Skip to content
New issue

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

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

Already on GitHub? # to your account

Keep the nested structure when the LocaleKeys are generated #390

Open
ValentinVignal opened this issue Jun 15, 2021 · 7 comments · Fixed by #418
Open

Keep the nested structure when the LocaleKeys are generated #390

ValentinVignal opened this issue Jun 15, 2021 · 7 comments · Fixed by #418
Labels
enhancement New feature or request

Comments

@ValentinVignal
Copy link

Let's say I have this en.json file:

{
  "project": {
    "name" : "project name",
    "date": "project date"
  },
  "user": {
    "name": "user name",
    "age": "age",
  }
}

Right now, running flutter pub run easy_localization:generate -f keys -o locale_keys.g.dart to generate the keys will flatten the nested structure and generate:

LocaleKeys.project_name;
LocaleKeys.project_date;
LocaleKeys.user_name;
LocaleKeys.user_age;

It would be nice if it could keep the nested structure and generate nested objects:

LocaleKeys.project.name;
LocaleKeys.project.date;
LocaleKeys.user.name;
LocaleKeys.user.age;
@ValentinVignal
Copy link
Author

Hello @aissat, is it an acceptable proposition?
I'm willing to spend some time and contribute to make it available if you validate this request.

@Overman775
Copy link
Collaborator

@ValentinVignal i think it's god idea. PR welcom 😉

@Overman775 Overman775 added the enhancement New feature or request label Jul 25, 2021
@TarekkMA
Copy link

@ValentinVignal are you working on this? If not I can give it a try.

@ValentinVignal
Copy link
Author

@TarekkMA Not yet, I have been quite busy recently.

@Overman775 right now LocalKeys.project_name and the other are all const. Would It be okay to not make the nested object const:

LocalKeys.project.name;

would not be a const anymore, is that fine?

@TarekkMA
Copy link

@ValentinVignal take a look at my PR #418, I've managed to make nested objects private and const.

Your feedback is most appreciated.

@btd1337
Copy link

btd1337 commented Dec 16, 2021

This idea is very useful!

@opanitch
Copy link

opanitch commented Aug 3, 2023

any idea if this will be merged into the project anytime soon?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants