From 92194f2349fc51a552a1e872a1e36990db5991cf Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Mon, 26 Jan 2015 16:00:53 +0000 Subject: [PATCH] [config][translator] use the new fallbacks option. --- best_practices/i18n.rst | 2 +- book/translation.rst | 12 +++++++----- quick_tour/the_architecture.rst | 2 +- reference/configuration/framework.rst | 19 ++++++++++++++----- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/best_practices/i18n.rst b/best_practices/i18n.rst index 9da3fad3271..5190af0a4ba 100644 --- a/best_practices/i18n.rst +++ b/best_practices/i18n.rst @@ -11,7 +11,7 @@ following ``translator`` configuration option and set your application locale: # app/config/config.yml framework: # ... - translator: { fallback: "%locale%" } + translator: { fallbacks: ["%locale%"] } # app/config/parameters.yml parameters: diff --git a/book/translation.rst b/book/translation.rst index 35339af79c2..cdaca6a1753 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -59,7 +59,7 @@ enable the ``translator`` in your configuration: # app/config/config.yml framework: - translator: { fallback: en } + translator: { fallbacks: [en] } .. code-block:: xml @@ -74,7 +74,9 @@ enable the ``translator`` in your configuration: http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> - + + en + @@ -82,10 +84,10 @@ enable the ``translator`` in your configuration: // app/config/config.php $container->loadFromExtension('framework', array( - 'translator' => array('fallback' => 'en'), + 'translator' => array('fallbacks' => array('en')), )); -See :ref:`book-translation-fallback` for details on the ``fallback`` key +See :ref:`book-translation-fallback` for details on the ``fallbacks`` key and what Symfony does when it doesn't find a translation. The locale used in translations is the one stored on the request. This is @@ -403,7 +405,7 @@ checks translation resources for several locales: #. If it wasn't found, Symfony looks for the translation in a ``fr`` translation resource (e.g. ``messages.fr.xliff``); -#. If the translation still isn't found, Symfony uses the ``fallback`` configuration +#. If the translation still isn't found, Symfony uses the ``fallbacks`` configuration parameter, which defaults to ``en`` (see `Configuration`_). .. _book-translation-user-locale: diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index aa644328799..2a499195cf1 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -145,7 +145,7 @@ PHP. Have a look at this sample of the default Symfony configuration: framework: #esi: ~ - #translator: { fallback: "%locale%" } + #translator: { fallbacks: ["%locale%"] } secret: "%secret%" router: resource: "%kernel.root_dir%/config/routing.yml" diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 5c871545081..26351f22135 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -48,7 +48,7 @@ Configuration * :ref:`enabled ` * `translator`_ * :ref:`enabled ` - * `fallback`_ + * `fallbacks`_ * `validation`_ * `cache`_ * `enable_annotations`_ @@ -526,10 +526,19 @@ enabled Whether or not to enable the ``translator`` service in the service container. -fallback -........ +.. _fallback: -**type**: ``string`` **default**: ``en`` +fallbacks +......... + +**type**: ``string|array`` **default**: ``array('en')`` + +.. versionadded:: 2.3.25 + The ``fallbacks`` option was introduced in Symfony 2.3.25. Prior + to Symfony 2.3.25, it was called ``fallback`` and only allowed one fallback + language defined as a string. + Please note that you can still use the old ``fallback`` option if you want + define only one fallback. This option is used when the translation key for the current locale wasn't found. @@ -676,7 +685,7 @@ Full default Configuration # translator configuration translator: enabled: false - fallback: en + fallbacks: [en] # validation configuration validation: