@@ -93,6 +93,43 @@ not exist in the user's locale.
93
93
The locale used in translations is the one stored on the request. This is
94
94
typically set via a ``_locale `` attribute on your routes (see :ref: `book-translation-locale-url `).
95
95
96
+ Fallback and Default Locale
97
+ ---------------------------
98
+
99
+ If the locale hasn't been set explicitly in the session, the ``fallback_locale ``
100
+ configuration parameter will be used by the ``Translator ``. The parameter
101
+ defaults to ``en `` (see `Configuration `_).
102
+
103
+ Alternatively, you can guarantee that a locale is set on each user's request
104
+ by defining a ``default_locale `` for the framework:
105
+
106
+ .. configuration-block ::
107
+
108
+ .. code-block :: yaml
109
+
110
+ # app/config/config.yml
111
+ framework :
112
+ default_locale : en
113
+
114
+ .. code-block :: xml
115
+
116
+ <!-- app/config/config.xml -->
117
+ <framework : config >
118
+ <framework : default-locale >en</framework : default-locale >
119
+ </framework : config >
120
+
121
+ .. code-block :: php
122
+
123
+ // app/config/config.php
124
+ $container->loadFromExtension('framework', array(
125
+ 'default_locale' => 'en',
126
+ ));
127
+
128
+ .. versionadded :: 2.1
129
+ The ``default_locale `` parameter was defined under the session key
130
+ originally, however, as of 2.1 this has been moved. This is because the
131
+ locale is now set on the request instead of the session.
132
+
96
133
.. index ::
97
134
single: Translations; Translation resource locations
98
135
@@ -259,6 +296,11 @@ support for both Twig and PHP templates.
259
296
Twig Templates
260
297
~~~~~~~~~~~~~~
261
298
299
+ ..
300
+ However, the ``%var%``
301
+ notation is required when translating in Twig templates, and is overall a
302
+ sensible convention to follow.
303
+
262
304
Symfony2 provides specialized Twig tags (``trans `` and ``transchoice ``) to
263
305
help with message translation of *static blocks of text *:
264
306
@@ -469,6 +511,13 @@ Create a translation file under the ``validators`` catalog for the constraint me
469
511
# validators.en.yml
470
512
author.name.not_blank : Please enter an author name.
471
513
514
+ Translating Database Content
515
+ ----------------------------
516
+
517
+ The translation of database content should be handled by Doctrine through
518
+ the `Translatable Extension `_. For more information, see the documentation
519
+ for that library.
520
+
472
521
Summary
473
522
-------
474
523
@@ -490,3 +539,4 @@ steps:
490
539
.. _`i18n` : http://en.wikipedia.org/wiki/Internationalization_and_localization
491
540
.. _`ISO3166 Alpha-2` : http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
492
541
.. _`ISO639-1` : http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
542
+ .. _`Translatable Extension` : https://github.com/l3pp4rd/DoctrineExtensions
0 commit comments