i18next / i18next-parser

Parse your code to extract translation keys/values and manage your catalog files
MIT License
488 stars 199 forks source link

defaultValue_plural value is ignored and doesn't get parsed to be the plural form of default value in t function #795

Open crazyyi opened 1 year ago

crazyyi commented 1 year ago

🐛 Bug Report

The plural form of the default value is not parsed correctly using defaultValue_plural. This seems to be the correct keyword according to i18next's doc, but it always falls back to the default singular value no matter what value I change it to. In order to parse the defaultValue plural forms correctly, I have to add another property called defaultValue_other, which does the same thing as the defaultValue_plural is supposed to do. And it works. I am not sure what other value I can change the property to but this is not documented anywhere.

To Reproduce

A minimal reproducible example. In this sample project, I have provided both the successful examples and the failed examples. Every time I modify the keys or i18next tags I use yarn lang:extract to parse the keys and translations with gulp in i18next-parser

Expected behavior

I expected the defaultValue_plural property will produce a correct plural form for the default value. like the first two. But I got results like the last two when using defaultValue_plural with i18next-parser.

JSON output:

"itemCount_one": "{{ count }} unit",
"itemCount_other": "{{ count }} units", // this only works with property "defaultValue_other"
"itemFailedCount_one": " You can see this is not working using defaultValue_plural: {{ count }} unit",
"itemFailedCount_other": " You can see this is not working using defaultValue_plural: {{ count }} unit"

Your Environment