L10N
Extends:
This class localizes texts by either selecting one from a dictionary (asynchron loaded JSON File) or choosing the right string from a selection.
Constructor Summary
| Public Constructor | ||
| public |
constructor(options: L10NOptions) |
|
Member Summary
| Public Members | ||
| public |
dictionary: * |
|
| Private Members | ||
| private |
|
|
| private |
|
|
| private |
|
|
| private |
languageFileUrl_: URL |
|
Method Summary
| Public Methods | ||
| public |
|
|
| public |
getCurrentLang(): string | * |
|
| public |
getDefaultLang(): * |
|
| public |
isRtl(): bool |
|
| public |
localiseUsingDictionary(identifier: string, silent: boolean): string Localise identifier using given dictionary. |
|
| public |
selectL10N(data: *): string Select language string. |
|
| public |
setAvailableLanguages(languages: string[]) |
|
| public |
setCurrentLang(lang: string) |
|
Public Constructors
public constructor(options: L10NOptions) source
Params:
| Name | Type | Attribute | Description |
| options | L10NOptions |
Public Methods
public localiseUsingDictionary(identifier: string, silent: boolean): string source
Localise identifier using given dictionary. Throws an error if identifier is not in dictionary. Relies on selectL10N to select actual localisation.
public selectL10N(data: *): string source
Select language string. Note that this routine throws an error if there is no fitting string. Method to obtain the fitting string:
- If there is no data, an 'Unable to obtain localization' error is thrown.
- If data is a string, that string is returned.
- If language is given and present in data, the string value for langage is returned.
- If the default language is given and present in data, that value is returned.
- If the special tag '*' is present in data, that value is returned.
- If still no string was found at this point, an 'Unable to obtain localization' error is thrown.
Params:
| Name | Type | Attribute | Description |
| data | * |
Return:
| string | a (presumably localised) string |
Return Properties:
| Name | Type | Attribute | Description |
| data | Localizable |
