2011-12-12 108 views
9

我想翻譯我的應用程序。我把這個在配置/ application.rb中:Rails 3,Set i18n locale is not working

​​

而且我創建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'" 
    .... 

如果我改變 「FR:」 要 「:恩」 它的工作。

任何想法我做錯了什麼? (我重新啓動apache)

謝謝你的幫助。

編輯:

的解決方案是使用:

I18n.default_locale = :fr 

,而不是

​​

回答

5

我的回答是使用的

config.i18n.default_locale = :fr 

代替

I18n.default_locale = :fr 

謝謝你的幫助。

+1

不知道爲什麼,但這個工程! – eloyesp

11

有你註釋掉這一行:

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

我更喜歡使用這條線來代替,因此它被遞歸包括子文件夾中的文件太:

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

博訥的機會!

+0

是的,我做到了,但我不看到有什麼區別...仍然是英文。 – Sebastien

+0

我的錯誤是使用:config.i18n.default_locale =:fr而不是I18n.default_locale =:fr – Sebastien

+0

好消息! :)所以那樣做了?也許你可以把我的答案標記爲好答案? ;) – jipiboily

5

@Sebastien答案爲我工作,也:

config.i18n.locale = :es 

我有另一個應用程序非常相似,這一次和設定DEFAULT_LOCALE作品在那裏。還沒有時間去挖掘真正的問題呢。

UPDATE

發現問題:https://github.com/gregbell/active_admin/issues/434

長時間的討論,但仍不能完全解決(SEP 2012),一個解決辦法:

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