Problems with the Dart Intl library for translations
I am having problems setting up translation features for localization in a Dart app. I currently have 1 class called basics.dart and all the classes have access to its functionality. Here is the function I want to translate:
basics.dart
String loadingMessage() {
return Intl.message(
"Tickets are currently loading",
name: "loadingMessage",
args: [],
desc: "Tickets are currently loading");
}
ticket_list.dart
_p.text = loadingMessage();//'Currently loading the tickets';
This returns the message in English correctly. Now how do I set it up so I can get a French translation?
+3
source to share
1 answer
See the doc of the intl package .
Basically you need to extract messages for translation with:
pub run intl:extract_to_arb --output-dir=target/directory
my_program.dart more_of_my_program.dart
Then translate the arb files and finally generate the .dart file for the translated posts with:
pub run intl:generate_from_arb --generated_file_prefix=<prefix>
<my_dart_files> <translated_ARB_files>
+2
source to share