简体   繁体   中英

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?

This worked for me:

config.after_initialize do
  I18n.reload!
end

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM