Class

I18n

I18n()

This class allows you to manage the translations of the texts contained in the application.

Constructor

# new I18n()

Constructor

View Source i18n/I18n.js, line 11

Methods

# addLocale(lang, locales)

Add locales.

Parameters:
Name Type Description
lang string

Language to add, in ISO (es_ES) format.

locales Object

Object with the key/value pairs for locales.

View Source i18n/I18n.js, line 26

# addLocales(obj)

Add an object of locales.

Parameters:
Name Type Description
obj Object

Language object. Key is the language code.

View Source i18n/I18n.js, line 36

# getLang()

Get the language of the user based on one setted by the platform.

View Source i18n/I18n.js, line 56

# getRegionCode() → {string}

Return the locale region code: 'en', 'es', ...

View Source i18n/I18n.js, line 76

Region code.

string

# init(forceopt)

Initialize translations

Parameters:
Name Type Attributes Default Description
force string | boolean <optional>
false

Force to passed language.

View Source i18n/I18n.js, line 94

# setLang(langopt)

Set the language.

Parameters:
Name Type Attributes Default Description
lang string <optional>
'en_US'

Language to force (es_ES, en_US, ...)

View Source i18n/I18n.js, line 111

# trans(str, langopt) → {string}

Translate a string to the current locale.

Parameters:
Name Type Attributes Default Description
str string

String to translate.

lang string <optional>
null

The destination language (Auto if null).

View Source i18n/I18n.js, line 48

string