【发布时间】:2010-04-08 15:41:29
【问题描述】:
我想做的是:
在 config/routes.rb 中
resources :posts
在 config/locale/en.yml 中
en:
resources:
posts: "posts"
new: "new"
edit: "edit"
在 config/locale/tr.yml
tr:
resources:
posts: "yazilar"
new: "yeni"
edit: "duzenle"
得到
I18n.locale = :en
edit_post_path(3) #=> /posts/3/edit
I18n.locale = :tr
edit_post_path(3) #=> /yazilar/3/duzenle
我还希望 Rails 随时匹配这些路由中的任何一个,并在 params 哈希中传递相关的语言环境,这样当我导航到 /yazilar 时,请求应该被路由到带有 @987654327 的 posts#index 操作参数哈希中的@locale。
有什么简单或复杂的方法吗?
【问题讨论】:
标签: ruby-on-rails localization routing internationalization