Skip to content

[Translation] Improve the pluralization rule for French #16256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Oct 16, 2015 · 5 comments
Closed

[Translation] Improve the pluralization rule for French #16256

ghost opened this issue Oct 16, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Oct 16, 2015

The current pluralization rule for French is not exactly right. Numbers like negatives (like -4) and decimals of 1 (like 1.78) should also be considered as singulars, not plurals. Correct me if I'm wrong, but the current rule sets only 0, decimals of 0, and 1, as singulars, and the rest as plurals.

Something like that is better:

return [
    if ($number >= 0 and $number < 2) {
        return 'singular';
    }
    else {
        return 'plural';
    }
]

(Sorry, I'm not a coder, so I can't really provide the appropriate patch myself)

ghost referenced this issue in flarum/framework Oct 16, 2015
We now use Symfony's Translation component. Yay! We get more powerful pluralisation and better a fallback mechanism. Will want to implement the caching mechanism at some point too. The API is replicated in JavaScript, which could definitely use some testing.

Validators have been refactored so that they are decoupled from models completely (i.e. they simply validate arrays of user input). Language packs should include Laravel's validation messages.

ref #267
@aitboudad
Copy link
Contributor

Hi,
The pluralization rule expect number to be an integer and not a float type.

  • Numbers decimals: if we pass ($number = (int) 1.78 = 1) should be considered as singulars which is the current behavior.
  • Numbers negatives: IMO the number should be >= 0

@ghost
Copy link
Author

ghost commented Oct 21, 2015

I see you closed it, but what's about >= 0?

@stof
Copy link
Member

stof commented Oct 21, 2015

CLDR pluralization rules only support non-negative integers. And this is logical: language pluralization rules are based on a quantity, which cannot be negative or non-integer. So there is no way to pass such value in a pluralization rule selector and have it give you a meaningful value.

@ghost
Copy link
Author

ghost commented Oct 21, 2015

Okay, thanks for the explaination! :)

@kylekatarnls
Copy link
Contributor

kylekatarnls commented Feb 12, 2019

The pluralization rule expect number to be an integer and not a float type.

It should not! As @ghost explained, 1.5 is singular in French, plural in English, so you can't have both working if you force the integer cast, remove this typing please:

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Translation/IdentityTranslator.php#L57

@fabpot There is still a linguistic bug about decimal, this should be re-open and decimal numbers should be properly handled in different languages groups according to language plural rule, not truncated for every language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants