Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on rails - javascript current locale

How a javascript can get the current locale in ruby on rails application?

like image 715
Oksana Avatar asked Oct 11 '10 08:10

Oksana


1 Answers

There are few ways how to do it, for example you can set locale variable in your view like this:

<script type="text/javascript"> 
  var locale = '<%= I18n.locale %>';
</script>

Of course, this is a global variable, so you should use a namespace.

like image 70
Igor Pavelek Avatar answered Oct 03 '22 08:10

Igor Pavelek