aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2015-02-10 15:59:45 +0100
committerRobin Dupret <robin.dupret@gmail.com>2015-02-10 15:59:45 +0100
commitd89912b9bef03f76f355e807476edd292cc293bc (patch)
tree83e5b4983f7ac1b6fbc353f03b164371b2eeb928 /guides
parenta2c80a894578ef0eee0da6a97ae2660aea69d12f (diff)
parente17260ca91d2e75a71279c47034ed1c2c14c1396 (diff)
downloadrails-d89912b9bef03f76f355e807476edd292cc293bc.tar.gz
rails-d89912b9bef03f76f355e807476edd292cc293bc.tar.bz2
rails-d89912b9bef03f76f355e807476edd292cc293bc.zip
Merge pull request #18808 from carlosramireziii/i18n-doc-update
Document lazy lookup behavior for controllers [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/i18n.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index fbee267975..8f24c53edb 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -588,6 +588,25 @@ you can look up the `books.index.title` value **inside** `app/views/books/index.
NOTE: Automatic translation scoping by partial is only available from the `translate` view helper method.
+"Lazy" lookup can also be used in _controllers_:
+
+```yaml
+en:
+ books:
+ create:
+ success: Book created!
+```
+which is especially useful for setting flash messages:
+
+```ruby
+class BooksController < ApplicationController
+ def create
+ # ...
+ redirect_to books_url, notice: t('.success')
+ end
+end
+```
+
### 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.