Table of Contents

Class TranslationEntry

Namespace
Tlumach.Base
Assembly
Tlumach.Base.dll

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

key string

The key to which the translation entry corresponds.

text string

An optional localized text of the translation entry that has been un-escaped if necessary.

escapedText string

An optional localized text of the translation entry that has not been un-escaped.

reference string

An 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

string

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

bool

Context

Gets or sets an optional description of the context.

public string? Context { get; set; }

Property Value

string

Description

Gets or sets an optional description of the entry.

public string? Description { get; set; }

Property Value

string

Empty

Gets a static instance that represents an empty entry.

public static TranslationEntry Empty { get; }

Property Value

TranslationEntry

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

string

Key

Gets the original key of the entry.

public string Key { get; }

Property Value

string

Placeholders

Gets an optional collection of placeholder descriptions.

public List<Placeholder>? Placeholders { get; }

Property Value

List<Placeholder>

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

string

Screen

Gets or sets an optional reference to a screenshot of the entry.

public string? Screen { get; set; }

Property Value

string

SourceText

Gets or sets an optional original text that was translated.

public string? SourceText { get; set; }

Property Value

string

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

string

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

string

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

string

Video

Gets or sets an optional reference to a video of the entry.

public string? Video { get; set; }

Property Value

string

Methods

AddPlaceholder(Placeholder)

public void AddPlaceholder(Placeholder placeholder)

Parameters

placeholder Placeholder

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

culture CultureInfo

The culture/locale for which the text is needed.

textProcessingMode TextFormat

The required text processing mode.

placeholderValues IDictionary<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

culture CultureInfo

The culture/locale for which the text is needed.

textProcessingMode TextFormat

The required text processing mode.

placeholderValues OrderedDictionary

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, 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

culture CultureInfo

The culture/locale for which the text is needed.

textProcessingMode TextFormat

The required text processing mode.

getPlaceholderValueFunc Func<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

culture CultureInfo

The culture/locale for which the text is needed.

textProcessingMode TextFormat

The required text processing mode.

placeholderValues 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, 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

culture CultureInfo

The culture/locale for which the text is needed.

textProcessingMode TextFormat

The required text processing mode.

placeholderValues 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.

Unlock()

For internal use only.

public void Unlock()