Browse files

Merge pull request #556 from Mirrorball/master

It documents how translations for namespaced models should be defined. [ci skip]
  • Loading branch information...
2 parents 63a29bc + dafaa52 commit 204fa86bc48750845b4afb6792ebf4e2a462e0ad @carlosantoniodasilva carlosantoniodasilva committed May 2, 2012
Showing with 32 additions and 1 deletion.
  1. +32 −1
@@ -567,7 +567,7 @@ en:
**SimpleForm** will always look for a default attribute translation under the "defaults" key if no
-specific is found inside the model key.Note that this syntax is different from 1.x. To migrate to
+specific is found inside the model key. Note that this syntax is different from 1.x. To migrate to
the new syntax, just move "labels.#{attribute}" to "labels.defaults.#{attribute}".
In addition, **SimpleForm** will fallback to default human_attribute_name from Rails when no other
@@ -614,6 +614,37 @@ There are other options that can be configured through I18n API, such as require
Be sure to check our locale file or the one copied to your application after you run
`rails generate simple_form:install`.
+It should be noted that translations for labels, hints and placeholders for a namespaced model, e.g.
+`Admin::User`, should be placed under `admin_user`, not under `admin/user`. This is different from
+how translations for namespaced model and attribute names are defined:
+ activerecord:
+ models:
+ admin/user: User
+ attributes:
+ admin/user:
+ name: Name
+They should be placed under `admin/user`. Form labels, hints and placeholders for those attributes,
+though, should be placed under `admin_user`:
+ simple_form:
+ labels:
+ admin_user:
+ name: Name
+This difference exists because **SimpleForm** relies on `object_name` provided by Rails'
+FormBuilder to determine the translation path for a given object instead of `i18n_key` from the
+object itself. Thus, similarly, if a form for an `Admin::User` object is defined by calling
+`simple_form_for @admin_user, :as => :some_user`, **SimpleForm** will look for translations
+under `some_user` instead of `admin_user`.
## Configuration
**SimpleForm** has several configuration options. You can read and change them in the initializer

0 comments on commit 204fa86

Please sign in to comment.