It is recommended for better support of types by code assistance in IDEs to usegetFrappeTranslationController()
in order to get the instance of FrappeTranslationController
instead of renovation.translate
which is TranslationController
if the backend is Frappè, for instance. In this guide we will use Frappé as an example and use getFrappeTranslationController()
Returns the translations of the selected language from the backend of Frappe.
property | type | required | description |
lang | String | no | Langue translation to be returned from the backend, default “en” for english |
RequestResponse<Map<String,String>>
RequestResponse<Map<String,String>> translate =await getFrappeTranslationController().loadTranslations(lang: "ar");if (translate.isSuccess) {print("TEST in arabic : ${translate.data['TEST']}");} else {print(translate.error);}
Gets the translation of a text specified by language (optionally) or the current set language.
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
String sourceText = getFrappeTranslationController().getMessage(txt: "Name",lang: "ar");print("Translation: $sourceText");
Sets the translation dictionary replacing the existing one, if any, for a specific language.
property | type | required | description |
dict | Map<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
getFrappeTranslationController().setMessageDict(dict: {"Name": "الاسم"},lang: "ar");
Appends the translation dictionary replacing the existing keys (source texts), if any, for a specific language.
property | type | required | description |
dict | Map<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
getFrappeTranslationController().extendDictionary(dict: {"Name": "الاسم","Age": "العمر"},lang: "ar");
Sets the current language (locally only) of the current user, Defaults to 'en'
property | type | required | description |
lang | String | yes | The language to set for the current user. |
void
getFrappeTranslationController().setCurrentLanguage("ar" // lang);
Gets the current language (locally only) of the current user.
String
String currentLang = getFrappeTranslationController().getCurrentLanguage();
Removes all translations saved in messages dictionary.
void
getFrappeTranslationController().clearCache();