Language
Expression Extends:
class Language extends aggregate(LanguageModel, Helper)
Helper class representing a Language.
Constructor Summary
Public Constructor | ||
public |
constructor(json: Object, getTranslations: Boolean) Constructor for Language. |
Member Summary
Private Members | ||
private |
|
Method Summary
Public Methods | ||
public |
Synchronizes the language information with the server and sets it to this._translations |
|
public |
Returns the translation for the language based on the 'key'. |
Public Constructors
Public Methods
public getTranslations(): Promise source
Synchronizes the language information with the server and sets it to this._translations
Return:
Promise | Returns a key/value object with the key being the word and value being the translation. |
Example:
const lang = new Language({ iso: 'en' });
lang.getTranslations();
const lang = new Language({ iso: 'en' }, true);
// automatically calls lang.getTranslations();
public translate(key: String): String source
Returns the translation for the language based on the 'key'.
Params:
Name | Type | Attribute | Description |
key | String |
|
The key corresponding to the translation. |
Example:
const lang = new Language({ iso: 'en' }, true);
console.log(lang.translate('welcome_description'));
languageService.getLanguages().then((languages: Language[]) => {
languages[0].getTranslations() // will get translations for the language;
.then(()=>{
console.log(languages[0].translate('welcome_text'));
});
});