Error I18n::InvalidLocaleData

走远了吗. 提交于 2019-12-21 12:34:23

问题


I want use I18n and I already follow on how to do that from railscast but the thing gone wild and I don't know where the mistake, had tried check the format, tried several ways but still can't be done.

my en.yml

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

my view

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

But return I18n::InvalidLocaleData in Categories#index and can not load translations from /home/lenovo/cost_control/config/locales/en.yml, expected it to return a hash, but does not

I had try on my en.yml just:

en:
  title: "Listing Categories"

and can work perfectly, but when I adding more line, just return me those error. I'm sorry I just not so advanced yet in rails, thank you for the help you guys :D really.


回答1:


It seems your YAML is broken. Didn't you use tabs instead of spaces?

You can use YAMLlint to check YAML for validity.




回答2:


The validator Ilya recommends seemed pretty basic and not so great

Found this one which is better https://codebeautify.org/yaml-validator



来源:https://stackoverflow.com/questions/15331873/error-i18ninvalidlocaledata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!