Coral.i18n provides localized strings to Coral components.

Coral.i18n API

A Coral I18n service

Static Properties

Coral.i18n.locale {Coral.i18n.locales}

Coral.i18n current locale value.

Coral.i18n.locales {String}

Enum for locale values.

Properties:

Name Type Value Description
en String en-US English (U.S.)
"en-us" String en-US English (U.S.)
cs String cs-CZ Czech (Czechia)
"cs-cz" String cs-CZ Czech (Czechia)
da String da-DK Danish (Denmark)
"da-dk" String da-DK Danish (Denmark)
de String de-DE German (Germany)
"de-de" String de-DE German (Germany)
es String es-ES Spanish (Spain)
"es-es" String es-ES Spanish (Spain)
fi String fi-FI Finnish (Finland)
"fi-fi" String fi-FI Finnish (Finland)
fr String fr-FR French (France)
"fr-fr" String fr-FR French (France)
it String it-IT Italian (Italy)
"it-it" String it-IT Italian (Italy)
ja String ja-JP Japanese (Japan)
"ja-jp" String ja-JP Japanese (Japan)
ko String ko-KR Korean (Korea)
"ko-kr" String ko-KR Korean (Korea)
nb String nb-NO Norwegian Bokmål (Norway)
"nb-no" String nb-NO Norwegian Bokmål (Norway)
nl String nl-NL Dutch (Netherlands)
"nl-nl" String nl-NL Dutch (Netherlands)
pl String pl-PL Polish (Poland)
"pl-pl" String pl-PL Polish (Poland)
pt String pt-BR Portuguese (Brazil)
"pt-br" String pt-BR Portuguese (Brazil)
ru String ru-RU Russian (Russia)
"ru-ru" String ru-RU Russian (Russia)
sv String sv-SE Swedish (Sweden)
"sv-se" String sv-SE Swedish (Sweden)
tr String tr-TR Turkish (Turkey)
"tr-tr" String tr-TR Turkish (Turkey)
"zh-cn" String zh-CN Simplified Chinese
"zh-hans-cn" String zh-CN Simplified Chinese
"zh-hans" String zh-CN Simplified Chinese
"zh-tw" String zh-TW Traditional Chinese
"zh-hant-tw" String zh-TW Traditional Chinese
"zh-hant" String zh-TW Traditional Chinese

Methods

Coral.i18n.get

Gets a localized string, using arguments, and translation hint.
Parameters:
Name Type Description
key String the key of the string to retrieve
args String one more arguments
translation_hint String context information for translators
Returns:
the localized string with arguments {String}
Example
Coral.i18n.get('English string: {0}', 10, 'Translation hint 1'); // => 'Translated string 1: 10')
Coral.i18n.get('English string: {0}', 10, 'Translation hint 2'); // => 'Translated string 2: 10')
Coral.i18n.get('English string: {0}, {1}, and {2}', 10, 20, 30, 'Translation hint 1'); // => 'Translated string 1: 30, 10, and 20'
Coral.i18n.get('English string: {0}, {1}, and {2}', 10, 20, 30, 'Translation hint 2'); // => 'Translated string 2: 30, 10, and 20'

Coral.i18n.get

Gets a localized string, using translation hint.
Parameters:
Name Type Description
key String the key of the string to retrieve
translation_hint String context information for translators
Returns:
the localized string {String}
Example
Coral.i18n.get('English string', 'Translation hint 1'); // => 'Translated string 1'
Coral.i18n.get('English string', 'Translation hint 2'); // => 'Translated string 2'

Coral.i18n.get

Gets a localized string, using named arguments.
Parameters:
Name Type Description
key String the key of the string to retrieve
args Object one more named arguments
Returns:
the localized string with arguments {String}
Example
Coral.i18n.get('English string: {name}', { name: 'foo' }); // => 'Translated string: foo'
Coral.i18n.get('English string: {name1}, {name2}, and {name3}', { name1: 'foo', name2: 'bar', name3: 'qux' }); // => 'Translated string: qux, foo, and bar'

Coral.i18n.get

Gets a localized string, using arguments.
Parameters:
Name Type Description
key String the key of the string to retrieve
args String one more arguments
Returns:
the localized string with arguments {String}
Example
Coral.i18n.get('English string: {0}', 10); // => 'Translated string: 10'
Coral.i18n.get('English string: {0}, {1}, and {2}', 10, 20, 30); // => 'Translated string: 30, 10, and 20'

Coral.i18n.get

Gets a localized string.
Parameters:
Name Type Description
key String the key of the string to retrieve
Returns:
the localized string {String}
Example
Coral.i18n.get('English string'); // => 'Translated String'

Coral.i18n.get

