3
我将i18n添加到我的网页(针对不同语言的不同内容)。我的网址看看魔神这样的:Rails3:所有url_for URLS的前缀
scope "/:language/", :language => /de|en/ do
match "news/:news_id(/:title)" => "news#show_entry", :constraints => { :news_id => /[0-9]+/ }
...
end
我:
http://host.tld/de/news/15
http://host.tld/en/news/15
...
所有应用程序中的我的网址是由link_to
/url_for
方法这样
url_for("/news/#{news.id}/#{urlify(news.title)}")
url_for("/news/#{@news.section}")
...
我的路由看起来是这样的设置添加到我的ApplicationController:
def default_url_options(options={})
{:language => I18n.locale}
end
现在,我想将语言前缀添加到所有网址,而无需更改所有url_for() - 调用。有没有解决方案(参数/配置选项或其他)来添加此前缀?它也应该与相对路径一起工作。