10

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

1 Answer 1

16

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.