Sebastien
Sebastien

Reputation: 6660

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

Upvotes: 10

Views: 9937

Answers (3)

yorch
yorch

Reputation: 7318

@Sebastien answer worked for me, but also:

config.i18n.locale = :es

I have another application very similar to this one and the default_locale setting works there. Haven't had time to dig into the real problem yet.

UPDATE

Found the issue: https://github.com/gregbell/active_admin/issues/434

Long discussion and still not completely resolved (Sep 2012), one workaround:

config.i18n.default_locale = :es
I18n.locale = config.i18n.locale = config.i18n.default_locale

Upvotes: 5

Sebastien
Sebastien

Reputation: 6660

My answer was to use

config.i18n.default_locale = :fr 

instead of

I18n.default_locale = :fr 

Thank you for help.

Upvotes: 5

jipiboily
jipiboily

Reputation: 1240

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!

Upvotes: 11

Related Questions