ActiveAdmin with I8n.js in Rails

I am developing a Rails application with ActiveAdmin and I am using I18n.js for js translations.

Problem is that for I8n.js to work, I have to set the language in each .erb as follows:

 <script type="text/javascript"> I18n.defaultLocale = "<%= I18n.default_locale %>"; I18n.locale = "<%= I18n.locale %>"; </script> 

The witch works fine in the rest of the application (if I put it in the application.erb file), but I cannot find a global location so that it can be used for all my ActiveAdmin forms.

I really don't want to repeat the code in every form or change the default erb (if possible).

So, is there a way to share some erb code in all views?

Thanks!

+4
source share
1 answer

There are two ways, I think: 1. Put this code in the layout view 2. Put this code in a separate partial and display it in each view (if there are some problems with the layouts)

0
source

All Articles