ruby-on-railsruby-on-rails-3internationalizationruby-on-rails-3.2rails-i18n

Rails internationalization (i18n): Everything translating except layouts/application.html.erb


I keep getting "translation missing: en.layouts.application.title" for title or any item I try to translate within app/views/layouts/application.html.erb file.

config/locales/en.yml

en:

  layouts:
    application:
      title:  "My Catalog"
      home:  "Home"
      store:   "Store"
      faq:      "FAQ"
      contact:  "Contact"
      about:    "About"

app/views/layouts/application.html.erb

<div id="banner">
  <% t('.title') %>
</div>
<div id="nav_menu" class="sidebar_menu">
  <a href="/"><%= t('.home') %></a>
  <a href="/store"><%= t('.store') %></a>
  <a href="/faq"><%= t('.faq') %></a>
  <a href="/contact"><%= t('.contact') %></a>
  <a href="/about"><%= t('.about') %></a>
</div>

All the translations in the views are working but anything in the layout says its missing. I am using en.yml, fr.yml, and es.yml and it's the same issue with each (fr.layouts.application.title and es.layouts.application.title, respectively)

If I move the lines out of the layouts: application: nest and into the root hierarchy of the .yml file (removing the period from the t method of course) then everything translates. As soon as I move them back under layouts: application: I get translation missing again.

What could be wrong? I am using Rails 3.2.7

EDIT 1: Just tried using <% t('layouts.application.title') %> but still says translation missing.

EDIT 2: Work-around found if I copy or rename application.html.erb to a different name (and change *.yml files accordingly).
If I start a new project translations work just fine within application.html.erb. However in the current project: as long as I'm using application.html.erb (even with minimal test content) I still get translation missing.


Solution

  • UPDATE: Been away from this project for some time but figured out the issue....

    SOLVED: Pretty stupid I might add.
    Make sure you do not tab ('\t') to space the text in the files.
    Clearly it's not able to compile correctly with the tab characters.