question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plurals half-working for 1 langauge and entirely working for another

See original GitHub issue

Describe 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 en croatian1

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:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Nikola-Miloviccommented, Sep 26, 2022

@Nikola-Milovic did you open an issue on the main i18next repository? I can’t find it. If no, did you find out what the problem was?

The issue was with the language itself, basically Croatian has 2 plural forms.

"exclusivityPeriodItems": {
        "day_one": "{{count}} dan",
        "day_few": "{{count}} dana",
        "day_other": "{{count}} dana",
        "month_one": "{{count}} mjesec",
        "month_few": "{{count}} mjeseca",
        "month_other": "{{count}} mjeseci",
        "week_other": "{{count}} tjedana",
        "week_few": "{{count}} tjedana",
        "week_one": "{{count}} tjedan"
      },

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.

1reaction
isaachinmancommented, Apr 16, 2022

I highly doubt this is an issue with next-i18next. Can you please open an issue in the main i18next repository?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found