Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3, Set i18n locale is not working

I am trying to translate my application. I put this in config/application.rb :

config.i18n.default_locale = :fr

And i create the active_admin.fr.yml file :

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'"
    ....

If i change the "fr:" to ":en" it's working.

Any idea what i did wrong? (I rebooted apache)

Thank you for help.

Edit :

The solution was to use :

I18n.default_locale = :fr

and not

config.i18n.default_locale = :fr
like image 409
Sebastien Avatar asked Dec 12 '11 17:12

Sebastien


2 Answers

Have you uncommented this line:

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s] # default one has "my" instead of "config", which is wrong

I prefer to use this line instead, so it is recursively including files in sub-folders too:

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]

Bonne chance!

like image 79
jipiboily Avatar answered Oct 17 '22 23:10

jipiboily


My answer was to use

config.i18n.default_locale = :fr 

instead of

I18n.default_locale = :fr 

Thank you for help.

like image 37
Sebastien Avatar answered Oct 17 '22 21:10

Sebastien