Methods
(async, abstract) loadTranslations()
Load translations from source.
Returns:
The possible async process promise.
- Type
- Promise | void
(abstract) translate(string, replacementsopt, countopt)
Translate a string for the current locale.
If replacement array is given, replace %s by the given replacement in order of appearance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string | The string to translate. | |
replacements |
object.<string, string> |
<optional> |
The token replacements. |
count |
number |
<optional> |
The string count for pluralization. |
Returns:
The translated string.
- Type
- string
(abstract) addTranslation(key, value, locale)
Add translation key and value for given locale or current locale.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | The translation key. |
value |
string | The translation value. |
locale |
string | null | The locale the translation should be used for. |
Returns:
The current driver instance.
(abstract) addTranslations(translations)
Add translations from key-value pair object.
Example
driver.addTranslations({
foo: {
bar: {
en: 'baz',
fr: 'qux'
}
}
});
Parameters:
Name | Type | Description |
---|---|---|
translations |
string | The translations. |
Returns:
The current driver instance.
(abstract) setLocale(locale)
Set locale to use for translation.
Parameters:
Name | Type | Description |
---|---|---|
locale |
string | The locale. |
Returns:
The current driver instance.
(abstract) setFallbackLocale(locale)
Set fallback locale.
Parameters:
Name | Type | Description |
---|---|---|
locale |
string | The fallback locale. |
Returns:
The current driver instance.