localizely / flutter-intl-vscode

This VS Code extension generates boilerplate code for localization of Flutter apps with official Dart Intl library
MIT License
87 stars 1 forks source link

Not generate when key is "continue" #91

Closed pro100andrey closed 2 years ago

pro100andrey commented 2 years ago

For example: File name is intl_en.arb

{
  "continue": "Продолжить"
}

VSCode output:

INFO: Generating localization files for the 'core' project...
INFO: Failed to format 'l10n.dart' file.
Error in parsing /Users/.../packages/core/lib/generated/l10n.dart, no messages extracted.
ERROR: Failed to generate localization files.
Invalid argument(s): Parsing errors in /Users/...packages/core/lib/generated/l10n.dart
pub finished with exit code 2
exit code 2

For example: if change the key 'continue' into 'goOn'

{
    "goOn": "Продолжить"
}

all works!

lzoran commented 2 years ago

Hi @pro100andrey,

The continue is a reserved keyword in Dart, and as such, it can't be used as an identifier. The same applies to other reserved keywords like for, break, return, and similar.

You can find more info here.

Maybe renaming (e.g. goOn) or adding a prefix (e.g. commonContinue) to the string key would be the right way to go.

pro100andrey commented 2 years ago

@lzoran Thanks for your answer.

In my opinion, flutter-intl-vscode documentation should contain a paragraph about keywords, because this is unpredictable for users.

Thanks!