1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added information about "lazy lookup" inside views (t '.foo') in I18N guide

This commit is contained in:
Karel Minarik 2009-03-01 12:51:18 +01:00
parent 959b827e40
commit a6f1e42c09

View file

@ -539,6 +539,23 @@ I18n.t 'active_record.error_messages'
# => { :inclusion => "is not included in the list", :exclusion => ... }
</ruby>
h5. "Lazy" lookup
Rails 2.3 implements convenient way to lookup locale inside _views_. When you have following dictionary:
<yaml>
es:
books:
index:
title: "Título"
</yaml>
you can lookup the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
<ruby>
<%= t '.title' %>
</ruby>
h4. Interpolation
In many cases you want to abstract your translations so that *variables can be interpolated into the translation*. For this reason the I18n API provides an interpolation feature.