Search code examples
ruby-on-railsrubyrails-i18n

Rails: translation missing error


I am trying to learn ruby on rails. And when doing internationalisation, I'm getting the error:

translation missing: en.store.index.title_html

Below is my en.yml file

en:
  layouts:
    application: 
      title: "Pragmatic book shelf"
      home: "Home"
      questions: "Questions"
      news: "News"
      contact: "Contact"

  store:
    index:
    title_html: "Your Pragmatic Catalog" 
    add_html: "Add to Cart"

I have searched the solution, and it says allow only spaces in en.yml file. It's already written with only spaces. Any help will be highly appreciated.


Solution

  • You must add the proper indentation under the index key.

    en:
      store:
        index:
          title_html: "Your Pragmatic Catalog" 
          add_html: "Add to Cart"
    

    For accessing title_html with your current code, it'll be right after store, as you do with index (the three keys under the same store key):

    en.store.title_html