Class TlumachStringLocalizer<T>
- Namespace
- Tlumach.Extensions.Localization
- Assembly
- Tlumach.Extensions.Localization.dll
Represents an IStringLocalizer that provides strings for T.
public sealed class TlumachStringLocalizer<T> : IStringLocalizer<T>, IStringLocalizer
Type Parameters
TThe type that defines the context of localization. Please refer to the topic on Dependency Injection in Tlumach documentation for details.
- Inheritance
-
TlumachStringLocalizer<T>
- Implements
- Inherited Members
Constructors
TlumachStringLocalizer(IStringLocalizerFactory)
public TlumachStringLocalizer(IStringLocalizerFactory factory)
Parameters
factoryIStringLocalizerFactory
Properties
this[string]
Gets the localized string with the given name (key).
The value is the text of the translation entry as it stands, with the placeholders it contains left untouched. To have the placeholders replaced with values, use the this[string, object[]] property.
When the key is not present in any translation, the value is the key itself and ResourceNotFound is true.
public LocalizedString this[string name] { get; }
Parameters
namestringThe name (key) of the string to return.
Property Value
- LocalizedString
The value of the string with an indicator of whether it was found.
this[string, object[]]
Gets the localized string with the given name (key).
If the string contains placeholders, they are replaced with the placeholder values provided in the arguments parameter.
When the key is not present in any translation, the value is the key itself and ResourceNotFound is true.
public LocalizedString this[string name, params object[] arguments] { get; }
Parameters
namestringThe name (key) of the string to return.
argumentsobject[]The list of values to use to replace placeholders.
Property Value
- LocalizedString
The value of the string with an indicator of whether it was found.
Methods
GetAllStrings(bool)
Returns all localized strings contained in the translation for the current culture and, optionally, for its parent cultures and the default translation. Every key appears once.
public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)
Parameters
includeParentCulturesboolIndicates whether the strings from the parent cultures and from the default translation should be returned as well.
Returns
- IEnumerable<LocalizedString>
The list of the localized strings.
WithCulture(CultureInfo)
Returns a localizer that retrieves the strings for the given culture instead of the culture of the thread.
public IStringLocalizer WithCulture(CultureInfo culture)
Parameters
cultureCultureInfoThe culture to use.
Returns
- IStringLocalizer
A new localizer. The one whose method was called is left untouched.
WithTextProcessingMode(TextFormat)
Returns a localizer that uses the given text processing mode when it processes text which contains placeholders.
public IStringLocalizer WithTextProcessingMode(TextFormat textProcessingMode)
Parameters
textProcessingModeTextFormatThe mode to use.
Returns
- IStringLocalizer
A new localizer. The one whose method was called is left untouched.