Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

TranslationCollectorPass.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler;
8
9 use eZ\Bundle\EzPublishCoreBundle\Translation\GlobCollector;
10 use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
11 use Symfony\Component\DependencyInjection\ContainerBuilder;
12
16 class TranslationCollectorPass implements CompilerPassInterface
17 {
18 const ORIGINAL_TRANSLATION = 'en';
19
21 public const LOCALES_MAP = [
22 'de_DE' => 'de',
23 'el_GR' => 'el',
24 'es_ES' => 'es',
25 'fi_FI' => 'fi',
26 'fr_FR' => 'fr',
27 'hi_IN' => 'hi',
28 'hr_HR' => 'hr',
29 'hu_HU' => 'hu',
30 'it_IT' => 'it',
31 'ja_JP' => 'ja',
32 'nb_NO' => 'nb',
33 'pl_PL' => 'pl',
34 'pt_PT' => 'pt',
35 'ru_RU' => 'ru',
36 ];
37
38 public function process(ContainerBuilder $container)
39 {
40 if (!$container->hasDefinition('translator.default')) {
41 return;
42 }
43
44 $collector = new GlobCollector($container->getParameterBag()->get('kernel.root_dir'));
45
46 $availableTranslations = [self::ORIGINAL_TRANSLATION];
47 foreach ($collector->collect() as $file) {
48 /* TODO - to remove when translation files will have proper names. */
49 if (isset(self::LOCALES_MAP[$file['locale']])) {
50 $file['locale'] = self::LOCALES_MAP[$file['locale']];
51 }
52 $availableTranslations[] = $file['locale'];
53 }
54
55 $container->setParameter('available_translations', array_values(array_unique($availableTranslations)));
56 }
57 }
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\TranslationCollectorPass
This compilation pass loads every ezplatform available translations into symfony translator.
Definition: TranslationCollectorPass.php:17
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\TranslationCollectorPass\process
process(ContainerBuilder $container)
Definition: TranslationCollectorPass.php:38
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\TranslationCollectorPass\LOCALES_MAP
const LOCALES_MAP
Definition: TranslationCollectorPass.php:21
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\TranslationCollectorPass\ORIGINAL_TRANSLATION
const ORIGINAL_TRANSLATION
Definition: TranslationCollectorPass.php:18
eZ\Bundle\EzPublishCoreBundle\Translation\GlobCollector
Retrieves all installed ezplatform translation files ie those installed as ezsystems/ezplatform-i18n-...
Definition: GlobCollector.php:13
eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler
Definition: AsseticPass.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.