Romanian pluralization rules are wrong

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 Likes

The pluralization rules used by Discourse are wrong:

https://github.com/discourse/discourse/blob/master/config/locales/plurals.rb#L82-L82

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 Likes

How can i repro this? i want to fix it

Already pushed a pull request here: https://github.com/discourse/discourse/pull/4126

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 Likes

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 Likes

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

@tibarra if we also need this change submit a PR

1 Like

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 Likes

Thanks !! merged the PR in

1 Like