错误I18n :: InvalidLocaleData

ksu*_*rto 6 ruby-on-rails internationalization

我想使用I18n,我已经按照如何做到这一点,railscast但事情变得疯狂,我不知道哪里出错,试过检查格式,尝试了几种方法,但仍然无法完成.

我的 en.yml

en:
  category:
    index:
      title: "Listing Categories"
      name: "Name"
      is_active: "Is Active"
Run Code Online (Sandbox Code Playgroud)

我的 view

<%= t 'category.index.title' %>
Run Code Online (Sandbox Code Playgroud)

但回归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"
Run Code Online (Sandbox Code Playgroud)

并且可以完美地工作,但是当我添加更多行时,只需返回那些错误.对不起,我还没有在轨道上那么先进,感谢你们的帮助:D真的.

Ily*_*kov 26

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

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