I18N.DotNet v1.3.1
Loading...
Searching...
No Matches
Public Member Functions | Properties | List of all members
ILocalizer Interface Reference

Converter of strings from a base-language value to its corresponding language-specific localization. More...

Inheritance diagram for ILocalizer:
ContextLocalizer ILoadableLocalizer Localizer AutoLoadLocalizer Localizer

Public Member Functions

string Localize (PlainString text)
 Localizes a string. More...
 
string Localize (FormattableString frmtText)
 Localizes an interpolated string. More...
 
string LocalizeFormat (string format, params object[] args)
 Localizes and then formats a string. More...
 
IEnumerable< string > Localize (IEnumerable< string > texts)
 Localizes multiple strings. More...
 
ILocalizer Context (string contextId)
 Gets the localizer for a context in the current localizer. More...
 
ILocalizer Context (IEnumerable< string > splitContextIds)
 Gets the localizer for a context in the current localizer. More...
 

Properties

string TargetLanguage [get]
 Target language of the localizer. More...
 
CultureInfo TargetCulture [get]
 Target culture of the localizer. More...
 

Detailed Description

Converter of strings from a base-language value to its corresponding language-specific localization.

Member Function Documentation

◆ Context() [1/2]

ILocalizer Context ( IEnumerable< string >  splitContextIds)

Gets the localizer for a context in the current localizer.

Contexts are used to disambiguate the conversion of the same base-language string to different language-specific strings depending on the context where the conversion is performed.

Parameters
splitContextIdsChain of context identifiers in split form.
Returns
Localizer for the given context.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ Context() [2/2]

ILocalizer Context ( string  contextId)

Gets the localizer for a context in the current localizer.

Contexts are used to disambiguate the conversion of the same base-language string to different language-specific strings depending on the context where the conversion is performed.

Contexts can be nested. The context identifier can identify a chain of nested contexts by separating their identifiers with the '.' character (left = outermost / right = innermost).

Parameters
contextIdIdentifier of the context.
Returns
Localizer for the given context.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ Localize() [1/3]

string Localize ( FormattableString  frmtText)

Localizes an interpolated string.

Converts the composite format string of the base-language formattable string frmtText (e.g. an interpolated string) to its corresponding language-specific localized composite format value, and then generates the result by formatting the localized composite format value along with the frmtText arguments by using the formatting conventions of the localizer culture.

Parameters
frmtTextBase-language formattable string.
Returns
Formatted string generated from the language-specific localized format string if found, or generated from frmtText otherwise.
Exceptions
FormatExceptionThrown when the localized format value of frmtText is invalid.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ Localize() [2/3]

IEnumerable< string > Localize ( IEnumerable< string >  texts)

Localizes multiple strings.

Converts the base-language strings in texts to their corresponding language-specific localized values.

Parameters
textsBase-language strings.
Returns
Language-specific localized strings if found, or the base-language string otherwise.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ Localize() [3/3]

string Localize ( PlainString  text)

Localizes a string.

Converts the base-language string text to its corresponding language-specific localized value.

Parameters
textBase-language string.
Returns
Language-specific localized string if found, or text otherwise.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ LocalizeFormat()

string LocalizeFormat ( string  format,
params object[]  args 
)

Localizes and then formats a string.

Converts the base-language format string format to its corresponding language-specific localized format value, and then generates the result by formatting the localized format value along with the args arguments by using the formatting conventions of the localizer culture.

Parameters
formatBase-language format string.
argsArguments for the format string.
Returns
Formatted string generated from the language-specific localized format string if found, or generated from format otherwise.
Exceptions
FormatExceptionThrown when format or its localized format value is invalid.

Implemented in AutoLoadLocalizer.

Property Documentation

◆ TargetCulture

CultureInfo TargetCulture
get

Target culture of the localizer.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ TargetLanguage

string TargetLanguage
get

Target language of the localizer.

Implemented in AutoLoadLocalizer, and ContextLocalizer.