views:

310

answers:

2

Hi, I am trying to use i18n in rails. I want the language to be set first from params[:locale] (probably already in the url) then from the browser http header and lastly from the default_locale. Everything is fine. Now the problem starts, when I want to add a dropdown list to allow the user to change the locale. How do I force the page to reload with the new Locale? FYI, I tried using .js and forcing a page.reload. The result was that the it kept the same locale in the url after the reload. Any ideas?

A: 

You could use the PrototypeHelper#observe_field method to generate the Javascript to add the onSelect event.

You can't just reload the page, you have to do a new request to the same url with the new locale.

BJ Clark
+1  A: 

I think this is really a JS question. It should be something like this:

location.href = location.href + "&locale=" + locale;
eipipuz