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) 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 downloadet yet, this will make sure the string is replaced when it is actually loaded. So for easy translations passing the jQuery object to apply it to is more save, especially when they are loaded in the beginning.
Parameters:
Name Type Attributes Description
$element jQuery optional
messageId string
args * <repeatable>
one or multiple parameters injected into placeholders
Source:
Returns:
Type
string