Class: I18n

@aofl/i18n~ I18n

Provides translation capability.

new I18n( [translations])

Creates an instance of I18n.
Parameters:
Name Type Argument Default Description
translations Object <optional>
{} translations map
Source:

Methods


<async> __(id, str)

Language translation function.
Parameters:
Name Type Description
id String
str String
Source:
Returns:
Type
String

<async> _c(id, str, args)

Conditional translation function. When invoked it finds the correct string based on the labels specified in ...args.
Parameters:
Name Type Argument Description
id *
str *
args * <repeatable>
Source:
Returns:
Type
String

<async> _r(_str, args)

Replace function. When invoked it will replace %r(number)% with the number matching the index of the arguments passed to the _r function.
Parameters:
Name Type Argument Description
_str String
args * <repeatable>
Source:
Returns:
Type
String

getTranslationMap(lang)

Lazy-load the translation map
Parameters:
Name Type Description
lang String
Source:
Returns:
Type
Promise