'Internationalization Flutter by intl

I've learned flutter. I built an internationalized app using the intl dependency (follow this)

  1. I run 1st command well (no error message):
flutter packages pub run intl_translation:extract_to_arb --output-dir=lib/l10n lib/main.dart

3 files were generated:

enter image description here

  1. I need to create intl_{locale}.arb file before run next command.

  2. 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 ?



Solution 1:[1]

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": {}
  }
}

Solution 2:[2]

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

Solution 3:[3]

Between the steps you mentioned 1. and 2. you should copy the new strings to intl*.arb.

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 Gabriela Dias de Souza
Solution 2 Durdu
Solution 3 Durdu