5
我試圖在I18n & Rails中實現語言環境特定的多元化規則,但我沒有運氣。下面是我在做什麼:定製Rails I18n語言環境多元化幫助
# 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"
正如你所看到的,我試圖迫使:一些關鍵的(它應該返回「少數用戶」),只是爲了看看這個黨pluralizer將工作.. 。但沒有骰子:(
這裏是我運行環境:
- 的Rails 2.3.8
- 國際化0.5.0寶石
任何想法?
甜。這工作。多謝,夥計! – dhulihan 2010-12-05 07:52:04