问题
i'm creating a multi screen app on android using Flutter.
I'm using intl to localize it, but i don't understand how to procede to create the arb file. Should i run the following commaand
flutter pub pub run intl_translation:extract_to_arb --output-dir=lib\l10n lib\main.dart
command for every "page/activity/fragment" of my app?
回答1:
Are you trying to implement in-app localization? i.e. just changing the app's locale without it being affected by the phone's locale? Then you can refer to this blog: https://blog.geekyants.com/flutter-in-app-localization-438289682f0c
The result would look something like this:
回答2:
Start by generating the strings files: 1. Extract all messages to arb file format, which is the template for translations (you can specify multiple files as input.
> flutter pub pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/first_file.dart lib/second_file.dart
- Generate translation files in arb format for each language in the form intl_messages_.arb
Generate .dart files for the translations (specify one output for each translation):
flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n \ --no-use-deferred-loading lib/first_file.dart lib/second_file.dart lib/l10n/intl_messages_en.arb lib/l10n/intl_messages_.arb
来源:https://stackoverflow.com/questions/51630696/flutter-localization-of-a-multi-screen-app