yongwoon
yongwoon

Reputation: 155

I18n::InvalidLocaleData - can not load translations from

I using the i18n for internationalization. but, occur the problem as blow.

config/locales/view/en.yml: expects it to return a hash, but does not

Although, I write yml with correct intent (2 space, no tap),
error is occur.
How could I resolve the problem ?

en.yml

en:
  moderna:
    language:
      en: English
      jp: Japanese
      kr: Korean
    menu:
      company: Company
      home: Home
    submenu:
      company:
        history: History
        introduce: Introduce
        philosophy: Philosophy
        subsidiary: Subsidiary
        vision: Vision

erb

<%= link_to t("moderna.menu.home"), xx_path %>
<%= link_to t("moderna.submenu.company.introduce"), introduce_path %>
<%= link_to t("moderna.submenu.company.history"), history_path %>
<%= link_to t("moderna.submenu.company.philosophy"), philosophy_path %>
<%= link_to t("moderna.submenu.company.subsidiary"), subsidiary_path %>
<%= link_to t("moderna.submenu.company.vision"), vision_path %>

Upvotes: 3

Views: 7633

Answers (1)

yongwoon
yongwoon

Reputation: 155

I found the cause. When you use i18n in project

  1. should be generate file of internalization with different name.

    config/locales/default/en.yml
    config/locales/default/kr.yml
    config/locales/model/en.yml
    config/locales/model/kr.yml
    engines/hoge_engines/config/locales/default/en.yml
    engines/hoge_engines/config/locales/default/kr.yml
    engines/hoge_engines/config/locales/modle/en.yml
    engines/hoge_engines/config/locales/model/kr.yml

=> maybe occur error.[can not load translations from ~~~~~] so, I changed the file name as blow

config/locales/default/default_en.yml  
config/locales/default/default_kr.yml  
config/locales/model/model_en.yml  
config/locales/model/model_kr.yml  
engines/hoge_engines/config/locales/default/default_en.yml   
engines/hoge_engines/config/locales/default/default_kr.yml  
engines/hoge_engines/config/locales/modle/model_en.yml   
engines/hoge_engines/config/locales/model/model_kr.yml  
  1. Don't make empty file for internalization (yml). I made the empty yml file for use after. It also cause that raise error.

Upvotes: 2

Related Questions