Rails 3.2.11: localizing RailsAdmin

I installed rails_admin gem on my localized site (2 languages) and I need the administration (/ admin) to always be in English. According to the documentation , I have to add the following 2 lines to the beginning of the rails_admin.rb file.

require 'i18n' I18n.default_locale = :de 

But it does not work. Any idea how to do this?

+4
source share
2 answers

I came across the same problem. Here's how I solved it:

 class ApplicationController < ActionController::Base include Clearance::Controller # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception before_filter :set_locale def set_locale if [Clearance, RailsAdmin].include?(self.class.parent) I18n.locale = :en else I18n.locale = params[:locale] || I18n.default_locale end end end 
Controllers

RailsAdmin inherits the form your ApplicationController , so you need to explicitly tell them how to use the: en locale there, or you can open classes and overwrite set_locale .

+2
source

It points to the documentation that you only need to do this if your local server is configured for something other than English, so you may find that you do not need to install this. If you need to install this, make sure it is below the RailsAdmin.config do |config| line RailsAdmin.config do |config| in rails_admin.rb

Update -

As you still run into problems, can you tell me which version of ruby ​​you are using? Did you bundle install ? Could you try sudo gem install i18n . Also, if he cannot find your locales, you may need to point him to them. I I18n.load_translations "#{RAILS_ROOT}/locales/#{locale}.rb"

+1
source

All Articles