Gets a localized string, using named arguments, and translation hint.
Parameters:
Name Type Description
key String the key of the string to retrieve
args Object one more named arguments
translation_hint String context information for translators
Returns:
the localized string with arguments {String}
Example
Coral.i18n.get('English string: {name}', { name: 'foo' }, 'Translation hint 1'); // => 'Translated string 1: foo'
Coral.i18n.get('English string: {name}', { name: 'foo' }, 'Translation hint 2'); // => 'Translated string 2: foo'
Coral.i18n.get('English string: {name1}, {name2}, and {name3}', { name1: 'foo', name2: 'bar', name3: 'qux' }, 'Translation hint 1'); // => 'Translated string 1: qux, foo, and bar'
Coral.i18n.get('English string: {name1}, {name2}, and {name3}', { name1: 'foo', name2: 'bar', name3: 'qux' }, 'Translation hint 2'); // => 'Translated string 2: qux, foo, and bar'

Coral.i18n.set

Sets multiple localized strings, using translation hints.
Parameters:
Name Type Description
map Array.<String, String, String> a key-value object map to add to the strings dictionary.
Example
Coral.i18n.set([
      ['English string', 'Translated string 1', 'Translation hint 1'],
      ['English string', 'Translated string 2', 'Translation hint 2'],
      ['English string with {0} items', 'Translated string 1 with {0} items', 'Translation hint 1'],
      ['English string with {0} items', 'Translated string 2 with {0} items', 'Translation hint 2'],
      ['English string with {0}, {1} and {2} items', 'Translated string 1 with {0}, {1} and {2} items', 'Translation hint 1'],
      ['English string with {0}, {1} and {2} items', 'Translated string 2 with {0}, {1} and {2} items', 'Translation hint 2'],
      ['English string: {name}', 'Translated string 1: {name}', 'Translation hint 1'],
      ['English string: {name}', 'Translated string 2: {name}', 'Translation hint 2'],
      ['English string: {name1}, {name2}, and {name3}', 'Translated string 1: {name3}, {name1}, and {name2}', 'Translation hint 1'],
      ['English string: {name1}, {name2}, and {name3}', 'Translated string 2: {name3}, {name1}, and {name2}', 'Translation hint 2']
    ]);

Coral.i18n.set

Sets a localized string, using translation hint.
Parameters:
Name Type Description
key String the key to set
value String the value associated with the given key.
translation_hint String the translation hint associated with the given key.
Example
Coral.i18n.set('English string', 'Translated string 1', 'Translation hint 1');
Coral.i18n.set('English string', 'Translated string 2', 'Translation hint 2');
Coral.i18n.set('English string with {0} items' , 'Translated string 1 with {0} items', 'Translation hint 1');
Coral.i18n.set('English string with {0} items' , 'Translated string 2 with {0} items', 'Translation hint 2');
Coral.i18n.set('English string: {0}, {1}, and {2}', 'Translated string 1: {2}, {0}, and {1}', 'Translation hint 1');
Coral.i18n.set('English string: {0}, {1}, and {2}', 'Translated string 2: {2}, {0}, and {1}', 'Translation hint 2');
Coral.i18n.set('English string: {name}', 'Translated string 1: {name}', 'Translation hint 1');
Coral.i18n.set('English string: {name}', 'Translated string 2: {name}', 'Translation hint 2');
Coral.i18n.set('English string: {name1}, {name2}, and {name3}', 'Translated string 1: {name3}, {name1}, and {name2}', 'Translation hint 1');
Coral.i18n.set('English string: {name1}, {name2}, and {name3}', 'Translated string 2: {name3}, {name1}, and {name2}', 'Translation hint 2');

Coral.i18n.set

Sets multiple localized strings.
Parameters:
Name Type Description
map Array.<String, String> a key-value map to add to the strings dictionary.
Example
Coral.i18n.set([
      ['English string 1', 'Translated string 1'],
      ['English string 2', 'Translated string 2'],
      ['English string 1 with {0} items','Translated string 1 with {0} items'],
      ['English string 2 with {0} items','Translated string 2 with {0} items'],
      ['English string 1: {0}, {1}, and {2}','Translated string 1: {2}, {0}, and {1}'],
      ['English string 2: {0}, {1}, and {2}','Translated string 2: {2}, {0}, and {1}'],
      ['English string 1: {name}', 'Translated string 1: {name}'],
      ['English string 2: {name}', 'Translated string 2: {name}'],
      ['English string 1: {name1}, {name2}, and {name3}', 'Translated string 1: {name3}, {name1}, and {name2}'],
      ['English string 2: {name1}, {name2}, and {name3}', 'Translated string 2: {name3}, {name1}, and {name2}']
    ]);

Coral.i18n.set

Sets a localized string.
Parameters:
Name Type Description
key String the key to set
value String the value associated with the given key.
Example
Coral.i18n.set('English string', 'Translated string');
Coral.i18n.set('English string: {0}', 'Translated string: {0}');
Coral.i18n.set('English string: {0}, {1}, and {2}', 'Translated string: {2}, {0}, and {1}');
Coral.i18n.set('English string: {name}', 'Translated string: {name}');
Coral.i18n.set('English string: {name1}, {name2}, and {name3}', 'Translated string: {name3}, {name1}, and {name2}');