Hello,
I notices that tin the fnando/i18n-js doc there is an easy way to pluralize the words by doing
Car: {
counting:{
one: 'Car',
other: 'Cars'
}}
and call it with i18n.t('Car', {count: 10}} which should here return Cars
When I define my translations like that I have an error saying that my key, value translation schema is wrong, and that I can't define an object of translations.
So I'm probably not defining my translations schema as I should, and I can't find any example with a JSON formatted translation file. Any idea ?
Here are screen shot of the error/warning


@ansmonjol You need to enclose your keys by double quotes. Try something like this instead:
"Car": {
"one": "Car",
"other": "Cars"
}
and call it like this: i18n.t('Car', {count: 10})
I'll try thanks !
I close the issue for now and will reopen if something went wrong
For future explorers:
You have to use the the variable name 'count' for it to be pluralized, otherwise you will get a RSOD similar to the above.
Hi @ansmonjol
Can you help me getting pluralization to work?
I have a localization file that looks something like this:
.init({
fallbackLng: 'en',
lng: "en",
resources: {
en: {
common: {
frequency: {
interval: {
one: "Every day",
other: "Every {{count}}. day",
zero: "Never",
},
},
},
},
},
})
And I use it like this in my component:
let intervalString = i18n.t("frequency.interval", {count: myCount})
I tried the other solutions mentioned here, but I can't get it to work :(
PS: I tried using double quotes as suggested by @skyplor, but it didn't do the job for me. According to this example is it also not the correct syntax for i18n-next, I guess?!
@nabati Thank you, sir. Saved my day!
@nabati Was looking for this everywhere. Thanks!
Should we consider adding to documentation?
Most helpful comment
For future explorers:
You have to use the the variable name 'count' for it to be pluralized, otherwise you will get a RSOD similar to the above.