mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #34309 from oliverguenther/patch-1
Document `deep_interpolation` parameter for bulk lookups
This commit is contained in:
commit
a3dcba42e2
1 changed files with 20 additions and 0 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue