'GetX Translate long Map
I use getx translate like the example:
return GetMaterialApp(
translations: Messages(),
locale: Get.deviceLocale,
fallbackLocale: const Locale('pt','BR'),
(...)
class Messages extends Translations { @override Map<String, Map<String, String>> get keys => {
"pt": {
"titulo": "Ernesto Berg",
"subtitulo":"Habilidades Profissonais",
(...)
The problem is that my Messages class has a lot of information, and on some devices, when opening, the Messages is not read in time and text is not shown. Example printscreen below.
Any suggestion to do this work? I think in doing a wait or using compute()
but I was not successful!
I will appreciate your suggestions.
Solution 1:[1]
first make a class of locales like this
`import 'package:get/get.dart';
class LocalStrings extends Translations {
@override
Map<String, Map<String, String>> get keys => {
'en_US': {
'Send': 'Send',
'Choose your language': 'Choose your language',
},
'ar_001': {
'Send': '?????',
'Choose your language': '???? ????',
},
};
}`
After this you have to set your locale in main.dart under GetMaterialApp. Make sure you are using GetX for that. locale: Locale('ar_001'),After this just write the same text you wrote in locale file and add tr after that "Welcome Back To".tr, This will set your language based on your locale in main.dart file
If you want to change language just do var locale = Locale('ar_001'); Get.updateLocale(locale);this. This will update language
everywhere
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Usama majid |
