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

Localizer which translations can be loaded from different sources. More...

Inheritance diagram for ILoadableLocalizer:
ILocalizer AutoLoadLocalizer Localizer

Classes

class  ParseException
 Exception thrown when a localization file cannot be parsed properly. More...
 

Public Member Functions

void LoadXML (string filepath, CultureInfo? culture=null)
 Loads translations for the given culture from a localization configuration file in XML format. More...
 
void LoadXML (string filepath, string language)
 Loads translations for the given language from a localization configuration file in XML format. More...
 
void LoadXML (string filepath, bool merge)
 Loads translations for the current localizer language from a localization configuration file in XML format. More...
 
void LoadXML (Stream stream, CultureInfo? culture=null)
 Loads translations for the given culture from a localization configuration file in XML format obtained from a stream. More...
 
void LoadXML (Stream stream, string language)
 Loads translations for the given language from a localization configuration file obtained in XML format from a stream. More...
 
void LoadXML (Stream stream, bool merge)
 Loads translations for the current localizer language from a localization configuration file in XML format obtained from a stream. More...
 
void LoadXML (XDocument doc, CultureInfo? culture=null)
 Loads translations for the given culture from a localization configuration in an XML document. More...
 
void LoadXML (XDocument doc, string language)
 Loads translations for the given language from a localization configuration in an XML document. More...
 
void LoadXML (XDocument doc, bool merge)
 Loads translations for the current localizer language from a localization configuration in an XML document. More...
 
void LoadXML (Assembly assembly, string resourceName, CultureInfo? culture=null)
 Loads translations for the given culture from a localization configuration file in XML format obtained from an embedded resource in the given assembly. More...
 
void LoadXML (Assembly assembly, string resourceName, string language)
 Loads translations for the given language from a localization configuration file in XML format obtained from an embedded resource in the given assembly. More...
 
void LoadXML (Assembly assembly, string resourceName, bool merge)
 Loads translations for the current localizer language from a localization configuration file in XML format obtained from an embedded resource in the given assembly. More...
 
string Localize (PlainString text)
 Localizes a string. More...
 
string Localize (FormattableString frmtText)
 Localizes an interpolated string. More...
 
IEnumerable< string > Localize (IEnumerable< string > texts)
 Localizes multiple strings. More...
 
string LocalizeFormat (string format, params object[] args)
 Localizes and then formats a string. 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

Localizer which translations can be loaded from different sources.

Member Function Documentation

◆ Context() [1/2]

ILocalizer Context ( IEnumerable< string >  splitContextIds)
inherited

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)
inherited

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.

◆ LoadXML() [1/12]

void LoadXML ( Assembly  assembly,
string  resourceName,
bool  merge 
)

Loads translations for the current localizer language from a localization configuration file in XML format obtained from an embedded resource in the given assembly.

Parameters
assemblyAssembly that contains the embedded XML file.
resourceNameName of the embedded resource for the XML file.
mergeReplaces the current translations with the loaded ones when<c>false, otherwise merges both (existing translations are overridden with loaded ones).
Exceptions
ParseExceptionThrown when the stream contents cannot be parsed properly.
InvalidOperationExceptionThrown when the embedded resource could not be found in the given assembly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [2/12]

void LoadXML ( Assembly  assembly,
string  resourceName,
CultureInfo?  culture = null 
)

Loads translations for the given culture from a localization configuration file in XML format obtained from an embedded resource in the given assembly.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

Parameters
assemblyAssembly that contains the embedded XML file.
resourceNameName of the embedded resource for the XML file.
cultureCulture for the target language of translations, or null to use the current UI culture (obtained from CultureInfo.CurrentUICulture).
Exceptions
ParseExceptionThrown when the embedded resource contents cannot be parsed properly.
InvalidOperationExceptionThrown when the embedded resource could not be found in the given assembly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [3/12]

void LoadXML ( Assembly  assembly,
string  resourceName,
string  language 
)

Loads translations for the given language from a localization configuration file in XML format obtained from an embedded resource in the given assembly.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

If the system does not support a culture for language , then CultureInfo.InvariantCulture will be used as the culture for formatting operations.

