Skip to content

The initializer if forcing the :en locale (reopen #187) #746

jbescoyez opened this Issue Sep 28, 2011 · 8 comments

6 participants


It seems the exact same issue as #187 has reappeared in edge.

The only workaround I found until now is to define config.i18n.locale = :fr # your locale in application.rb.

bartocc commented Sep 29, 2011

same here


Can you raise an error inside the I18n library to trace out where this is happening in RA?


The problem is actually happening since I18n.locale is called in the rails_admin initalizer before I18n.default_locale= in application.rb. Here is the stack trace:

/Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/gems/i18n-0.6.0/lib/i18n/config.rb:6:in `locale': unhandled exception
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/gems/i18n-0.6.0/lib/i18n.rb:147:in `translate'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/gems/activemodel-3.1.0/lib/active_model/translation.rb:55:in `human_attribute_name'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/fields/association.rb:46:in `block in <class:Association>'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/base.rb:88:in `instance_eval'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/base.rb:88:in `block in register_instance_option'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/sections/show.rb:38:in `block in initialize'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/sections/show.rb:36:in `each'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/sections/show.rb:36:in `initialize'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/sections.rb:27:in `new'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/sections.rb:27:in `block (2 levels) in included'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/model.rb:36:in `block in edit'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/model.rb:35:in `each'
    from /Users/jbescoyez/.rvm/gems/ruby-1.9.2-p290@test/bundler/gems/rails_admin-dc8cbf07ff97/lib/rails_admin/config/model.rb:35:in `edit'

Thx! I'll have a look.


Same here.

For now I put I18n.locale = 'my_locale' in initializers/rails_admin.rb after the RailsAdmin.config block to resolve this problem temporarily.

Is it possible to read main application's default locale when RailsAdmin is initialized in engine.rb ?

@bbenezech bbenezech added a commit that closed this issue Nov 16, 2011
@bbenezech bbenezech added default locale workaround to initializer
closes #746 [ci skip]
@bbenezech bbenezech closed this in e7d4b21 Nov 16, 2011

Won't fix for now (design): we need to access default locale before Rails sets it in application.rb
Added a workaround for newcomers, can't do much more for now.

zolzaya commented Jan 18, 2013

This is not work for me :(. I'm using Rails 3.2.11. Any idea how to make it work?

x-ji commented Mar 10, 2015

Also not working for me. Although /admin panel itself loads fine, still getting I18n::InvalidLocale - :en is not a valid locale error if I click on a specific model in the panel, even after adding that line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.