当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - How to render different partials depending on current locale

问题描述:

I got index.erb and index-de.erb, and somewhere I saw an example where this resulted in index-de being rendered when I18n.locale was :de, but i just tried and it did not work and I could not find any documentation on this subject. So does this actually work or do I need an extra plugin for this ?

网友答案:

Localization is built into rails as of 2.2; you'll probably want to check out the i18n screencast and/or the guide.

Edit: in particular check out the guide's section 3.3, "Localized Views". The short answer is that the correct filename is index.de.html.erb.

网友答案:

they must be named index.LOCALE.EXTENSION so e.g. index.de.erb or index.de.html.erb for de locale (I18n.locale)

分享给朋友:
您可能感兴趣的文章:
随机阅读: