LocaleHelper

lumin.utils. LocaleHelper

Localization wrapper around ICU

Constructor

new LocaleHelper(localeopt, pathopt, fileopt)

Constructor

Parameters:
Name Type Attributes Default Description
locale string <optional>
"en"

the locale code to initialize the helper with (E.g. "en", "en_US", "es" etc.)

path string <optional>
"res"

the path of the icu data file (e.g. "res")

file string <optional>
"locale"

the filename of the locale file (the .dat extension is not required)

Classes

Param
Param
Param

Methods

formatUTF8String(input, arguments) → {string}

Format a given string with the given string arguments (only string replacements are possible with this method)

Parameters:
Name Type Description
input string

the string to format

arguments Array.<string>

a vector of strings - argument names will be numbers (e.g. the first element will be named "0", the second will be "1" etc.)

Returns:

the formatted output string

Type
string

formatUTF8String(input, arguments) → {string}

Format a given string with the given Params

Parameters:
Name Type Description
input string

the string to format

arguments Array.<lumin.utils.LocaleHelper.Param>

a vector of Params - argument names will be numbers (e.g. the first element will be named "0", the second will be "1" etc.)

Returns:

the formatted output string

Type
string

formatUTF8String(input, arguments) → {string}

Format a given string with the given string arguments (only string replacements are possible with this method)

Parameters:
Name Type Description
input string

the string to format

arguments Object.<string, string>

a map of argument names to argument string values

Returns:

the formatted output string

Type
string

formatUTF8String(input, arguments) → {string}

Format a given string with the given Params

Parameters:
Name Type Description
input string

the string to format

arguments Object.<string, lumin.utils.LocaleHelper.Param>

a map of argument names to Params

Returns:

the formatted output string

Type
string

getFormattedUTF8String(key, arguments) → {string}

Locate a string in the locale data with the given key and format it with the given Params

Parameters:
Name Type Description
key string

the key of the requested localized string

arguments Object.<string, lumin.utils.LocaleHelper.Param>

a map of argument names to Params

Returns:

the formatted output string

Type
string

getFormattedUTF8String(key, arguments) → {string}

Locate a string in the locale data with the given key and format it with the given Params

Parameters:
Name Type Description
key string

the key of the requested localized string

arguments Array.<lumin.utils.LocaleHelper.Param>

a vector of Params - argument names will be numbers (e.g. the first element will be named "0", the second will be "1" etc.)

Returns:

the formatted output string

Type
string

getFormattedUTF8String(key, arguments) → {string}

Locate a string in the locale data with the given key and format it with the given string arguments (only string replacements are possible with this method)

Parameters:
Name Type Description
key string

the key of the requested localized string

arguments Object.<string, string>

a map of argument names to argument string values

Returns:

the formatted output string

Type
string

getFormattedUTF8String(key, arguments) → {string}

Locate a string in the locale data with the given key and format it with the given string arguments (only string replacements are possible with this method)

Parameters:
Name Type Description
key string

the key of the requested localized string

arguments Array.<string>

a vector of strings - argument names will be numbers (e.g. the first element will be named "0", the second will be "1" etc.)

Returns:

the formatted output string

Type
string

getLocale() → {string}

Get the current locale code

Returns:

the current locale code

Type
string

getLocalizedPath(path) → {string}

Helper method to get the localized path of a resource using the LocaleHelper's current locale

Parameters:
Name Type Description
path string

is the relative path to the resource

Returns:

the path to the resource if found

Type
string

getUTF8String(key) → {string}

Retrieves a string from the locale data with the given key and performs no formatting

Parameters:
Name Type Description
key string

the key of the requested localized string

Returns:

the requested string

Type
string

init() → {boolean}

Initialize the locale helper. This or setLocale must be called before other methods are available.

Returns:

true if initialized successfully, false otherwise

Type
boolean

setLocale(locale) → {boolean}

Change the locale of the locale helper

Parameters:
Name Type Description
locale string

the new locale code

Returns:

true if locale data was found for the new locale, false otherwise

Type
boolean