I have a bilingual site with nice URLs for SEO. Using Ruby on Rails 2.3.10.
routes.rb
fragment:
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
As you can see, :locale
and :greenhopper
are "hidden" in the URL.
There is a switch so that you can change the language of the current page. See my 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' %>
I simply don't specify a controller and action so that I am redirected to the current controller and action with different locale. Unfortunately, :greenhopper parameter gets lost.
- I am at
/order-jira-with-greenhopper-hosting/11.html
(:option => 11, :locale => 'en', :greenhopper => true
) - Generated links for switching languages are
/order-jira-hosting/11.html
and/zamow-hosting-jira/11.html
(:option => 11, :locale => 'pl' and 'en', :greenhopper => false)
... - ...But they should be
/order-jira-with-greenhopper-hosting/11.html
and/zamow-hosting-jira-z-greenhopper/11.html
(:option => 11, :locale => 'pl' and 'en', :greenhopper => true)
How to use link_to method so that all parameters passed to controller are preserved? Thanks for your help.