Class TranslationEntry
Represents an entry in the translation file. An entry may have a value (some text in a specific language) or be a reference to an external file with a translation.
Instances of this class are always owned by a dictionary which keeps the keys, and that dictionary is transferred in a way that specifies the locale. For this reason, TranslationEntry does not hold a key or locale ID.
public class TranslationEntry
- Inheritance
-
TranslationEntry
- Inherited Members
Constructors
TranslationEntry()
Initializes a new instance of the TranslationEntry class.
public TranslationEntry()
TranslationEntry(string, string?, string?, string?)
Initializes a new instance of the TranslationEntry class.
public TranslationEntry(string key, string? text, string? escapedText = null, string? reference = null)
Parameters
keystringThe key to which the translation entry corresponds.
textstringAn optional localized text of the translation entry that has been un-escaped if necessary.
escapedTextstringAn optional localized text of the translation entry that has not been un-escaped.
referencestringAn optional reference to an external file with the text.
Properties
Comment
Gets or sets an optional comment of the entry.
public string? Comment { get; set; }
Property Value
ContainsPlaceholders
Indicates that the text is a template and contains placeholders. When it is, use the ProcessTemplatedValue(CultureInfo, TextFormat, params object?[]) method or its overloads to format the template.
public bool ContainsPlaceholders { get; set; }
Property Value
Context
Gets or sets an optional description of the context.
public string? Context { get; set; }
Property Value
Description
Gets or sets an optional description of the entry.
public string? Description { get; set; }
Property Value
Empty
Gets a static instance that represents an empty entry.
public static TranslationEntry Empty { get; }
Property Value
EscapedText
Gets or sets a localized text that has not been un-escaped. This text is used when evaluating if the localized text contains templates and when processing those templates.
public string? EscapedText { get; set; }
Property Value
Key
Gets the original key of the entry.
public string Key { get; }
Property Value
Placeholders
Gets an optional collection of placeholder descriptions.
public List<Placeholder>? Placeholders { get; }
Property Value
Reference
Gets or sets an optional reference to an external file with the translation value.
A reference is set by the parser when the text starts with '@' (at) and the RecognizeFileRefs property is true.
public string? Reference { get; set; }
Property Value
Screen
Gets or sets an optional reference to a screenshot of the entry.
public string? Screen { get; set; }
Property Value
SourceText
Gets or sets an optional original text that was translated.
public string? SourceText { get; set; }
Property Value
Target
Gets or sets an optional target of the entry.
Targets are defined in the ARB specification as attributes of HTML elements to which the content should be assigned.
public string? Target { get; set; }
Property Value
Text
Gets or sets a localized text. This text has been un-escaped (if needed) during loading from the translation file.
public string? Text { get; set; }
Property Value
Type
Gets or sets an optional type of the entry.
Describes the type of resource. Possible values are "text", "image", "css".
public string? Type { get; set; }
Property Value
Video
Gets or sets an optional reference to a video of the entry.
public string? Video { get; set; }
Property Value
Methods
AddPlaceholder(Placeholder)
public void AddPlaceholder(Placeholder placeholder)
Parameters
placeholderPlaceholder
Lock()
For internal use only.
public void Lock()
ProcessTemplatedValue(CultureInfo, TextFormat, IDictionary<string, object?>)
/// Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
public string ProcessTemplatedValue(CultureInfo culture, TextFormat textProcessingMode, IDictionary<string, object?> placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
textProcessingModeTextFormatThe required text processing mode.
placeholderValuesIDictionary<string, object>The values for the placeholders of the entry.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
ProcessTemplatedValue(CultureInfo, TextFormat, OrderedDictionary)
/// Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
public string ProcessTemplatedValue(CultureInfo culture, TextFormat textProcessingMode, OrderedDictionary placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
textProcessingModeTextFormatThe required text processing mode.
placeholderValuesOrderedDictionaryThe values for the placeholders of the entry.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
ProcessTemplatedValue(CultureInfo, TextFormat, Func<string, int, object?>)
/// Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
public string ProcessTemplatedValue(CultureInfo culture, TextFormat textProcessingMode, Func<string, int, object?> getPlaceholderValueFunc)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
textProcessingModeTextFormatThe required text processing mode.
getPlaceholderValueFuncFunc<string, int, object>The function which will be called to obtain values for the placeholders.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
ProcessTemplatedValue(CultureInfo, TextFormat, object)
/// Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
public string ProcessTemplatedValue(CultureInfo culture, TextFormat textProcessingMode, object placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
textProcessingModeTextFormatThe required text processing mode.
placeholderValuesobjectThe values for the placeholders of the entry.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
ProcessTemplatedValue(CultureInfo, TextFormat, params object?[])
/// Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
public string ProcessTemplatedValue(CultureInfo culture, TextFormat textProcessingMode, params object?[] placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
textProcessingModeTextFormatThe required text processing mode.
placeholderValuesobject[]The values for the placeholders of the entry.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
Unlock()
For internal use only.
public void Unlock()