确保将翻译放在 config/locales/sl.yml 中。您还需要创建一个文件 config/locales/plurals.rb 并将以下代码放入其中:
# More rules in this file: https://github.com/svenfuchs/i18n/blob/master/test/test_data/locales/plurals.rb
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
{
:'sl' => { :i18n => { :plural => { :rule => lambda { |n| [1].include?(n % 100) && ![11].include?(n % 100) ? :one : [2].include?(n % 100) && ![12].include?(n % 100) ? :two : [3, 4].include?(n % 100) && ![13, 14].include?(n % 100) ? :few : :other }}}}
}
在你的 application.rb 中确保你设置了默认的语言环境:
class Application < Rails::Application
...
config.i18n.default_locale = :sl
...
end
确保在进行这些更改后重新启动服务器。此外:one, :two, :other
,您还可以:few
使用 3、4、...等数字
你也可以看看这个要点,它完全符合你的要求。