Romanian pluralization rules are wrong

AI-generated summary

A discussion on the inaccuracies of Romanian pluralization rules in Discourse. iamntz initially reported the issue, explaining the correct rules for Romanian pluralization and how the current implementation only uses “one” and “other” cases. gerhard pointed out that the pluralization rules used by Discourse are incorrect and provided a link to the correct rules.

iamntz created a pull request to fix the issue, and tibarra suggested an additional condition to account for numbers ending in 100. tibarra and tibarra created separate pull requests to address this issue.

sam merged iamntz’s pull request and later merged tibarra’s pull request, resolving the issue.

Hey guys.

I noticed (the hard way…) that translating numbers is a bit off. The expectation was „enforced” by transifex’s one/few/other for cases that contain numbers to behave in a certain way. At least in romanian, we have this rules:

  • for one item is obvious;
  • for up to 20 items, it’s also ok (e.g.: 19 items);
  • over 20 items it’s an extra particle (e.g. 21 of items ).

Anyhow, I marched on the idea that this was implemented and updated quite a few strings to act accordingly. After the update? Surprise! Only „one” and „other” cases are used, leaving me with awkward translations :slight_smile:

This can be changed? Or can transifex be configured to not show the redundant one? (because you cannot save a translation that doesn’t have all three translation)

إعجابَين (2)

The pluralization rules used by Discourse are wrong:

See: http://www.unicode.org/cldr/charts/27/supplemental/language_plural_rules.html#ro

It should be like this:
https://github.com/discourse/discourse/blob/master/lib/javascripts/locale/ro.js

4 إعجابات

How can i repro this? i want to fix it

Already pushed a pull request here: Romanian Plurals by iamntz · Pull Request #4126 · discourse/discourse · GitHub

However, in order to reproduce, the best place to check is on like counter:

  • on more than one, less than 19 likes, you should read „3 aprecieri”
  • over 20 likes, you should read „23 de aprecieri”.
3 إعجابات

I think you forgot to take care of the 100 modules in your logic as in this section:

if (n === 0 || n != 1 && (n % 100) >= 1 &&
      (n % 100) <= 19 && n == Math.floor(n)) {
    return 'few';
  }

I made a PR with that conditionals too, but your solution was great! Cheers!

https://github.com/discourse/discourse/pull/4127

3 إعجابات

I merged @iamntz’s change, thanks :heart:

@tibarra if we also need this change submit a PR

إعجاب واحد (1)

Q: So, i make it again considering the modules?

A: Never mind, i already did it :sweat_smile:

https://github.com/discourse/discourse/pull/4128

إعجابَين (2)

Thanks !! merged the PR in

إعجاب واحد (1)