Localization

Localization

A helper class which assists with localization and string translation

Constructor

new Localization()

Source:

Members

_fallback :Object

Source:

Fallback translations if the target keys are not found

Type:
  • Object

lang :String

Source:

The target language for localization

Type:

translations :Object

Source:

The translation dictionary for the target language

Type:
  • Object

Methods

(async) initialize() → {Promise}

Source:

Initialize the Localization module Discover available language translations and apply the current language setting

Returns:
Type
Promise

localize(stringId) → {String}

Source:

Localize a string by drawing a translation from the available translations dictionary, if available If a translation is not available, the original string is returned

Parameters:
Name Type Description
stringId String

The string ID to translate

Returns:

The translated string

Type
String

(async) setLanguage(lang) → {Promise}

Source:

Set a language as the active translation source for the session

Parameters:
Name Type Description
lang String

A language string in CONFIG.supportedLanguages

Returns:

A Promise which resolves once the translations for the requested language are ready

Type
Promise