SEO に適した URL を持つバイリンガル サイトがあります。Ruby on Rails 2.3.10 を使用しています。
routes.rb
断片:
map.connect 'order-jira-hosting/:option.html',
:controller => 'order', :action => 'index', :locale => 'en'
map.connect 'order-jira-with-greenhopper-hosting/:option.html',
:controller => 'order', :action => 'index', :locale => 'en', :greenhopper => true
map.connect 'zamow-hosting-jira/:option.html',
:controller => 'order', :action => 'index', :locale => 'pl'
map.connect 'zamow-hosting-jira-z-greenhopper/:option.html',
:controller => 'order', :action => 'index', :locale => 'pl', :greenhopper => true
ご覧のとおり:locale
、:greenhopper
URL に「隠されています」。
現在のページの言語を変更できるようにスイッチがあります。私を参照してくださいviews/layouts/default.erb
:
<%= link_to image_tag('icons/polish.png', :alt => 'polski'), { :locale => 'pl'}, :class => 'a' %>
<%= link_to image_tag('icons/english.png', :alt => 'English'), { :locale => 'en'}, :class => 'a' %>
コントローラーとアクションを指定しないだけなので、現在のコントローラーとアクションに別のロケールでリダイレクトされます。残念ながら、:greenhopper パラメータは失われます。
- 私は
/order-jira-with-greenhopper-hosting/11.html
(:option => 11, :locale => 'en', :greenhopper => true
)にいます /order-jira-hosting/11.html
言語を切り替えるために生成されたリンクは/zamow-hosting-jira/11.html
(:option => 11, :locale => 'pl' and 'en', :greenhopper => false)
...- ...しかし、そうあるべきで
/order-jira-with-greenhopper-hosting/11.html
あり、/zamow-hosting-jira-z-greenhopper/11.html
(:option => 11, :locale => 'pl' and 'en', :greenhopper => true)
コントローラーに渡されるすべてのパラメーターが保持されるように link_to メソッドを使用する方法は? ご協力いただきありがとうございます。