babel-plugin-i18next-extract
babel-plugin-i18next-extract copied to clipboard
Ability to extract plurals from defaultValues
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):
- Add plurals manually to the translations file.
- 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.
Just noticed the #167 which asks for the same feature...