aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-06 16:40:45 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-06 16:40:45 -0300
commit29ae431c51dea6e50abf98b6d62dbfd4828ceab7 (patch)
tree5a3f5fd58a5920aeb0ce7be3cff3274bd2feb559 /guides/source
parentadc10d2dc523ee1480e3b9d31ad2e264ee235bf4 (diff)
parentd5f2c5c20e2f8f104a1e67ba81166874cc472b9e (diff)
downloadrails-29ae431c51dea6e50abf98b6d62dbfd4828ceab7.tar.gz
rails-29ae431c51dea6e50abf98b6d62dbfd4828ceab7.tar.bz2
rails-29ae431c51dea6e50abf98b6d62dbfd4828ceab7.zip
Merge pull request #14997 from jpcody/nested_value_i18n
Include label value in i18n attribute lookup
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/i18n.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index c1b575c7b7..0eba3af6e8 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -712,6 +712,19 @@ en:
Then `User.model_name.human(count: 2)` will return "Dudes". With `count: 1` or without params will return "Dude".
+In the event you need to access nested attributes within a given model, you should nest these under `model/attribute` at the model level of your translation file:
+
+```yaml
+en:
+ activerecord:
+ attributes:
+ user/gender:
+ female: "Female"
+ male: "Male"
+```
+
+Then `User.human_attribute_name("gender.female")` will return "Female".
+
#### Error Message Scopes
Active Record validation error messages can also be translated easily. Active Record gives you a couple of namespaces where you can place your message translations in order to provide different messages and translation for certain models, attributes, and/or validations. It also transparently takes single table inheritance into account.