Skip to content

Commit 0d1e97e

Browse files
committed
feature #4834 [translator] use the new fallbacks option. (aitboudad)
This PR was merged into the 2.3 branch. Discussion ---------- [translator] use the new fallbacks option. | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | symfony/symfony#13376 Commits ------- 92194f2 [config][translator] use the new fallbacks option.
2 parents 9846d97 + 92194f2 commit 0d1e97e

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

best_practices/i18n.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ following ``translator`` configuration option and set your application locale:
1111
# app/config/config.yml
1212
framework:
1313
# ...
14-
translator: { fallback: "%locale%" }
14+
translator: { fallbacks: ["%locale%"] }
1515
1616
# app/config/parameters.yml
1717
parameters:

book/translation.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ enable the ``translator`` in your configuration:
5959
6060
# app/config/config.yml
6161
framework:
62-
translator: { fallback: en }
62+
translator: { fallbacks: [en] }
6363
6464
.. code-block:: xml
6565
@@ -74,18 +74,20 @@ enable the ``translator`` in your configuration:
7474
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7575
7676
<framework:config>
77-
<framework:translator fallback="en" />
77+
<framework:translator>
78+
<framework:fallback>en</framework:fallback>
79+
</framework:translator>
7880
</framework:config>
7981
</container>
8082
8183
.. code-block:: php
8284
8385
// app/config/config.php
8486
$container->loadFromExtension('framework', array(
85-
'translator' => array('fallback' => 'en'),
87+
'translator' => array('fallbacks' => array('en')),
8688
));
8789
88-
See :ref:`book-translation-fallback` for details on the ``fallback`` key
90+
See :ref:`book-translation-fallback` for details on the ``fallbacks`` key
8991
and what Symfony does when it doesn't find a translation.
9092

9193
The locale used in translations is the one stored on the request. This is
@@ -403,7 +405,7 @@ checks translation resources for several locales:
403405
#. If it wasn't found, Symfony looks for the translation in a ``fr`` translation
404406
resource (e.g. ``messages.fr.xliff``);
405407

406-
#. If the translation still isn't found, Symfony uses the ``fallback`` configuration
408+
#. If the translation still isn't found, Symfony uses the ``fallbacks`` configuration
407409
parameter, which defaults to ``en`` (see `Configuration`_).
408410

409411
.. _book-translation-user-locale:

quick_tour/the_architecture.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ PHP. Have a look at this sample of the default Symfony configuration:
145145
146146
framework:
147147
#esi: ~
148-
#translator: { fallback: "%locale%" }
148+
#translator: { fallbacks: ["%locale%"] }
149149
secret: "%secret%"
150150
router:
151151
resource: "%kernel.root_dir%/config/routing.yml"

reference/configuration/framework.rst

+14-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Configuration
4848
* :ref:`enabled <profiler.enabled>`
4949
* `translator`_
5050
* :ref:`enabled <translator.enabled>`
51-
* `fallback`_
51+
* `fallbacks`_
5252
* `validation`_
5353
* :ref:`enabled <validation-enabled>`
5454
* `cache`_
@@ -564,10 +564,19 @@ enabled
564564

565565
Whether or not to enable the ``translator`` service in the service container.
566566

567-
fallback
568-
........
567+
.. _fallback:
569568

570-
**type**: ``string`` **default**: ``en``
569+
fallbacks
570+
.........
571+
572+
**type**: ``string|array`` **default**: ``array('en')``
573+
574+
.. versionadded:: 2.3.25
575+
The ``fallbacks`` option was introduced in Symfony 2.3.25. Prior
576+
to Symfony 2.3.25, it was called ``fallback`` and only allowed one fallback
577+
language defined as a string.
578+
Please note that you can still use the old ``fallback`` option if you want
579+
define only one fallback.
571580

572581
This option is used when the translation key for the current locale wasn't found.
573582

@@ -724,7 +733,7 @@ Full default Configuration
724733
# translator configuration
725734
translator:
726735
enabled: false
727-
fallback: en
736+
fallbacks: [en]
728737
729738
# validation configuration
730739
validation:

0 commit comments

Comments
 (0)