Skip to content

[translator] use the new fallbacks option. #4834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion best_practices/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enable the ``translator`` in your configuration:

# app/config/config.yml
framework:
translator: { fallback: en }
translator: { fallbacks: [en] }

.. code-block:: xml

Expand All @@ -74,18 +74,20 @@ enable the ``translator`` in your configuration:
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:translator fallback="en" />
<framework:translator>
<framework:fallback>en</framework:fallback>
</framework:translator>
</framework:config>
</container>

.. code-block:: php

// 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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion quick_tour/the_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
19 changes: 14 additions & 5 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Configuration
* :ref:`enabled <profiler.enabled>`
* `translator`_
* :ref:`enabled <translator.enabled>`
* `fallback`_
* `fallbacks`_
* `validation`_
* `cache`_
* `enable_annotations`_
Expand Down Expand Up @@ -526,10 +526,19 @@ enabled

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

fallback
........
.. _fallback:

**type**: ``string`` **default**: ``en``
fallbacks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a label for the old name before the headline:

.. _fallback:

.........

**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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @aitboudad. I missed this first. Can you please move the versionadded below the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain more ? :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "type: string|array default: array('en')" line should just be before the versionadded directive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done !


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

Expand Down Expand Up @@ -676,7 +685,7 @@ Full default Configuration
# translator configuration
translator:
enabled: false
fallback: en
fallbacks: [en]

# validation configuration
validation:
Expand Down