2013-03-11 98 views
4

我想使用I18n,我已经遵循如何做到这一点从railscast但事情疯了,我不知道错在哪里,试图检查格式,尝试了几种方法,但仍然可以不行。错误I18n :: InvalidLocaleData

en.yml

en: 
    category: 
    index: 
     title: "Listing Categories" 
     name: "Name" 
     is_active: "Is Active" 

view

<%= t 'category.index.title' %> 

但返回I18n::InvalidLocaleData in Categories#indexcan not load translations from /home/lenovo/cost_control/config/locales/en.yml, expected it to return a hash, but does not

我曾尝试对我的en.yml刚:

en: 
    title: "Listing Categories" 

,可以完美地工作,但是当我增加更多的线路,只返回我的错误。对不起,我只是没有那么高级,但感谢你们的帮助:真的。

+0

完成检查[此问题](http://stackoverflow.com/questions/12286099/rails-console-fails-to-start-with-error-from-i18n) – ksugiarto 2013-03-11 05:40:16

+0

而且[this](http:///stackoverflow.com/questions/13123406/gem-spree-i18n-throws-error-on-server-startup-can-not-load-translations) – ksugiarto 2013-03-11 05:40:40

回答

19

看来你的YAML坏了。你不是使用制表符而不是空格吗?

您可以使用YAMLlint来检查YAML的有效性。

+0

是的,先生,谢谢。我刚发现它必须使用tab而不是空格。我认为我应该像当我在选项卡上做coffescript时那样做。现在它的工作,谢谢先生:D – ksugiarto 2013-03-11 06:34:04

+1

+1为真棒链接 – davidicus 2014-08-25 20:53:35

+0

非常感谢你 – 2015-02-28 06:06:06