lang
- Description:
- Internationalisation of language strings
- Source:
Classes
- LangModule
Methods
(static) exports.storeStrings(phrases, key, value)
- Description:
- Parses a dotted language key and stores the value in the phrases dictionary
- Source:
Parameters:
| Name |
Type |
Description |
phrases |
Object
|
The phrases dictionary to store into |
key |
String
|
Key in the format 'lang.namespace.key' |
value |
String
|
The string value to store |
(static) exports.translate(phrases, defaultLang, logWarn, lang, key, data) → {String}
- Description:
- Returns translated language string
- Source:
Parameters:
| Name |
Type |
Description |
phrases |
Object
|
The phrases dictionary |
defaultLang |
String
|
Default language to use when lang is not a string |
logWarn |
function
|
Logging function for missing keys (receives message string) |
lang |
String
|
The target language (if undefined, the default language will be used) |
key |
String
|
AdaptError
|
The unique string key (if an AdaptError is passed, the error data will be used for the data param) |
data |
Object
|
Dynamic data to be inserted into translated string |
Returns:
-
Type
-
String
(static) exports.translateError(phrases, defaultLang, logWarn, lang, error)
- Description:
- Source:
Parameters:
| Name |
Type |
Description |
phrases |
Object
|
The phrases dictionary |
defaultLang |
String
|
Default language to use when lang is not a string |
logWarn |
function
|
Logging function for missing keys (receives message string) |
lang |
String
|
The target language |
error |
AdaptError
|
Error to translate |
Returns:
The translated error (if passed error is not an instance of AdaptError, the original value will be returned)