I've installed rails_admin gem on my localized site (2 languages) and i need administration (/admin) to be always in English. According to documentation I should add following 2 lines to beginning of rails_admin.rb file.
require 'i18n'
I18n.default_locale = :de
But it's not working. Any idea how to do that?
Stumbled over the same Issue. Here is 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
RailsAdmin
controllers are inheriting form your ApplicationController
so you need to tell them explicitly to use the locale :en there or you can open the classes and overwrite set_locale
.
It does state on the documentation that you only need to do this if your local is set to something other then English so you may find that you do not need to set this. If you do need to set this then make sure it is below the RailsAdmin.config do |config|
line in rails_admin.rb
Update -
As you are still running into problems could you please let me know what version of ruby you are using? Have you run a bundle install
? Could you try sudo gem install i18n
. Also if it cannot find your locales you may need to point it at them i.e I18n.load_translations "#{RAILS_ROOT}/locales/#{locale}.rb"
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