svenfuchs / rails-i18n

Repository for collecting Locale data for Ruby on Rails I18n as well as other interesting, Rails related I18n stuff
http://rails-i18n.org
MIT License
3.98k stars 2.77k forks source link

Wrong pluralization rules. #461

Open Exoth opened 10 years ago

Exoth commented 10 years ago

Pluralization rules for the Engilsh and many other languages are wrong. CLDR contains the right pluralization rules, and ruby-cldr gem gives them as ruby code. For example, for :en locales it is like this:

lambda { |n| n = n.respond_to?(:abs) ? n.abs : ((m = n.to_s)[0] == "-" ? m[1,m.length] : m); (n.to_i == 1 && ((v = n.to_s.split(".")[1]) ? v.length : 0) == 0) ? :one : :other }

Here's a CLDR defined difference:

1.0 - CLDR: other, rails-i18n: one

This difference comes from ruby-cldr as CLDR doesn't seem to define rules for negative numbers (also coverd by #270): -1 - ruby-cldr: one, rails-i18n: other

Explanations of why rails-i18n is wrong in these two cases is in the answer here: http://english.stackexchange.com/questions/69162/are-these-plural-or-singular

I propose not to change globally OneOther pluralization for all the locales, but to fix languages one by one whenever we are sure that it works some way. So this issue is about fixing :en and :en-xx pluralizations.

Also one more general ruby-cldr difference:

'1' - ruby-cldr: one, rails-i18n: other

I think, that converting strings to numbers for the check is nice.

Exoth commented 10 years ago

Though now I think that abs() could be used globally until we get some evidence, that it doesn't work this way in some language. At least this way we'll fix more locales than we'll break.

gorn commented 6 years ago

abs works well for cs locale