I18n

i18n~ I18n

I18n class for dealing with translations

Constructor

new I18n()

Source:

Methods

(static) getI18n() → {I18n}

Source:

Return a new instance of this class

Returns:
Type
I18n

addSource(path)

Source:

Adds a .properties file to the list of sources to load translations from

Files are loaded in the order they're added, and the first translation of each string that's encountered will be used.

Parameters:
Name Type Description
path String

addStrings(strings)

Source:

Adds one or more strings to the list of strings to translate

Parameters:
Name Type Description
strings Array.<String> | String

getTranslation(string) → {String}

Source:

Gets the translated version of the specified string

If no translation exists for the specified string, the string is returned as is with two asterisks on each side, in order to easily identify missing translations in the UI

Parameters:
Name Type Description
string
Returns:
Type
String

getUntranslatedStrings() → {Array|undefined}

Source:

Get the list of strings that don't have translations

If no translations have been loaded yet, undefined is returned in stead.

Returns:

Array of untranslated strings, or undefined if translations haven't been loaded

Type
Array | undefined

isTranslated(string) → {boolean}

Source:

Check if a translation exists for the specified string

Parameters:
Name Type Description
string
Returns:

True if a translation exists, false otherwise

Type
boolean

load() → {Promise}

Source:

Load translations

First, all properties files (specified with addSource) are loaded. Then, if any untranslated strings remain, these are POSTed to the i18n endpoint of the DHIS2 API.

Returns:
Type
Promise