Constructor
new L18n(appInstance)
Constructor
Parameters:
Name | Type | Description |
---|---|---|
appInstance | App | InfrontJS App reference |
- Source
Methods
addTranslation(langCode, translationObject)
Add given translation object to dictionary
Parameters:
Name | Type | Description |
---|---|---|
langCode | string | Langugae code (2 chars) |
translationObject | object | The translation object, simple key-value object, e.g. { 'Hello' : 'Hallo' } |
- Source
expose()
Export localization functions to window scope.
- Source
getCurrentLanguage() → {string}
Get current selected language
- Source
Returns:
- Returns 2 chared language code
- Type:
- string
getDateTime(dt, optsopt) → {string}
Get formatted date time
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dt | Date | Date object to format | ||
opts | Object | <optional> | null | DateTimeFormat options used if set. @see DateTimeFormat |
- Source
Returns:
- Type:
- string
getLocale(key, paramsopt) → {string}
Gets current translation by given key
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key | string | Translation key | |
params | array | <optional> | Params array |
- Source
Returns:
- Type:
- string
getNumber(num, optsopt) → {string}
Get formatted number
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
num | Date | 0 | Number to format | |
opts | Object | <optional> | null | NumberFormat options used if set. @see NumberFormat |
- Source
Returns:
- Type:
- string
resolveBrowserLanguage() → {*|null|string}
Resolve preferred browser language
- Source
Returns:
- Type:
- * |
null | string
setCurrentLanguage(langCode)
Set current language
Parameters:
Name | Type | Description |
---|---|---|
langCode | string | 2 chared language code |
- Source
Throws:
- Invalid language code
- Type
- Error
setDictionary(dictopt)
Sets dictionary
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dict | object | <optional> | { defaultLang : { "langCode" : "translation", ... }, ... } | Dictionary |
- Source