@@ -321,14 +321,6 @@ use for translation::
321321 'fr_FR'
322322 );
323323
324- $translator->transChoice(
325- '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
326- 10,
327- [],
328- 'messages',
329- 'fr_FR'
330- );
331-
332324Extracting Translation Contents and Updating Catalogs Automatically
333325-------------------------------------------------------------------
334326
@@ -478,56 +470,60 @@ to learn more about how to handle it.
478470Fallback Translation Locales
479471----------------------------
480472
481- Imagine that the user's locale is ``fr_FR `` and that you're translating the
482- key ``Symfony is great ``. To find the French translation, Symfony actually
473+ Imagine that the user's locale is ``es_AR `` and that you're translating the
474+ key ``Symfony is great ``. To find the Spanish translation, Symfony actually
483475checks translation resources for several locales:
484476
485- #. First, Symfony looks for the translation in a ``fr_FR `` translation resource
486- (e.g. ``messages.fr_FR.xlf ``);
477+ #. First, Symfony looks for the translation in a ``es_AR `` (Argentinean
478+ Spanish) translation resource (e.g. ``messages.es_AR.yaml ``);
479+
480+ #. If it wasn't found, Symfony looks for the translation in the
481+ parent locale, which is automatically defined only for some locales. In
482+ this example, the parent locale is ``es_419 `` (Latin American Spanish);
487483
488- #. If it wasn't found, Symfony looks for the translation in a ``fr `` translation
489- resource (e.g. ``messages.fr.xlf ``);
484+ #. If it wasn't found, Symfony looks for the translation in a ``es ``
485+ (Spanish) translation resource (e.g. ``messages.es.yaml ``);
490486
491487#. If the translation still isn't found, Symfony uses the ``fallbacks `` option,
492488 which can be configured as follows:
493489
494- .. configuration-block ::
490+ .. configuration-block ::
495491
496- .. code-block :: yaml
492+ .. code-block :: yaml
497493
498- # config/packages/translation.yaml
499- framework :
500- translator :
501- fallbacks : ['en']
502- # ...
494+ # config/packages/translation.yaml
495+ framework :
496+ translator :
497+ fallbacks : ['en']
498+ # ...
503499
504- .. code-block :: xml
500+ .. code-block :: xml
505501
506- <!-- config/packages/translation.xml -->
507- <?xml version =" 1.0" encoding =" UTF-8" ?>
508- <container xmlns =" http://symfony.com/schema/dic/services"
509- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
510- xmlns : framework =" http://symfony.com/schema/dic/symfony"
511- xsi : schemaLocation =" http://symfony.com/schema/dic/services
512- https://symfony.com/schema/dic/services/services-1.0.xsd
513- http://symfony.com/schema/dic/symfony
514- https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
502+ <!-- config/packages/translation.xml -->
503+ <?xml version =" 1.0" encoding =" UTF-8" ?>
504+ <container xmlns =" http://symfony.com/schema/dic/services"
505+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
506+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
507+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
508+ https://symfony.com/schema/dic/services/services-1.0.xsd
509+ http://symfony.com/schema/dic/symfony
510+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
515511
516- <framework : config >
517- <framework : translator >
518- <framework : fallback >en</framework : fallback >
519- <!-- ... -->
520- </framework : translator >
521- </framework : config >
522- </container >
512+ <framework : config >
513+ <framework : translator >
514+ <framework : fallback >en</framework : fallback >
515+ <!-- ... -->
516+ </framework : translator >
517+ </framework : config >
518+ </container >
523519
524- .. code-block :: php
520+ .. code-block :: php
525521
526- // config/packages/translation.php
527- $container->loadFromExtension('framework', [
528- 'translator' => ['fallbacks' => ['en']],
529- // ...
530- ]);
522+ // config/packages/translation.php
523+ $container->loadFromExtension('framework', [
524+ 'translator' => ['fallbacks' => ['en']],
525+ // ...
526+ ]);
531527
532528 .. note ::
533529
@@ -582,7 +578,6 @@ Learn more
582578.. _`i18n` : https://en.wikipedia.org/wiki/Internationalization_and_localization
583579.. _`ICU MessageFormat` : http://userguide.icu-project.org/formatparse/messages
584580.. _`ISO 3166-1 alpha-2` : https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
585- .. _`ISO 31-11` : https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals
586581.. _`ISO 639-1` : https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
587582.. _`Translatable Extension` : http://atlantic18.github.io/DoctrineExtensions/doc/translatable.html
588583.. _`Translatable Behavior` : https://github.com/KnpLabs/DoctrineBehaviors
0 commit comments