I am using Ruby on Rails 3.1 and I would like to know how to correctly handle internationalization related to view files. That is, …
… in my app/views/users/flag.html.erb file I have:
<% content_for :page_title do %>
<%= t(:test_key) %>
<% end %>
… in my config/locales/views/users/en.yml file (note: I am organizing files as stated in the official RoR guide) I have:
en:
views:
users:
flag:
test_key: Test text
When I browse the flag page the t(:test_key) is not translated. What is wrong in the config/locales/views/users/en.yml file? How can I make it to work?
You might want to read a bit further down on that guide, until you reach the “Lazy lookup” part.
Try
t('.test_key')instead oft(:test_key). The difference is in the dot.