Table of Contents

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

T

The 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

factory IStringLocalizerFactory

Properties

this[string]

Gets the localized string with the given name (key).

If the string contains placeholders, they are replaced with the placeholder names. To provide values for placeholders, use the this[string, object[]] property.

public LocalizedString this[string name] { get; }

Parameters

name string

The name (key) of the string to return.

Property Value

LocalizedString

The value of the string with an indicator of whether the localized string was found (if the resource was not found, the value from the default translation is returned).

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.

public LocalizedString this[string name, params object[] arguments] { get; }

Parameters

name string

The name (key) of the string to return.

arguments object[]

The list of values to use to replace placeholders.

Property Value

LocalizedString

The value of the string with an indicator of whether the localized string was found (if the resource was not found, the value from the default translation is returned).

Methods

GetAllStrings(bool)

Returns all localized strings contained in the translation for the given culture and, optionally, its parent cultures.

public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)

Parameters

includeParentCultures bool

Indicates whether the strings from the parent cultures should be returned.

Returns

IEnumerable<LocalizedString>

The list of the localized strings. If the values from multiple cultures are returned, the string keys may overlap (Tlumach does not reduce the list to just unique keys).

WithCulture(CultureInfo)

Switches the culture, used by the localizer object when retrieving localized text.

public IStringLocalizer WithCulture(CultureInfo culture)

Parameters

culture CultureInfo

The new culture to use.

Returns

IStringLocalizer

The localizer object to be used.

WithTextProcessingMode(TextFormat)

Switches the text processing mode, used by the localizer object when processing text which contains placeholders.

public IStringLocalizer WithTextProcessingMode(TextFormat textProcessingMode)

Parameters

textProcessingMode TextFormat

The mode to use.

Returns

IStringLocalizer

The localizer object to be used.