Ruby on rails 3 Rails 3和斯洛文尼亚多元化
我想在Rails 3.0.9中对斯洛文尼亚语翻译使用Ruby on rails 3 Rails 3和斯洛文尼亚多元化,ruby-on-rails-3,localization,pluralize,Ruby On Rails 3,Localization,Pluralize,我想在Rails 3.0.9中对斯洛文尼亚语翻译使用t('errors',:count=>2),并希望它返回“2 napaki”,这是斯洛文尼亚语的一种特殊复数形式 我已经创建了locales/sl.yml,并拥有以下代码: sl: error: one: %{count} napaka two: %{count} napaki other: %{count} napak 但这似乎不起作用。请确保将翻译放在config/locales/sl.yml中。您还需要创建一
t('errors',:count=>2)
,并希望它返回“2 napaki”,这是斯洛文尼亚语的一种特殊复数形式
我已经创建了locales/sl.yml,并拥有以下代码:
sl:
error:
one: %{count} napaka
two: %{count} napaki
other: %{count} napak
但这似乎不起作用。请确保将翻译放在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
类应用程序
确保在进行这些更改后重新启动服务器。除了:一,:二,:其他
对于3,4
你也可以让wich完全按照你的要求去做。确保你把你的翻译放在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
类应用程序
确保在进行这些更改后重新启动服务器。除了:一,:二,:其他
对于3,4
你也可以让wich完全按照你的要求去做