Browse Source

Refactored docs

- Added more structure
- Added section on setting translation domain for fields
dantleech 12 years ago
parent
commit
e4d78a0de8
1 changed files with 31 additions and 3 deletions
  1. 31 3
      Resources/doc/reference/translation.rst

+ 31 - 3
Resources/doc/reference/translation.rst

@@ -41,7 +41,7 @@ You have two options to configure the catalogue for the admin class:
 
 
 An admin instance always gets the ``translator`` instance, so it can be used to
-translate messages within the ``configure*Fields`` method or in templates.
+translate messages within the ``configureFields`` method or in templates.
 
 .. code-block:: jinja
 
@@ -61,8 +61,33 @@ Translate field labels
 ----------------------
 
 The Admin bundle comes with a customized form field template. The most notable
-changes from the original one is the use of the translation domain provided by
-the Admin instance to translate label.
+change from the original one is the use of the translation domain provided by
+either the Admin instance or the field description to translate labels.
+
+Setting the translation domain
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+The translation domain of the Admin instance is used by default, however this
+can be overridden when defining new form fields:
+
+.. code-block:: php
+
+        $formMapper->with('form.my_group')
+            ->add('publishable', 'checkbox', array(
+                // ...
+                'translation_domain' => 'MyTranslationDomain',
+            ))
+            ->add('start_date', 'date', array(
+                // ...
+                'translation_domain' => 'MyTranslationDomain',
+            ));
+
+This is of particular use when using admin :doc:`extensions <extensions>`,
+where the extension and the translations would be defined in one bundle, but
+implemented in many different admin instances.
+
+Setting the label name
+^^^^^^^^^^^^^^^^^^^^^^
 
 By default, the label is the field name. However a label can be defined as
 third argument of the ``add`` method:
@@ -78,6 +103,9 @@ third argument of the ``add`` method:
         }
     }
 
+Label strategies
+^^^^^^^^^^^^^^^^
+
 There is another option for rapid prototyping or to avoid spending too much time
 adding the ``label`` key to all option fields: ``Label Strategies``. By default
 labels are generated by using a simple rule ::