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
optionsTwBlazorOptionsThe options
AddTwBlazorwas 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
Formats
Gets the date and time formats for the current culture.
public virtual TwDateTimeFormats Formats { get; }
Property Value
this[string]
Gets the text for a key in the current language.
public virtual string this[string key] { get; }
Parameters
Property Value
- string
The text, or
keywhen 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
Property Value
- string
The formatted text.
formatCulture
Gets the culture dates, times and numbers are formatted with.
protected virtual CultureInfo formatCulture { get; }
Property Value
textCulture
Gets the culture text is looked up for.
protected virtual CultureInfo textCulture { get; }
Property Value
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
textCultureInfoThe culture resource files are read for.
formatCultureInfoThe 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
keystringOne of the TwStrings keys.
cultureCultureInfoThe culture to look the key up for.
Returns
- string
The text, or
nullwhen no resource file has a value for the key.