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

Ability to extract plurals from defaultValues #207

Open
janis-github opened this issue Mar 1, 2022 · 1 comment
Open

Ability to extract plurals from defaultValues #207

janis-github opened this issue Mar 1, 2022 · 1 comment

Comments

@janis-github
Copy link

janis-github commented Mar 1, 2022

Is your feature request related to a problem? Please describe.

Currently this excellent plugin supports only the one basic form of default value: "defaultValue".
i18next supports a buch of suffixes for defaultValue: https://www.i18next.com/translation-function/essentials#overview-options
That would allow to maintain the default locale translations file be 100% generated from the source.

Similar approach could apply to contexts as well.

Describe the solution you'd like

It would be very nice if I could do something like this in code:

t("key", {
  defaultValue_zero: "no data",
  defaultValue_one: "One",
  defaultValue_other: "many",
  count: myCount
})

And it would produce:

{
  key_zero: "no data",
  key_one: "One",
  key_other: "many",
}

Describe alternatives you've considered

Now, there are two options (both suboptimal):

  1. Add plurals manually to the translations file.
  2. Do the pluralization in source.

Additional context

I'd be happy to do PR if someone could guide which parts should be changed.
One thing I found I could do is make parseTCallOptions return the extracted defaults but not sure how to integrate them with the rest of the code.

@janis-github
Copy link
Author

Just noticed the #167 which asks for the same feature...

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

1 participant