Romanian pluralization rules are wrong

(Ionuț Staicu) #1

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)

(Gerhard Schlager) #2

The pluralization rules used by Discourse are wrong:

See: Language Plural Rules

It should be like this:

(Tomas Ibarra) #3

How can i repro this? i want to fix it

(Ionuț Staicu) #4

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”.

(Tomas Ibarra) #5

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!

(Sam Saffron) #6

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

@tibarra if we also need this change submit a PR

(Tomas Ibarra) #7

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

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

(Sam Saffron) #8

Thanks !! merged the PR in

(Sam Saffron) #9