api/utils/localization

Module for server side localization. Uses minimized localization files at frontend/express/public/localization/min/

Source:

Methods

(static) format(value, …var_args) → {string}

Source:

Replaces placeholders in localized string with provided values

Example
localize.getProperties(member.lang, function(err, properties){
    var message = localize.format(properties["mail.new-member"], mail.getUserFirstName(member), host, member.username, memberPassword);
    mail.sendMessage(member.email, properties["mail.new-member-subject"], message);
});
Parameters:
Name Type Attributes Description
value string

localized value with placeholders to be replaced

var_args * <repeatable>

other arguments to be inserted in localized string's placeholder places {}

Returns:

localized string with placeholders replaced by provided var_args values

Type
string

(static) getProperties(lang, callback)

Source:

Fetches whole localized object with property names as key and localized strings as values for provided language

Example
localize.getProperties(member.lang, function(err, properties){
    var message = localize.format(properties["mail.new-member"], mail.getUserFirstName(member), host, member.username, memberPassword);
    mail.sendMessage(member.email, properties["mail.new-member-subject"], message);
});
Parameters:
Name Type Description
lang string

2 symbol code for localization file to be fetched, for example, "en"

callback function

function to be called when localized proeprty files was fetched, receiving first param as error and second as properties object

(static) getProperty(lang, name, callback)

Source:

Fetches single localized string by property name for provided language

Example
localize.getProperty(member.lang, "mail.new-member-subject", function(err, subject){
    mail.sendMessage(member.email, subject);
});
Parameters:
Name Type Description
lang string

2 symbol code for localization file to be fetched, for example, "en"

name string

name of the localized proeprty to fetch

callback function

function to be called when localized proeprty files was fetched, receiving first param as error and second as localized string