2011-12-12 77 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