I’m trying to implement locale-specific pluralization rules in I18n & Rails, but I’m having no luck. Here’s what I’m doing:
# in config/initializers/locale.rb
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
{
# Force Use of :few key
:ru => {:i18n => {:plural => {:rule => lambda { |n| :few}}}}
}
# in config/locales/ru.yml
ru:
user:
one: One User
few: Few Users
many: Many Users
other: Other Users
# Testing
script/console
>> I18n.locale = :ru ; I18n.t("user", :count => 20)
=> "Other Users"
As you can see, i’m trying to force the :few key(it should return “Few Users”), just to see if this dang pluralizer will work…but no dice 🙁
Here’s the environment I’m running:
- Rails 2.3.8
- i18n 0.5.0 gem
Any Ideas?
Tried replicating your problem, and had the same issue. Moved the pluralization rule into the locale file, and worked fine.
Switched the locale file over to the Ruby-style, as the regular YAML didn’t seem to like my lambda for some reason.
might give that a try and see if it helps