esskar / vscode-flutter-i18n-json

VS Code extension to create a binding between your translations from .json files and your Flutter app.
92 stars 21 forks source link

Locale class not generated when using arrays #58

Open Flomp opened 4 years ago

Flomp commented 4 years ago

Upon generation the private locale class of the second locale is not generated in i18n.dart if you have two locales that have an array with the same key.

Steps to reproduce:

  1. Call Flutter I18n Json: initialize in a fresh flutter project
  2. Add an array to your generated ${first_locale}.json:
    "sampleArray": [
        "1", "2", "3"
    ]
  3. Call Flutter I18n Json: Add locale and generate a second locale different from your first one
  4. Add an array with the same key to your ${second_locale}.json:
    "sampleArray": [
        "4", "5", "6"
    ]
  5. Run Flutter I18n Json: Update
  6. The i18n.dart file now shows two errors as the private class _I18n_${second_locale} was not generated
buzushkin commented 4 years ago

I have the same problem. Work around I found is to hardcode it into the i18n.dart file, though it requires me to do that after every update (including removing and pasting back the text in the language file) - at least until it is fixed by the developer. But it works.

gnudles commented 3 years ago

I wrote an alternative dart code generator in dart in order to fix the same issue with the arrays. you can find it at https://github.com/gnudles/dart_i18n_generator add it to dev dependencies in pubspec.yaml and generate i18n.dart by running the command flutter pub run i18n_json:i18n_json