i18NV3 - Client

Provides methods to get and format translated messages.

The i18N methods are accessed using the g_i18n global object.

i18NV3 - getMessage(String msgKey, Function callback)

Retrieves a translated message.

If the specified string exists in the database for the current language, then the translated message is returned. If the specified string does not exist for the current language, then the English version of the string is returned. If the string does not exist at all in the database, then the ID itself is returned.

Table 1. Parameters
Name Type Description
msgKey String The message to be retrieved.
callback Function The function to be called when the message has been retrieved. The callback function has one argument, a string that is the translated message.
Table 2. Returns
Type Description
void

i18NV3 - getMessages(Array msgKeys, Function callback)

Retrieves a set of messages.

If the specified string exists in the database for the current language, then the translated message is returned. If the specified string does not exist for the current language, then the English version of the string is returned. If the string does not exist at all in the database, then the ID itself is returned.

Table 3. Parameters
Name Type Description
msgKeys Array An array of keys specifying the messages to be retrieved.
callback Function The function to be called when the messages have been retrieved. The callback function has one argument, an object containing key-value pairs, where key is the requested message key, and the value is the translated string.
Table 4. Returns
Type Description
void

i18NV3 - format(String message, Object map)

Formats a string containing named tokens with values from a map.

Table 5. Parameters
Name Type Description
message String The message to have the tokens added.
map Object The map of name/value pairs to replace in the message.
Table 6. Returns
Type Description
String The formatted string
// Returns: "The rich young ruler was very very rich"
nowapi.i18n.format("The {p1} {p2} {p3} was very very {p1}",{p1: "rich", p2: "young", p3: "ruler"});