i18next: Doesn't work singular/plural forms with a few counts
đ Bug Report
I use Trans tag. And I use nesting to create the translations string from few other. So I have to use a few different âcountâ for every key. I canât use a few counts, because Trans doesnât have such options. So I use âvaluesâ. And in this case count works fine, context works fine⌠but â_pluralâ doesnât work.
To Reproduce
Here is code from the page:
<Trans
debug={true}
i18nKey="billedAfterTrial"
values={{
currencySign: currencySign,
currentPrice: currentPrice,
count1: periodType.count,
count2: trialType.count,
count3: day,
context1: periodType.context,
context2: trialType.context,
context3: month,
}}
>
[$79.99] billed [yearly] after a [7-day] trial period. Contact us via
support@dailyfit.io to cancel.
</Trans>
Here is the translation keys:
"X period": "{{count}} week",
"X period_plural": "{{count}} weeks",
"X period_month": "{{count}} month",
"X period_month_plural": "{{count}} months",
"X period_0": "{{count}} week",
"X period_1": "{{count}} week",
"X period_2": "{{count}} week",
"X period_month_0": "{{count}} month",
"X period_month_1": "{{count}} month",
"X period_month_2": "{{count}} month",
"X-period": "{{count}}-week",
"X-period_month": "{{count}}-month",
"billedAfterTrial": "{{currencySign}}{{currentPrice}} billed every $t(X period, {\"count\": \"{{count1}}\", \"context\": \"{{ context1 }}\" }) after the $t(X-period, {\"count\": \"{{count2}}\", \"context\": \"{{ context2 }}\" }) trial period."
I changed âsâ in the â_0, _1, _2â (we use it for Russian), but it doesnât work to. Also, I changed â_pluralâ to â_otherâ. And nothing works.
Expected behavior
I expect that if count1 will be 3, Iâll get âbilled every 3 monthsâ. I get âbilled every 3 monthâ
// Paste the expected results here
Your Environment
- i18next version: i.e. 19.9.2
- os: Mac
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 56 (27 by maintainers)
means (if plural):
en -> _one, _other (depending on singular or not) zh -> _other (for all)
@haoolii zh (chinese) does not differenciate singular or plural forms there is just one form so there is only the _other suffix https://en.wikipedia.org/wiki/Chinese_grammar#:~:text=Chinese nouns and other parts,"I%2C me").
zh has only 1 suffix, and thatâs the _other suffix: https://jsfiddle.net/6bpxsgd4
ahh i misunderstood, sorry⌠thatâs because youâre still using quotes for numbers: instead of
{\"count\": \"{{count2}}\"
you should do{\"count\": {{count2}}
https://codesandbox.io/s/react-i18next-example-forked-vz5e8?file=/src/i18n.js:2409-2431
I see⌠thanks. I will try to implement it