.translate

Controller handling the translations and setting the language

.loadTranslations() ★

Loads the translations and sets the local dictionary for the chosen language.

Input

LoadTranslationParams

property

type

required

description

lang

string

yes

The selected language to load the translations for.

Output

{ [x: string]: string }

Example

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.

Input

LoadTranslationParams

property

type

required

description

lang

string

yes

The selected language to load the translations for.

Output

{ [x: string]: string }

Example

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

.getMessage()

Gets the translation of a text specified by language (optionally) or the current set language.

Input

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.

Output*

string

Example

const sourceText = renovation.translate
.getMessage({
txt: "Name",
lang: "ar"
});
console.log("Translation: ", sourceText);

.setMessagesDict()

Sets the translation dictionary replacing the existing one, if any, for a specific language.

Input

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.

Output*

void

Example

renovation.translate.setMessageDict({
dict: {
"Name": "الاسم"
},
lang: "ar"
});

.extendDictionary()

Appends the translation dictionary replacing the existing keys (source texts), if any, for a specific language.

Input

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.

Output*

void

Example

renovation.translate.extendDictionary({
dict: {
"Name": "الاسم",
"Age": "العمر"
},
lang: "ar"
});

.setCurrentLanguage()

Sets the current language (locally only) of the current user.

Input

SetCurrentLanguageParams

property

type

required

description

lang

string

no

The language to set for the current user.

Output*

void

Example

renovation.translate.setCurrentLanguage({
lang: "ar"
});

.getCurrentLanguage()

Gets the current language (locally only) of the current user.

Output*

string

Example

renovation.translate.getCurrentLanguage();