Constructs a new Translatable.
- Version:
- 16.3.1
- Source:
- See:
Members
Methods
bind(varArgsopt) → {string}
stable API
Binds to a value for the current key and returns it. If a translation key is missing, returns the empty string. Accepts an optional list of message parameters.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
varArgs |
string | Translatable |
<optional> |
[] | optional parameters to be inserted into the translated message |
- Version:
- 16.3.1
- Source:
Returns:
the language-dependent value of this Translatable
- Type
- string
Examples
// If the i18n key greeting.header.name stores the value 'My Hello World ABCS App!'
Translatable translatable = new Translatable('greeting.header.name');
var value = translatable.bind();
// value is now 'My Hello World ABCS App!'
// If the i18n key greeting.header.name stores the value 'My {0} {1} ABCS App!'
Translatable translatable = new Translatable('greeting.header.name');
var value = translatable.bind('Hello', 'World');
// value is now 'My Hello World ABCS App!'
// If the i18n key greeting.header.name stores the value 'My {greeting} {who} ABCS App!'
Translatable translatable = new Translatable('greeting.header.name');
var value = translatable.bind({greeting: 'Hello', who: 'World'});
// value is now 'My Hello World ABCS App!'
toString() → {String}
stable API
Binds to the translated value for the current key. Overriding this method ensures that in String contexts, the translatable is rendered as a String.
In cases where there are no run-time paramaters, this method is no different that calling Translatable.bind() directly. If there are run-time parameters, Translatable.bind() must be used instead.
- Version:
- 16.3.1
- Source:
Returns:
the translated value of this translatable
- Type
- String