Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Translation missing activeadmin, Ruby on rails

I translated my active admin menu :

# encoding: utf-8
ActiveAdmin.register City do
    menu :parent => "Données géographiques", :label => I18n.t(:cities)
end

In my active_admin.fr.yml :

    fr:
      active_admin:
        dashboard: "Tableau de Bord"
        dashboard_welcome:
          welcome: "Bienvenue dans Active Admin. Ceci est la page par défaut."
          call_to_action: "Pour ajouter des sections au tableau de bord, consultez 'app/admin/dashboards.rb'"
      cities: "Villes"

In my local (debian 6) everything works fine, but on my pre-production (debian 6), it's writter :

translation missing: fr.cities

I tried to reboot apache, clear cache, reload I18n... I failed.

Any idea?

like image 494
Sebastien Avatar asked Dec 13 '11 16:12

Sebastien


3 Answers

This worked for me:

config.after_initialize do
  I18n.reload!
end
like image 102
Dieter Pisarewski Avatar answered Oct 25 '22 11:10

Dieter Pisarewski


I found the solution, you have to write that on your application.rb :

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

config.i18n.locale = :fr
config.i18n.default_locale = :fr

Reboot apache and that's good!

like image 23
Sebastien Avatar answered Oct 25 '22 11:10

Sebastien


I found the solution, add this in application.rb

config.before_configuration do # FIX conflict I18n ActiveAdmin
  I18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
  I18n.locale = I18n.default_locale = config.i18n.default_locale
  I18n.reload!
end
like image 38
Jaime Mateos Avatar answered Oct 25 '22 11:10

Jaime Mateos