2013-03-11 109 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