Reference Source
public class | source

I18nProvider

I18n service to get/set localized strings.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Member Summary

Public Members
public

I18n current locale value.

Method Summary

Public Methods
public

get(key: String): String

Gets a localized string.

public

set(map: Array<String, String, String>): *

Sets multiple localized strings, using translation hints.

Public Constructors

public constructor(options: Object) source

Params:

NameTypeAttributeDescription
options Object
  • optional

Options for this combo handler.

options.locale String
  • optional

The locale property defines the locale of the I18nProvider.

Public Members

public locale: String source

I18n current locale value. See I18nLocalesEnum.

Public Methods

public get(key: String): String source

Gets a localized string.

Params:

NameTypeAttributeDescription
key String

the key of the string to retrieve

Return:

String

the localized string

Example:

Coral.i18n.get('English string'); // => 'Translated String'

public set(map: Array<String, String, String>): * source

Sets multiple localized strings, using translation hints.

Params:

NameTypeAttributeDescription
map Array<String, String, String>

A key-value object map to add to the strings dictionary.

Return:

*

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']
]);