From a6f1e42c096a626b8a071094545d35f90d19ab55 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 12:51:18 +0100 Subject: [PATCH] Added information about "lazy lookup" inside views (`t '.foo'`) in I18N guide --- railties/guides/source/i18n.textile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index d882a65d8d..bb17e1ffc4 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -539,6 +539,23 @@ I18n.t 'active_record.error_messages' # => { :inclusion => "is not included in the list", :exclusion => ... } +h5. "Lazy" lookup + +Rails 2.3 implements convenient way to lookup locale inside _views_. When you have following dictionary: + + +es: + books: + index: + title: "Título" + + +you can lookup the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot): + + +<%= t '.title' %> + + 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.