Controller handling the translations and setting the language
Loads the translations and sets the local dictionary for the chosen language.
LoadTranslationParams
property | type | required | description |
lang | string | yes | The selected language to load the translations for. |
{ [x: string]: string }
async-await
const response = await renovation.translate.loadTranslations({lang: "ar"});console.log("Translation Object: ", response.data);
Classic Promise
renovation.translate.loadTranslations({lang: "ar"}).then(response =>console.log("Translation Object: ", response.data);
Loads the translations and sets the local dictionary for the chosen language.
LoadTranslationParams
property | type | required | description |
lang | string | yes | The selected language to load the translations for. |
{ [x: string]: string }
async-await
const response = await renovation.translate.loadTranslations({lang: "ar"});console.log("Translation Object: ", response.data);
Classic Promise
renovation.translate.loadTranslations({lang: "ar"}).then(response =>console.log("Translation Object: ", response.data);
Gets the translation of a text specified by language (optionally) or the current set language.
GetMessageParams
property | type | required | description |
txt | string | yes | The source text to get the translation for. |
lang | string | no | The target language to load the translations for. Defaults to the current set language of the user. |
string
const sourceText = renovation.translate.getMessage({txt: "Name",lang: "ar"});console.log("Translation: ", sourceText);
Sets the translation dictionary replacing the existing one, if any, for a specific language.
SetMessageDictParams
property | type | required | description |
dict | {[x: string]: string} | yes | The dictionary that will be set for the language. |
lang | string | no | The target language to set the translations dictionary for. Defaults to the current set language of the user. |
void
renovation.translate.setMessageDict({dict: {"Name": "الاسم"},lang: "ar"});
Appends the translation dictionary replacing the existing keys (source texts), if any, for a specific language.
ExtendDictParams
property | type | required | description |
dict | {[x: string]: string} | yes | The dictionary that will be appended for the language. |
lang | string | no | The target language to extend the translations dictionary for. Defaults to the current set language of the user. |
void
renovation.translate.extendDictionary({dict: {"Name": "الاسم","Age": "العمر"},lang: "ar"});
Sets the current language (locally only) of the current user.
SetCurrentLanguageParams
property | type | required | description |
lang | string | no | The language to set for the current user. |
void
renovation.translate.setCurrentLanguage({lang: "ar"});
Gets the current language (locally only) of the current user.
string
renovation.translate.getCurrentLanguage();