简体   繁体   中英

Rails 3 - translating of routes with I18n

I want simple thing. Translate routes with I18n like this

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

I made file initilizers/locale.rb with

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'

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. You need more advanced stuff to get it to work. Take a look at i18n_routing: http://github.com/kwi/i18n_routing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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