Internationalization functions.
Example
var i18nLib = require('/lib/xp/i18n');
Methods
(static) getPhrases(locale, bundles) → {object}
This function returns all phrases.
Parameters:
Name | Type | Description |
---|---|---|
locale |
string | A string-representation of a locale. |
bundles |
Array.<string> | List of bundle names. |
Returns:
An object of all phrases.
- Type
- object
(static) localize(params) → {string}
This function localizes a phrase.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
object | JSON with the parameters. Properties
|
Returns:
The localized string.
- Type
- string
Examples
// Localizes a simple message.
var message1 = i18nLib.localize({
key: 'mymessage'
});
// Localizes a message with placeholders.
var message2 = i18nLib.localize({
key: 'mymessage_with_placeholder',
locale: "no",
values: ["John", "London"]
});