Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments lines to the translation json file #543

Closed
giogithub89 opened this issue Jan 4, 2023 · 1 comment
Closed

Add comments lines to the translation json file #543

giogithub89 opened this issue Jan 4, 2023 · 1 comment

Comments

@giogithub89
Copy link

Hey, I know that json file does not allows to add comments, but is there a way to do it for Easy localization? Most of the time the translation files are too big and difficult to read. I would like to add comments lines in order to separate the translation file based on my flutter screens. Thanks

Example:
//screen 1 {"settings": "Settings"} //screen 2 {"welcome": "Benvenuto"}

@dJani97
Copy link

dJani97 commented Jan 14, 2023

JSON as a standard does not support comments, so supporting this would:

  • require them to come up with a whole new parser instead of using a built-in one
  • make the json files unreadable by external services, libraries, IDEs, etc.

But easy_localization can read multiple formats, including .xml or .yaml, all of which support comments.

Alternatively, this library supports nesting, so you could refactor your code this way:

{
  "screen1":{
    "settings":"Settings"
  },
  "screen2":{
    "welcome":"Benvenuto"
  }
}

And then access these keys in your code like so: "screen2.welcome".tr()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants