i18nManager

i18nManager

This class contains the i18n translation manager.

Constructor

new i18nManager(language)

Parameters:
Name Type Description
language String
Source:

Methods

getTranslations()

Gets all translations.
Source:

message(key) → {String}

Searches the translation message according to given key.
Parameters:
Name Type Description
key String
Source:
Returns:
Returns the message connected to the given key.
Type
String
Example
const translations = new i18nManager(); 
translations.message("test.sentence");

messageWithValue(key, value) → {String}

Searches the translation message according to given key including a value.
Parameters:
Name Type Description
key String
value String
Source:
Returns:
Returns the message connected to the given key including the inserted value.
Type
String
Example
const translations = new i18nManager(); 
translations.messageWithValue("test.sentence", "value");

searchNestedObject(nestedObj, pathArr) → {Object}

Searches for nested objects in the translation object.
Parameters:
Name Type Description
nestedObj Object
pathArr Array
Source:
Returns:
Type
Object

setLanguage(language)

Sets the language of the translation manager.
Parameters:
Name Type Description
language String
Source:
Example
const translations = new i18nManager(); 
translations.setLanguage('de');

setPath(path)

Sets the path to the translation files.
Parameters:
Name Type Description
path String
Source:
Example
const translations = new i18nManager(); 
translations.setPath('./../i18n/');