Rails 3 和斯洛文尼亚语多元化
我想在 Rails 3.0.9 中使用 t('errors', :count => 2)
进行斯洛文尼亚语翻译,并希望它返回“2 napaki”,这是一种特殊的复数形式斯洛文尼亚语。
我已经创建了 locales/sl.yml 并具有以下代码:
sl:
error:
one: %{count} napaka
two: %{count} napaki
other: %{count} napak
但这似乎不起作用。
I'd like to use t('errors', :count => 2)
with slovenian translation in Rails 3.0.9 and want it to return "2 napaki" which is a special plural form for slovene language.
I have created locales/sl.yml and have this code:
sl:
error:
one: %{count} napaka
two: %{count} napaki
other: %{count} napak
But this doesn't seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保将翻译放入 config/locales/sl.yml 中。您还需要创建一个文件 config/locales/plurals.rb 并将以下代码放入其中:
在您的 application.rb 中,确保设置默认区域设置:
确保在进行这些更改后重新启动服务器。除了
:one, :two, :other
之外,您还可以使用:few
来表示 3、4、... 等数字,您还可以使用 看看这个要点,它完全符合您的要求。
Make sure you put your translations in config/locales/sl.yml. You'll also need to create a file config/locales/plurals.rb and put the following code inside:
In your application.rb make sure you set the default locale:
Make sure you restart the server after you make these changes. Besides
:one, :two, :other
you also have:few
for numbers like 3, 4, ...You can have also have a look at this gist wich does exactly what you ask.