# How a js script can get the current locale from my rails app?

**URL:** <https://www.ruby-forum.com/t/how-a-js-script-can-get-the-current-locale-from-my-rails-app/197122>\
**Category:** Rails\
**Created:** [February 23, 2010, 7:47pm UTC](https://www.ruby-forum.com/t/how-a-js-script-can-get-the-current-locale-from-my-rails-app/197122 "2010-02-23T19:47:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [February 23, 2010, 7:47pm UTC](https://www.ruby-forum.com/t/how-a-js-script-can-get-the-current-locale-from-my-rails-app/197122/1 "2010-02-23T19:47:32Z")

</div>

I am not very fluent in JS, so I don’t see how to transfer the rails  
app current locale …

I have a JS script able to detect the default browser language …  
running fine

I can also modify the JS language, passing a global var …

// Create a JSON Object  
var myJSON = {  
“lang”: “fr”  
};  
// Pass it to the script immediately…  
datePickerController.setGlobalVars(myJSON);

and it runs … but I would like this script to use the language  
selected by the rails app user :  
the I18n.default\_locale being modified in the rails app

any clue ?

thanks a lot …

erwin

---

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [February 23, 2010, 9:56pm UTC](https://www.ruby-forum.com/t/how-a-js-script-can-get-the-current-locale-from-my-rails-app/197122/2 "2010-02-23T21:56:59Z")

</div>

Couldn’t you pass that back in your page’s view template?
