Renovation
Search…
.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
1
const response = await renovation.translate
2
.loadTranslations({
3
lang: "ar"
4
});
5
console.log("Translation Object: ", response.data);
Copied!
Classic Promise
1
renovation.translate.loadTranslations({lang: "ar"})
2
.then(response =>
3
console.log("Translation Object: ", response.data);
Copied!
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
1
const response = await renovation.translate
2
.loadTranslations({
3
lang: "ar"
4
});
5
console.log("Translation Object: ", response.data);
Copied!
Classic Promise
1
renovation.translate.loadTranslations({lang: "ar"})
2
.then(response =>
3
console.log("Translation Object: ", response.data);
Copied!

.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

1
const sourceText = renovation.translate
2
.getMessage({
3
txt: "Name",
4
lang: "ar"
5
});
6
console.log("Translation: ", sourceText);
Copied!

.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

1
renovation.translate.setMessageDict({
2
dict: {
3
"Name": "الاسم"
4
},
5
lang: "ar"
6
});
Copied!

.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

1
renovation.translate.extendDictionary({
2
dict: {
3
"Name": "الاسم",
4
"Age": "العمر"
5
},
6
lang: "ar"
7
});
Copied!

.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

1
renovation.translate.setCurrentLanguage({
2
lang: "ar"
3
});
Copied!

.getCurrentLanguage()

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

Output*

string

Example

1
renovation.translate.getCurrentLanguage();
Copied!
Last modified 1yr ago