Plurals half-working for 1 langauge and entirely working for another
See original GitHub issueDescribe the bug
I have 2 languages, Croatian and English, on the English side all plurals are working as expected, on the Croatian side, half of the translations work (even when the same key is used!)
Occurs in next-i18next version
“next-i18next”: “^10.2.0”,
Code used
const { t } = useTranslation("campaigns");
const options = [
{ count: 0, duration: "day" },
{ count: 1, duration: "week" },
{ count: 2, duration: "week" }, // this doesn't work in croatian
{ count: 3, duration: "week" }, // nor this
{ count: 1, duration: "month" },
{ count: 3, duration: "month" }, // nor this
{ count: 6, duration: "month" },
];
<select>
{options.map((it) => (
<option
key={it.count + it.duration}
label={t(
"common:fields.items." + it.duration, //duration is month/week/day
{ count: it.count },
)}
value={it.count + " " + it.duration}
className="w-full py-2"
></option>
))}
</select>
And my translations are as follows
//hr/common.json
"items": {
"day_one": "{{count}} dan",
"day_other": "{{count}} dana",
"month_one": "{{count}} mjesec",
"month_other": "{{count}} mjeseci",
"week_other": "{{count}} tjedna",
"week_one": "{{count}} tjedan"
},
//en/common.json
"items": {
"day_one": "{{count}} day",
"day_other": "{{count}} days",
"month_one": "{{count}} month",
"month_other": "{{count}} months",
"week_other": "{{count}} weeks",
"week_one": "{{count}} week"
},
Screenshots
Here are the two translations
OS (please complete the following information)
- Device: Ubuntu 20.04
- Browser: Chromium Version 100.0.4896.127 (Official Build) snap (64-bit)
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Learn the Rules of Plural Nouns
A plural noun indicates that there is more than one of a person, place, thing, or idea. Many plural nouns are created by...
Read more >Plurals ending in - Knudge.me
Plural forms for most nouns are formed by adding -s or -es. However, some nouns that end in -us have plural forms ending...
Read more >Irregular Plural Nouns | Guide to Writing - Lumen Learning
Irregular plurals, unlike regular plurals, don't necessarily follow any particular pattern—instead, they follow a lot of different patterns.
Read more >9 confusing ways to pluralize words - The Week
1. Add a suffix. This is what we normally do in English with –s and –es, and what many other languages do with...
Read more >Plural Rules - Unicode CLDR
Languages vary in how they handle plurals of nouns or unit expressions ("hour" vs "hours", and so on). Some languages have two forms,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue was with the language itself, basically Croatian has 2 plural forms.
There is both
_few
and_other
forms, there is a specification for this but I dont remember the link, more languages have their own quirks.I highly doubt this is an issue with
next-i18next
. Can you please open an issue in the main i18next repository?