aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2018-10-25 08:09:01 -0400
committerGitHub <noreply@github.com>2018-10-25 08:09:01 -0400
commita3dcba42e2422eb9c2e77011a39ce72dc934b420 (patch)
tree1f4552e4ffcad2317aa279010aec8c68daa88686
parent3c000873946e5f2eb405fc9ba264acbfd431047e (diff)
parent4692ed7e12b72f2bd3adee9a243bd270f0de402e (diff)
downloadrails-a3dcba42e2422eb9c2e77011a39ce72dc934b420.tar.gz
rails-a3dcba42e2422eb9c2e77011a39ce72dc934b420.tar.bz2
rails-a3dcba42e2422eb9c2e77011a39ce72dc934b420.zip
Merge pull request #34309 from oliverguenther/patch-1
Document `deep_interpolation` parameter for bulk lookups
-rw-r--r--guides/source/i18n.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index 7465726dca..c61b6ad214 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -664,6 +664,26 @@ I18n.t 'activerecord.errors.messages'
# => {:inclusion=>"is not included in the list", :exclusion=> ... }
```
+If you want to perform interpolation on a bulk hash of translations, you need to pass `deep_interpolation: true` as a parameter. When you have the following dictionary:
+
+```yaml
+en:
+ welcome:
+ title: "Welcome!"
+ content: "Welcome to the %{app_name}"
+```
+
+then the nested interpolation will be ignored without the setting:
+
+```ruby
+I18n.t 'welcome', app_name: 'book store'
+# => {:title=>"Welcome!", :content=>"Welcome to the %{app_name}"}
+
+I18n.t 'welcome', deep_interpolation: true, app_name: 'book store'
+# => {:title=>"Welcome!", :content=>"Welcome to the book store"}
+```
+
+
#### "Lazy" Lookup
Rails implements a convenient way to look up the locale inside _views_. When you have the following dictionary: