I am developing an Rails app on the advice of the Rails Guides to create the folder tree and files with the translations. My folder tree is similar to this:
|-defaults
|---es.rb
|---en.rb
|-models
|---book
|-----es.rb
|-----en.rb
|-views
|---defaults
|-----es.rb
|-----en.rb
|---books
|-----es.rb
|-----en.rb
|---users
|-----es.rb
|-----en.rb
|---navigation
|-----es.rb
|-----en.rb
The content in config/locales/views/books/en.yml is similar to this:
es:
books:
index:
title: "Título"
A in inside app/views/books/index.html.erb template like this (note the dot):
<%= t '.title' %>
When I have no namespace my translations in views work well but with the namespace "admin" that I use in my backend it does not work. Anyone know what is the problem?
I am using <%= t '.title' %>
because I am using “Lazy” Lookup http://guides.rubyonrails.org/i18n.html#lazy-lookup.
Rails implements a convenient way to look up the locale inside views. When you have the following dictionary:
es:
books:
index:
title: "Título"
you can look up the books.index.title value inside app/views/books/index.html.erb template like this (note the dot):
<%= t '.title' %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With