Table of Contents

Class TwLocalizer

Namespace
TwBlazor.Localization
Assembly
TwBlazor.dll

The default ITwLocalizer. It reads the resource files registered on Resources first and falls back to TwBlazor's built in strings.

public class TwLocalizer : ITwLocalizer
Inheritance
TwLocalizer
Implements
Inherited Members
Extension Methods

Constructors

TwLocalizer(TwBlazorOptions)

Initializes a new instance of the TwLocalizer class.

public TwLocalizer(TwBlazorOptions options)

Parameters

options TwBlazorOptions

The options AddTwBlazor was configured with.

Properties

Direction

Gets the direction the current language is read in. Components use it to mirror their keyboard navigation, so that the arrow keys keep following what is on screen.

public virtual TextDirection Direction { get; }

Property Value

TextDirection

Formats

Gets the date and time formats for the current culture.

public virtual TwDateTimeFormats Formats { get; }

Property Value

TwDateTimeFormats

this[string]

Gets the text for a key in the current language.

public virtual string this[string key] { get; }

Parameters

key string

One of the TwStrings keys.

Property Value

string

The text, or key when nothing is registered for it.

this[string, object?[]]

Gets the text for a key in the current language, with its {0} placeholders filled in.

public virtual string this[string key, params object?[] arguments] { get; }

Parameters

key string

One of the TwStrings keys.

arguments object[]

The values for the placeholders.

Property Value

string

The formatted text.

formatCulture

Gets the culture dates, times and numbers are formatted with.

protected virtual CultureInfo formatCulture { get; }

Property Value

CultureInfo

textCulture

Gets the culture text is looked up for.

protected virtual CultureInfo textCulture { get; }

Property Value

CultureInfo

Methods

CreateFormats(CultureInfo, CultureInfo)

Resolves the date and time formats for a culture: the configured options first, then the Format_ entries of the resource files, then the culture's own patterns.

protected virtual TwDateTimeFormats CreateFormats(CultureInfo text, CultureInfo format)

Parameters

text CultureInfo

The culture resource files are read for.

format CultureInfo

The culture dates and times are formatted with.

Returns

TwDateTimeFormats

The resolved formats.

GetString(string, CultureInfo)

Looks a key up in the registered resource files, then in the built in strings.

protected virtual string? GetString(string key, CultureInfo culture)

Parameters

key string

One of the TwStrings keys.

culture CultureInfo

The culture to look the key up for.

Returns

string

The text, or null when no resource file has a value for the key.