我正在使用 high_voltage
创建多个着陆页。
结构
app
views
pages
home.html.erb
about.html.erb
我希望能够根据 session[:locale]
以简单的方式使用不同的 View 模板
我想到了这样的结构:
app
views
pages
en
home.html.erb
es
home.html.erb
但是如何在 PagesController 中渲染正确的模板呢?
我不想为此使用 Rails 国际化 (I18n) gem。
我正在使用 set_language_controller
在 session 中保存 I18n.locale
。
来源:http://xyzpub.com/en/ruby-on-rails/3.2/i18n_mehrsprachige_rails_applikation.html
最佳答案
只需将文件命名为:
app
views
pages
home.html.en.erb
home.html.es.erb
about.html.en.erb
about.html.es.erb
关于ruby-on-rails - 如何使用基于语言的 View 和模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16104825/