简体   繁体   English

Rails 3 - 用I18n翻译路线

[英]Rails 3 - translating of routes with I18n

I want simple thing. 我想要简单的事情。 Translate routes with I18n like this 像这样翻译I18n的路线

get I18n.t('routes.login') => "devise/sessions#new", :as => :new_user_session

I made file initilizers/locale.rb with 我用文件initilizers / locale.rb

I18n.default_locale = :cz

It works perfectly when i run 'rake routes', but when i run server it ignore default locale and throw 'translation missing message' 当我运行'rake routes'时,它运行得很好,但是当我运行服务器时,它忽略默认语言环境并抛出'翻译缺失消息'

Any suggestion what is happening and why ? 有什么建议,为什么?

I believe, that normally routes are loaded once, even before locale are set, so you simply can't use the logic you have here. 我相信,通常路由被加载一次,甚至在设置locale之前,所以你根本就不能使用你在这里的逻辑。 You need more advanced stuff to get it to work. 你需要更高级的东西才能让它发挥作用。 Take a look at i18n_routing: http://github.com/kwi/i18n_routing 看看i18n_routing: http ://github.com/kwi/i18n_routing

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM