lib/xp/i18n

Internationalization functions.

Example
var i18nLib = require('/lib/xp/i18n');

Methods

(static) localize(params) → {string}

This function localizes a phrase.

Parameters:
Name Type Description
params object

JSON with the parameters.

Properties
Name Type Attributes Description
key string

The property key.

locale string <optional>

A string-representation of a locale. If the locale is not set, the site language is used.

values Array.<string> <optional>

Optional placeholder values.

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"]
});