# Rails I18n

**URL:** <https://www.ruby-forum.com/t/rails-i18n/170212>\
**Category:** Rails\
**Created:** [June 14, 2009, 3:49am UTC](https://www.ruby-forum.com/t/rails-i18n/170212 "2009-06-14T03:49:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![semyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce7236/32.png) [@semyou](https://www.ruby-forum.com/u/semyou)\
**Post date:** [June 14, 2009, 3:49am UTC](https://www.ruby-forum.com/t/rails-i18n/170212/1 "2009-06-14T03:49:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![semyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce7236/32.png) [@semyou](https://www.ruby-forum.com/u/semyou)\
**Post date:** [June 14, 2009, 5:34am UTC](https://www.ruby-forum.com/t/rails-i18n/170212/2 "2009-06-14T05:34:55Z")

</div>

Why don’t you just do a simple form that does a GET to the same page  
with the locale as a parameter?

- 

Maurício Linhares  
[http://codeshooter.wordpress.com/](http://codeshooter.wordpress.com/) | [http://twitter.com/mauriciojr](http://twitter.com/mauriciojr)

On Sat, Jun 13, 2009 at 10:49 PM, Youyou

---

<div class="post-metadata">

**Author:** ![semyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce7236/32.png) [@semyou](https://www.ruby-forum.com/u/semyou)\
**Post date:** [June 14, 2009, 7:38am UTC](https://www.ruby-forum.com/t/rails-i18n/170212/3 "2009-06-14T07:38:47Z")

</div>

You say it’s first set from params[:locale]

So all you need to do is open page with ?locale=xx

On Jun 14, 3:49 am, Youyou S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![semyou](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ce7236/32.png) [@semyou](https://www.ruby-forum.com/u/semyou)\
**Post date:** [June 14, 2009, 10:02am UTC](https://www.ruby-forum.com/t/rails-i18n/170212/4 "2009-06-14T10:02:37Z")

</div>

Hi,  
Here are some some commits with example code for what you are after  
written  
by my coworker Kieran for the open source Kete app:

> <https://github.com/kete/kete/commit/f3a5f91a30acb5335e2084a5f761855261935870>

> <https://github.com/kete/kete/commit/0fe07a875eb14a79d566e41d790b7a4342528eb6>

> <https://github.com/kete/kete/commit/de005f8f5e42b7d32c71371fb5155cc4939986a4>

If Javascript is enabled, changing the drop down value will result in a  
redirect to the page with chosen locale set. If javascript is disabled,  
a  
button is added so that the form can be submitted.

Note that available locales are pulled from a config/locales.yml file.

Hope this helps,  
Walter
