Class: I18n

I18n()

new I18n()

internationalization module
Source:

Members

(private, static) language

built in language
Properties:
Type Description
string | null
Source:

(private, static, readonly) languageLoadedEvent

const for string of loaded language
Properties:
Type Description
string
Source:

(private, static, readonly) supportedLanguages

supported languages, minus the built in 'en'
Properties:
Type Description
Array.<string>
Source:

(private, static) translations :Object

translation cache
Type:
  • Object
Source:

Methods

(static) _($element, messageId, …args) → {string}

translate a string, alias for I18n.translate
Parameters:
Name Type Attributes Description
$element jQuery optional
messageId string
args * <repeatable>
one or multiple parameters injected into placeholders
Source:
Returns:
Type
string

(static) getLanguage() → {string}

get currently loaded language
Source:
Returns:
Type
string

(static) getPluralForm(n) → {int}

per language functions to use to determine the plural form
Parameters:
Name Type Description
n int
Source:
See:
Returns:
array key
Type
int

(static) loadTranslations()

load translations into cache
Source:

(static) reset()

resets state, used for unit testing
Source:

(static) translate($element, messageId, …args) → {string}

translate a string Optionally pass a jQuery element as the first parameter, to automatically let the text of this element be replaced. In case the (asynchronously loaded) language is not downloaded yet, this will make sure the string is replaced when it eventually gets loaded. Using this is both simpler and more secure, as it avoids potential XSS when inserting text. The next parameter is the message ID, matching the ones found in the translation files under the i18n directory. Any additional parameters will get inserted into the message ID in place of %s (strings) or %d (digits), applying the appropriate plural in case of digits. See also Helper.sprintf().
Parameters:
Name Type Attributes Description
$element jQuery optional
messageId string
args * <repeatable>
one or multiple parameters injected into placeholders
Source:
Returns:
Type
string