Class BaseTranslationUnit
- Namespace
- Tlumach
- Assembly
- Tlumach.dll
The base class for TranslationUnit classes.
public class BaseTranslationUnit
- Inheritance
-
BaseTranslationUnit
- Derived
- Inherited Members
Constructors
BaseTranslationUnit(TranslationManager, TranslationConfiguration, bool)
protected BaseTranslationUnit(TranslationManager translationManager, TranslationConfiguration translationConfiguration, bool containsPlaceholders)
Parameters
translationManagerTranslationManagertranslationConfigurationTranslationConfigurationcontainsPlaceholdersbool
BaseTranslationUnit(TranslationManager, TranslationConfiguration, string, bool)
public BaseTranslationUnit(TranslationManager translationManager, TranslationConfiguration translationConfiguration, string key, bool containsPlaceholders)
Parameters
translationManagerTranslationManagertranslationConfigurationTranslationConfigurationkeystringcontainsPlaceholdersbool
Properties
ContainsPlaceholders
Gets the value indicating whether the text of the unit contains placeholders, and the application has to provide values via the OnPlaceholderValueNeeded event or using the CachePlaceholderValue(string, object?) method.
public bool ContainsPlaceholders { get; }
Property Value
Key
Gets the key of the translation unit, i.e., the identifier with which this unit appears in translation files.
public string Key { get; }
Property Value
TranslationConfiguration
Gets a reference to the configuration used when creating a unit.
protected TranslationConfiguration TranslationConfiguration { get; }
Property Value
TranslationManager
Gets the reference to the translation manager, associated with this unit.
public TranslationManager TranslationManager { get; }
Property Value
Methods
CachePlaceholderValue(string, object?)
Adds a value for the placeholder to the cache.
Call NotifyPlaceholdersUpdated() to notify the bindings after the list of values is upated.
public void CachePlaceholderValue(string name, object? value)
Parameters
ForgetPlaceholderValue(string)
Removes the value from the cache.
Call NotifyPlaceholdersUpdated() to notify the bindings after the list of values is upated.
public void ForgetPlaceholderValue(string name)
Parameters
namestringThe name of the placeholder, whose value is to be removed.
GetValue()
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
This overload will use the cached values if those are available, or will fire the OnPlaceholderValueNeeded event to obtain the values.
public string GetValue()
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(IDictionary<string, object?>)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named placeholders. It will work for indexed placeholders if the values in the `placeholderValues` dictionary use indexes for keys.
public string GetValue(IDictionary<string, object?> placeholderValues)
Parameters
placeholderValuesIDictionary<string, object>A dictionary that contains placeholder names as keys and actual values to substitute as values.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(OrderedDictionary)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for both named and indexed placeholders.
public string GetValue(OrderedDictionary placeholderValues)
Parameters
placeholderValuesOrderedDictionaryA dictionary that contains placeholder names as keys and actual values to substitute as values.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(CultureInfo)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
This overload will use the cached values if those are available, or will fire the OnPlaceholderValueNeeded event to obtain the values.
public string GetValue(CultureInfo culture)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(CultureInfo, IDictionary<string, object?>)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named placeholders. It will work for indexed placeholders if the values in the `placeholderValues` dictionary use indexes for keys.
public string GetValue(CultureInfo culture, IDictionary<string, object?> placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
placeholderValuesIDictionary<string, object>A dictionary that contains placeholder names as keys and actual values to substitute as values.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(CultureInfo, OrderedDictionary)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for both named and indexed placeholders.
public string GetValue(CultureInfo culture, OrderedDictionary placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
placeholderValuesOrderedDictionarya dictionary that contains placeholder names as keys and actual values to substitute as values.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(CultureInfo, object)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named placeholders but not for indexed ones.
public string GetValue(CultureInfo culture, object placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
placeholderValuesobjectAn object, whose properties are used to provide values for placeholders in the template. The names of the template's placeholders are matched with the object property names in a case-insensitive manner.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
is thrown if processing of the template fails.
GetValue(CultureInfo, params object[])
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for indexed placeholders but not for named ones.
public string GetValue(CultureInfo culture, params object[] placeholderValues)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
placeholderValuesobject[]a dictionary that contains placeholder names as keys and actual values to substitute as values.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
thrown if processing of the template fails.
GetValue(object)
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for named placeholders but not for indexed ones.
public string GetValue(object placeholderValues)
Parameters
placeholderValuesobjectAn object, whose properties are used to provide values for placeholders in the template. The names of the template's placeholders are matched with the object property names in a case-insensitive manner.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
is thrown if processing of the template fails.
GetValue(params object[])
Processes the templated translation entry by substituting the placeholders with actual values and returns the final text.
If TextProcessingMode is DotNet, Arb, or ArbNoEscaping, this overload will work for indexed placeholders but not for named ones.
public string GetValue(params object[] placeholderValues)
Parameters
placeholderValuesobject[]a dictionary that contains placeholder names as keys and actual values to substitute as values.
Returns
- string
The requested text or an empty string.
Exceptions
- TemplateProcessingException
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(string, params object[]) method or its overloads).
public string GetValueAsTemplate(CultureInfo culture)
Parameters
cultureCultureInfoThe culture/locale for which the text is needed.
Returns
- string
The requested text or an empty string.
InternalGetEntry(CultureInfo)
protected virtual TranslationEntry? InternalGetEntry(CultureInfo cultureInfo)
Parameters
cultureInfoCultureInfo
Returns
InternalGetValueAsText(CultureInfo)
protected virtual string InternalGetValueAsText(CultureInfo culture)
Parameters
cultureCultureInfo
Returns
NotifyPlaceholdersUpdated()
Notifies XAML bindings that they need to request a new value and update the controls.
Use this method when underlying data changes regardless of whether you cache this data as values or pass it via the OnPlaceholderValueNeeded event.
public virtual void NotifyPlaceholdersUpdated()
Events
OnPlaceholderValueNeeded
Fires when the value for a placeholder is needed during the retrieval of the text.
public event EventHandler<PlaceholderValueNeededEventArgs>? OnPlaceholderValueNeeded