How a javascript can get the current locale in ruby on rails application?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With