我有一些國際化,我把它設置地方通過URL參數,像這樣的Rails應用程序:在Ruby on Rails中,如何從url中省略默認語言環境?
/EN /後/顯示/ 4的英語
/JA /後/顯示/ 4日本
我的路線:
ActionController::Routing::Routes.draw do |map|
map.connect "", :controller => "post", :action => "index"
map.connect "/:locale", :controller => "post", :action => "index"
map.connect "post/show/:id/:tag_title", :controller => "post", :action => "show", :requirements => {:id => /\d+/}, :path_prefix => '/:locale'
map.connect ":controller/:action/:id.:format", :requirements => {:id => /[-\d]+/}, :path_prefix => '/:locale'
map.connect ":controller/:action/:id", :requirements => {:id => /[-\d]+/}, :path_prefix => '/:locale'
map.connect ":controller/:action.:format", :path_prefix => '/:locale'
map.connect ":controller/:action", :path_prefix => '/:locale'
end
我想是有它因此省略URL的區域一部分時,它會使用默認的語言環境。所以這個:
/後/顯示/ 4是一樣的
/EN /後/顯示/ 4
,將區域設置爲英語。
什麼是一個很好的方法來實現這一目標?謝謝!
我所試圖做的是使其工作時,有沒有從URL發送語言。 – 2010-12-19 07:03:58