Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

activeadmin + internationalization

I've updated active_admin to version 0.3.0 to get internationalization working. But I have problems with it.

I have my pl.yml file updated with activeadmin section which looks like this:

pl:  
  active_admin:
    blank_slate:
      content: "Nie ma jeszcze rekordów."
      link: "Nowy"
    dashboard: "Dashboard2"
    view: "Podgląd"

This didn't work, so I tried adding this code to my application.rb:

    config.before_configuration do
      I18n.locale = :pl
      I18n.load_path += Dir[Rails.root.join('config', 'locales', '*', '.{rb,yml}')]
      I18n.reload!
    end

Now internationalization seems to work in development environment, but I still have problems in other environments. I have problem with dashboard: key. Normally, in short, when I18n doesn't find the key it puts key: with capital letter, in this example it would be "Dashboard". But in my case i have something like this:

Develoment:
Development

Production:
Production

Is there anyone who had the same problem? I'm I doing something wrong, or is this an activeadmin bug? Any solution?

like image 612
Dawid Woźniak Avatar asked Aug 25 '11 15:08

Dawid Woźniak


2 Answers

I had the same problem. I needed to do this to be able to get it to work in both production and development:

config.before_configuration do
  I18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
  I18n.locale = :nl
  I18n.default_locale = :nl
  config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
  config.i18n.locale = :nl
  # bypasses rails bug with i18n in production\
  I18n.reload!
  config.i18n.reload!
end

config.i18n.locale = :nl
config.i18n.default_locale = :nl

Not very pretty, but probably caused by a bug in Rails.

like image 191
Jaap Avatar answered Dec 29 '22 15:12

Jaap


in application.rb

config.i18n.default_locale = :fr
I18n.locale = config.i18n.locale = config.i18n.default_locale
I18n.reload!
like image 43
user1358180 Avatar answered Dec 29 '22 14:12

user1358180