Class TemplatedTranslationUnit
Represents a unit of translation - a unit of text (a word, a phrase, a sentence, etc.) in a translation accessible using a unique key - that contains parameters ('format items' in .NET terms).
This class enables an application to relay processing of templates on the library.
Inherited Members
Namespace: Tlumach
Assembly: Tlumach.dll
Syntax
public class TemplatedTranslationUnit : BaseTranslationUnit
Constructors
TemplatedTranslationUnit(TranslationManager, TranslationConfiguration, string)
Declaration
public TemplatedTranslationUnit(TranslationManager translationManager, TranslationConfiguration translationConfiguration, string key)
Parameters
| Type | Name | Description |
|---|---|---|
| TranslationManager | translationManager | |
| TranslationConfiguration | translationConfiguration | |
| string | key |
Methods
GetValue(IDictionary<string, object?>)
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named parameters. It will work for indexed parameters if the parameters in the `parameters` dictionary use indexes for keys.
Declaration
public string GetValue(IDictionary<string, object?> parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| IDictionary<string, object> | parameters | A dictionary that contains parameter names as keys and actual values to substitute as values. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | thrown if processing of the template fails. |
GetValue(OrderedDictionary)
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for both named and indexed parameters.
Declaration
public string GetValue(OrderedDictionary parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| OrderedDictionary | parameters | A dictionary that contains parameter names as keys and actual values to substitute as values. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | thrown if processing of the template fails. |
GetValue(CultureInfo, IDictionary<string, object?>)
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named parameters. It will work for indexed parameters if the parameters in the `parameters` dictionary use indexes for keys.
Declaration
public string GetValue(CultureInfo culture, IDictionary<string, object?> parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | The culture/locale for which the text is needed. |
| IDictionary<string, object> | parameters | A dictionary that contains parameter names as keys and actual values to substitute as values. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | thrown if processing of the template fails. |
GetValue(CultureInfo, OrderedDictionary)
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for both named and indexed parameters.
Declaration
public string GetValue(CultureInfo culture, OrderedDictionary parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | The culture/locale for which the text is needed. |
| OrderedDictionary | parameters | a dictionary that contains parameter names as keys and actual values to substitute as values. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | thrown if processing of the template fails. |
GetValue(CultureInfo, object)
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named parameters but not for indexed ones.
Declaration
public string GetValue(CultureInfo culture, object parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | The culture/locale for which the text is needed. |
| object | parameters | An object, whose properties are used to provide values for parameters in the template. The names of the template's parameters are matched with the object property names in a case-insensitive manner. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | is thrown if processing of the template fails. |
GetValue(CultureInfo, params object[])
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for indexed parameters but not for named ones.
Declaration
public string GetValue(CultureInfo culture, params object[] parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | culture | The culture/locale for which the text is needed. |
| object[] | parameters | a dictionary that contains parameter names as keys and actual values to substitute as values. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | thrown if processing of the template fails. |
GetValue(object)
Processes the template translation entry by substituting the parameters with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named parameters but not for indexed ones.
Declaration
public string GetValue(object parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| object | parameters | An object, whose properties are used to provide values for parameters in the template. The names of the template's parameters are matched with the object property names in a case-insensitive manner. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |
Exceptions
| Type | Condition |
|---|---|
| TemplateProcessingException | is thrown if processing of the template fails. |
GetValueAsTemplate(CultureInfo)
Returns the text of the template translation entry without processing the template. This may be useful when template processing is handled by the caller (e.g., when strings use .NET template format which is handled using the Format(IFormatProvider, string, object) method).
Declaration
public string GetValueAsTemplate(CultureInfo cultureInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| CultureInfo | cultureInfo | The culture/locale for which the text is needed. |
Returns
| Type | Description |
|---|---|
| string | The requested text or an empty string. |