Constructor
new i18nManager(language)
Parameters:
Name | Type | Description |
---|---|---|
language |
String |
Methods
getTranslations()
Gets all translations.
message(key) → {String}
Searches the translation message according to given key.
Parameters:
Name | Type | Description |
---|---|---|
key |
String |
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 |
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 |
Returns:
- Type
- Object
setLanguage(language)
Sets the language of the translation manager.
Parameters:
Name | Type | Description |
---|---|---|
language |
String |
Example
const translations = new i18nManager();
translations.setLanguage('de');
setPath(path)
Sets the path to the translation files.
Parameters:
Name | Type | Description |
---|---|---|
path |
String |
Example
const translations = new i18nManager();
translations.setPath('./../i18n/');