Skip to content

Update translator fallback example to include ICU parents #10122

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 2 commits into from
Sep 4, 2018
Merged
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
16 changes: 12 additions & 4 deletions components/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,24 @@ Fallback Locales

If the message is not located in the catalog of the specific locale, the
translator will look into the catalog of one or more fallback locales. For
example, assume you're trying to translate into the ``fr_FR`` locale:
example, assume you're trying to translate into the ``es_AR`` locale:

#. First, the translator looks for the translation in the ``fr_FR`` locale;
#. First, the translator looks for the translation in the ``es_AR``
(Argentinean Spanish) locale;

#. If it wasn't found, the translator looks for the translation in the ``fr``
locale;
#. If it wasn't found, the translator looks for the translation in the parent
locale, which is automatically defined only for some locales. In this
example, the parent locale is ``es_419`` (Latin American Spanish);

#. If it wasn't found, the translator looks for the translation in the ``es``
(Spanish) locale;

#. If the translation still isn't found, the translator uses the one or more
fallback locales set explicitly on the translator.

.. versionadded:: 4.2
The use of parent locales was introduced in Symfony 4.2.

For (3), the fallback locales can be set by calling
:method:`Symfony\\Component\\Translation\\Translator::setFallbackLocales`::

Expand Down