I've learned flutter. I built an internationalized app using the intl dependency (follow this)
flutter packages pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/main.dart
3 files were generated:
I need to create intl_{locale}.arb file before run next command.
Next command:
flutter packages pub run intl_translation:generate_from_arb
--output-dir=lib/l10n --no-use-deferred-loading
lib/main.dart lib/l10n/intl_*.arb
It always returns a message although the corresponding message (messages_en.dart) file is generated:
No @@locale or _locale field found in intl_en, assuming 'en' based on the file name.
No @@locale or _locale field found in intl_messages, assuming 'messages' based on the file name.
How can I run the 2nd command without the messages, because I think they are unexpected messages ?
You should write in each file the following. Then flutter will automatically identify the language.
{
"@@locale": "en",
"title": "Flutter Example App",
"@title": {
"type": "text",
"placeholders": {}
}
}
1.
flutter packages pub run intl_translation:generate_from_arb \ --output-dir=lib/l10n --no-use-deferred-loading \ lib/main.dart lib/l10n/intl_*.arb
should be changed to:
flutter pub pub run intl_translation:extract_to_arb --output-dir=lib/l10n ****lib/DemoLocalizations.dart****
(where ****lib/DemoLocalizations.dart**** should be update to the file where you created this file from the steps you created.
2.
you will have the strings generated. these need to copied to intl*.arb
3.
then you should run:
flutter pub pub run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading ****lib/DemoLocalizations.dart**** lib/l10n/intl_*.arb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With