-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
How to get correct plural forms for fractions #10671
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
Comments
This is not a Issue is a question, you should create a question in http://stackoverflow.com and tagged with symfony2 |
Let me rephrase that then. In the function $position = PluralizationRules::get($number, $locale); Class return ($number == 1) ? 0 : 1; Thus, by default, the Translation component cannot handle fractional values properly. Similarily, for the french 'fr' locale For the Russian Locale, the resultant value returns 0, 1, or 2. Bosnian requires casing based on the value of the fraction It seems odd that the default casing provided by symfony framework when on a recent system, the built in MessageFormatter class provided by ext-intl in PHP works as expected foreach (array(1, 2, 5, 1.1, 1.2, 1.5) as $num) {
echo MessageFormatter::formatMessage("hr", "{count, plural, one{# one} few{# few} many{# many} other{# other}}", array("count"=>$num)), PHP_EOL;
}
// output:
1 one
2 few
5 other
1,1 one
1,2 few
1,5 other And 8000 it would be nice to not have to rely on ext-intl being installed as it is not enabled by default on PHP 5.3/5.4/5.5 |
We already have an issue suggesting to use the MessageFormatter class: #6009 |
Closing in favor of #6009 |
Is there any means of getting the correct plural forms selected for fractions?
ie:
"%count% Tag|%count% Tage"
should render
1 Tag
1,0 Tage
1,5 Tage
French seems to work by chance:
"%count% jour|%count% jours"
1 jour
1,0 jour
1,5 jour
The text was updated successfully, but these errors were encountered: