rails-i18n icon indicating copy to clipboard operation
rails-i18n copied to clipboard

Wrong pluralization rules.

Open Exoth opened this issue 10 years ago • 2 comments

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 avatar Jun 26 '14 14:06 Exoth

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.

Exoth avatar Jun 26 '14 17:06 Exoth

abs works well for cs locale

gorn avatar Sep 30 '18 23:09 gorn