WeblateOrg / weblate

Web based localization tool with tight version control integration.
https://weblate.org/
GNU General Public License v3.0
4.6k stars 1.02k forks source link

Plural rules (i18next v4) not working for Montenegrin #11197

Open dusan-smolnikar opened 7 months ago

dusan-smolnikar commented 7 months ago

Describe the issue

I am using i18next v4 json files for my translations. Among the languages I also have Montengrin (me.js)

In the file me.js I had a plural form of the following translation: "episode_one": "{number} epizoda", "episode_other": "{number} epizoda", "episode_few": "{number} epizode",

However, Weblate for some reason requires the forms one, few, many:

Screenshot 2024-03-13 at 23 32 03

When I save this translation string I lose the episode_few key from my source file, but episode_one and episode_other are kept.

I already tried

Steps to reproduce the behavior

  1. Import me.js with correct plural rules into weblate:
    "episode_one": "{number} epizoda",
    "episode_other": "{number} epizoda",
    "episode_few": "{number} epizode",

    Weblate requires me to write entries:

    • episode_one
    • episode_few
    • episode_many

Expected behavior

Weblate requires entering of

Screenshots

Screenshot 2024-03-13 at 23 32 03

Exception traceback

No response

How do you run Weblate?

Other

Weblate versions

Weblate 5.3.1

Weblate deploy checks

No response

Additional context

No response

nijel commented 7 months ago

There are two issues here:

  1. translate-toolkit doesn't have a definition for this language (because it's not present in CLDR) and loads and saves only one/many.
  2. Weblate has wrong labels here. The reason is that it uses the same plural formula as other languages which have one/few/many. This is caused by Weblate not supporting decimals in plural formulas and I don't see an easy way to address this. But this is just a display issue (showing Many instead of Other) and doesn't affect saving.
dusan-smolnikar commented 7 months ago

Regarding no. 1 - Not sure if this info is helpful at all, but in the Unicode CLDR the language is defined as sr-Latn-ME. The plural rules are the same as for Serbian (sr). Is there a way I can configure language aliases to make Weblate believe this is Serbian language? However, I do have Serbian language separate though, and they shouldn't be mixed.

For no. 2 - It's not just a display issue. I entered all 3 values in Weblate and committed - But this resulted in translations being deleted in my git repository. The only workaround was to manually return the key/value pair and not touch this translation in Weblate.

Screenshot 2024-03-13 at 23 15 27
nijel commented 7 months ago

Writing is again caused by missing definitions in the translate-toolkit.

nijel commented 7 months ago

https://github.com/translate/translate/pull/5212 should address saving/loading part, let's keep this issue open for the display issue.

dusan-smolnikar commented 7 months ago

Great, thanks!

gs-xpeng commented 6 months ago

We also met the similar issue : We found that :

“aaaa”:"aaaa", “aaaa_one”:"aaaa", “aaaa_two”:"aaaa", will keep the key “aaaa” stay only .

“aaaa”:"aaaa", “aaaa_other”:"aaaa", will keep the key “aaaa” stay only .

gs-xpeng commented 6 months ago

Is there any way to disable Plural rules ?

nijel commented 6 months ago

@gs-xpeng You can use "JSON file" instead, it will load all keys as they are.

The plural fix got finally released today at translate-toolkit: https://github.com/translate/translate/releases/tag/3.13.0