Parameters
assemblyAssembly that contains the embedded XML file.
resourceNameName of the embedded resource for the XML file.
languageName, code or identifier for the target language of translations.
Exceptions
ParseExceptionThrown when the embedded resource contents cannot be parsed properly.
InvalidOperationExceptionThrown when the embedded resource could not be found in the given assembly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [4/12]

void LoadXML ( Stream  stream,
bool  merge 
)

Loads translations for the current localizer language from a localization configuration file in XML format obtained from a stream.

Parameters
streamStream with the localization configuration.
mergeReplaces the current translations with the loaded ones when<c>false, otherwise merges both (existing translations are overridden with loaded ones).
Exceptions
ParseExceptionThrown when the stream contents cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [5/12]

void LoadXML ( Stream  stream,
CultureInfo?  culture = null 
)

Loads translations for the given culture from a localization configuration file in XML format obtained from a stream.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

Parameters
streamStream with the localization configuration.
cultureCulture for the target language of translations, or null to use the current UI culture (obtained from CultureInfo.CurrentUICulture).
Exceptions
ParseExceptionThrown when the stream contents cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [6/12]

void LoadXML ( Stream  stream,
string  language 
)

Loads translations for the given language from a localization configuration file obtained in XML format from a stream.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

If the system does not support a culture for language , then CultureInfo.InvariantCulture will be used as the culture for formatting operations.

Parameters
streamStream with the localization configuration.
languageName, code or identifier for the target language of translations.
Exceptions
ParseExceptionThrown when the stream contents cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [7/12]

void LoadXML ( string  filepath,
bool  merge 
)

Loads translations for the current localizer language from a localization configuration file in XML format.

Parameters
filepathPath to the localization configuration file.
mergeReplaces the current translations with the loaded ones when<c>false, otherwise merges both (existing translations are overridden with loaded ones).
Exceptions
ParseExceptionThrown when the input file cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [8/12]

void LoadXML ( string  filepath,
CultureInfo?  culture = null 
)

Loads translations for the given culture from a localization configuration file in XML format.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

Parameters
filepathPath to the localization configuration file.
cultureCulture for the target language of translations, or null to use the current UI culture (obtained from CultureInfo.CurrentUICulture).
Exceptions
ParseExceptionThrown when the input file cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [9/12]

void LoadXML ( string  filepath,
string  language 
)

Loads translations for the given language from a localization configuration file in XML format.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

If the system does not support a culture for language , then CultureInfo.InvariantCulture will be used as the culture for formatting operations.

Parameters
filepathPath to the localization configuration file.
languageName, code or identifier for the target language of translations.
Exceptions
ParseExceptionThrown when the input file cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [10/12]

void LoadXML ( XDocument  doc,
bool  merge 
)

Loads translations for the current localizer language from a localization configuration in an XML document.

Parameters
docXML document with the localization configuration.
mergeReplaces the current translations with the loaded ones when<c>false, otherwise merges both (existing translations are overridden with loaded ones).
Exceptions
ParseExceptionThrown when the stream contents cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [11/12]

void LoadXML ( XDocument  doc,
CultureInfo?  culture = null 
)

Loads translations for the given culture from a localization configuration in an XML document.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

Parameters
docXML document with the localization configuration.
cultureCulture for the target language of translations, or null to use the current UI culture (obtained from CultureInfo.CurrentUICulture).
Exceptions
ParseExceptionThrown when the input document cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ LoadXML() [12/12]

void LoadXML ( XDocument  doc,
string  language 
)

Loads translations for the given language from a localization configuration in an XML document.

All the translations loaded previously in the localizer are discarded and replaced with the new ones.

If the system does not support a culture for language , then CultureInfo.InvariantCulture will be used as the culture for formatting operations.

Parameters
docXML document with the localization configuration.
languageName, code or identifier for the target language of translations.
Exceptions
ParseExceptionThrown when the input document cannot be parsed properly.

Implemented in AutoLoadLocalizer, and Localizer.

◆ Localize() [1/3]

string Localize ( FormattableString  frmtText)
inherited

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)
inherited

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)
inherited

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 
)
inherited

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
getinherited

Target culture of the localizer.

Implemented in AutoLoadLocalizer, and ContextLocalizer.

◆ TargetLanguage

string TargetLanguage
getinherited

Target language of the localizer.

Implemented in AutoLoadLocalizer, and ContextLocalizer.