Trouble on translating views after renaming statements from 'translate' to 'I18n.t' and from 'localize' to 'I18n.l'

StackOverflow https://stackoverflow.com/questions/10845890

Question

I am using Ruby on Rails 3.2.2 and I have a strange problem. In my view files I use the following code:

# app/views/articles/show.html.erb
I18n.t('.page_title')

When I render the above view code in the browser I get the translation missing: en.page_title message. However, as you can see from the "missing" message, the translation doesn't refer to the articles.show.page_title YML statement... but it should do that! It seems that the “Lazy” Lookup doesn't work as expected.

Why that happens? Have you some idea about the issue and how to solve it?

Note: I just made a code refactoring renaming statements from translate to I18n.t and from localize to I18n.l...

Était-ce utile?

La solution

Try simply: t('.page_title') Then you should see another statement. But in fact, I18n searches in several places. You can add the translation and see for yourself:

en:
  page-title:

Or:

en:
  articles:
    show:
      page-title:
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top