@@ -321,14 +321,6 @@ use for translation::
321
321
'fr_FR'
322
322
);
323
323
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
-
332
324
Extracting Translation Contents and Updating Catalogs Automatically
333
325
-------------------------------------------------------------------
334
326
@@ -478,56 +470,60 @@ to learn more about how to handle it.
478
470
Fallback Translation Locales
479
471
----------------------------
480
472
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
483
475
checks translation resources for several locales:
484
476
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);
487
483
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 ``);
490
486
491
487
#. If the translation still isn't found, Symfony uses the ``fallbacks `` option,
492
488
which can be configured as follows:
493
489
494
- .. configuration-block ::
490
+ .. configuration-block ::
495
491
496
- .. code-block :: yaml
492
+ .. code-block :: yaml
497
493
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
+ # ...
503
499
504
- .. code-block :: xml
500
+ .. code-block :: xml
505
501
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" >
515
511
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 >
523
519
524
- .. code-block :: php
520
+ .. code-block :: php
525
521
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
+ ]);
531
527
532
528
.. note ::
533
529
@@ -582,7 +578,6 @@ Learn more
582
578
.. _`i18n` : https://en.wikipedia.org/wiki/Internationalization_and_localization
583
579
.. _`ICU MessageFormat` : http://userguide.icu-project.org/formatparse/messages
584
580
.. _`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
586
581
.. _`ISO 639-1` : https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
587
582
.. _`Translatable Extension` : http://atlantic18.github.io/DoctrineExtensions/doc/translatable.html
588
583
.. _`Translatable Behavior` : https://github.com/KnpLabs/DoctrineBehaviors
0 commit comments