Replace the default translator class with our own (if configured) to support `/zz/` browsing
{@inheritdoc}

@see \Zicht\Bundle\FrameworkExtraBundle\Translation\Translator
165439
public function process(ContainerBuilder $container)
    {
        if (class_exists(BaseTranslator::class) && $container->hasDefinition('translator.default')
            && $container->hasParameter('translator.class')) {
            $class = $container->getParameter('translator.class');
            $definition = $container->getDefinition('translator.default');
            $definition->setClass($class);
        }
    }
331096
public static function GetInstance() : Translator
   {

      if ( null === self::$_instance )
      {
         self::$_instance = new Translator();
      }

      return self::$_instance;

   }
297511
protected function generateTranslation()
    {
        $name = $this->qualifyClass($this->getNameInput());
        $path = $this->getTranslationPath($name);

        $this->makeDirectory($path);
        $this->files->put($path, $this->buildTranslation($name));

        $this->info('Translation also generated successfully.');
        $this->warn($path);
    }
979699
public function createTranslator($locale, $class = null, $cacheDir = null, $debug = false)
    {
        if (null === $class) {
            $class = '\Symfony\Component\Translation\Translator';
        }
        if (null === $locale) {
            $locale = 'en';
        }
        /** @var Translator $translator */
        $translator = new $class($locale, null, $cacheDir, $debug);
        $translator->addLoader('xml', new XliffFileLoader());
        $configuration = new SanityCheckConfiguration();
        $translations = $configuration->getTranslationResources();
        foreach ($translations as $locale => $resources) {
            foreach ($resources as $resource) {
                $translator->addResource('xml', $resource, $locale, 'chameleon_system_sanitycheck');
            }
        }

        return $translator;
    }
355308
public function addTranslationFunctions($twig)
    {
        $twig->addFunction('_x', new Twig_SimpleFunction('_x',
            function ($text, $context, $domain = 'default') {
                return _x($text, $context, $domain);
            }
        ));

        $twig->addFunction('_n', new Twig_SimpleFunction('_n',
            function ($single, $plural, $number, $domain = 'default') {
                return _n($single, $plural, $number, $domain);
            }
        ));

        $twig->addFunction('_nx', new Twig_SimpleFunction('_nx',
            function ($single, $plural, $number, $context, $domain = 'default') {
                return _nx($single, $plural, $number, $context, $domain);
            }
        ));

        return $twig;
    }
644899
protected function setDefault($default)
    {
        if ($this->isNullable() && $default === null) {
            $this->default = 'null';

            return $this;
        }

        if ($default === null) {
            $this->default = '';

            return $this;
        }

        switch ($this->getType()->getType()) {
            case 'string':
                $this->default = "'" . $default . "'";
                break;
            case 'bool':
                $this->default = var_export((bool) $default, true);
                break;
            default:
                $this->default = $default;
        }

        return $this;
    }
290338
public function getLang(): ?Translator
    {
        if (!$this->hasLang()) {
            $this->setLang($this->getDefaultLang());
        }
        return $this->lang;
    }
1277332
public function initialize(TranslatorInterface $translator)
    {
        $event = new CreateTranslatorEvent($translator);
        $this->eventDispatcher->dispatch($event::NAME, $event);

        return $translator;
    }
556871
public function getTranslator()
    {
        if ($this->translatorIsDisabled()) {
            return null;
        }

        if (null === $this->_translator) {
            return self::getDefaultTranslator();
        }

        return $this->_translator;
    }
342741
protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty)
    {
        switch ($relativePath) {
            case '':
                $directoryAlternatives = array('application/config/generated_overrides', 'application/config', 'concrete/config');
                break;
            case 'application':
                $directoryAlternatives = array('config/generated_overrides', 'config');
                break;
            case 'concrete':
                $directoryAlternatives = array('config');
                break;
            default:
                return;
        }
        $prefix = ($relativePath === '') ? '' : "$relativePath/";
        $this->parseFileTypes($translations, $rootDirectory, $prefix, $directoryAlternatives);
        $this->parseTranslatableStrings($translations, $rootDirectory, $prefix, $directoryAlternatives);
    }
306666
private function getTranslation()
    {
        $filterTranslation = null;
        foreach ($this->entity->getTranslations() as $translation) {
            if ($translation->getLocale() == $this->locale) {
                $filterTranslation = $translation;
            }
        }
        if (!$filterTranslation) {
            $filterTranslation = new FilterTranslation();
            $filterTranslation->setLocale($this->locale);
            $filterTranslation->setFilter($this->entity);
            $this->entity->addTranslation($filterTranslation);
        }

        return $filterTranslation;
    }
188766
protected function translate($name)
    {
        preg_match_all('/^(?P<bundle>[^:]+):(?P<directory>[^:]*:)?(?P<file>.+)$/', $name, $matches, \PREG_SET_ORDER);

        foreach (['bundle', 'file'] as $offset) {
            if (empty($matches[0][$offset])) {
                throw new ViewException(sprintf('Invalid or missing "%s" node in view filename "%s"', $offset, $name));
            }
        }

        $placeholders = [
            '{bundle}' => $matches[0]['bundle'],
            '{file}' => $matches[0]['file'],
            '{directory}' => isset($matches[0]['directory']) ? str_replace(':', '\\', $matches[0]['directory']) : null,
        ];

        $file = strtr($this->pattern, $placeholders);
        $file = str_replace(array('\\', '_', '//'), '/', $file);

        return $file;
    }
4402
public function translator(string $locale, string $domain, string $directory): ?TranslatorInterface
    {
        $class = GETTEXT_EXTENSION ? GettextTranslator::class : Translator::class;

        $previous = self::$translator;
        self::$translator = new $class($locale, $domain, $directory);

        if ($previous === null) {
            require __DIR__ . DIRECTORY_SEPARATOR . 'helpers.php';
        }

        $this->locale = $locale;

        return $previous;
    }
1237997
protected function translate($key, $default = false)
    {
        $string = $this->translator->get($key);

        if ($default !== false) {
            if ($string == $key) {
                return $default;
            }
        }

        return $string;
    }
299223
public function replace($search, $replace): ClassDeclaration
    {
        $this->constants->replace($search, $replace);
        $this->properties->replace($search, $replace);
        $this->methods->replace($search, $replace);

        return $this;
    }
50267
public function setTranslator($translator = null)
    {
        if (!$translator instanceof Translator && !$translator instanceof \Zend\I18n\Translator\TranslatorInterface) {
            throw new \InvalidArgumentException('Translator must be an instanceof "Zend\I18n\Translator\Translator" or "Zend\I18n\Translator\TranslatorInterface"');
        }

        $this->translator = $translator;
    }
938631
public function localized($language = null)
    {
        if (!$language){
            $language = Yii::$app->language;
        }
            
        if (!isset($this->with['translations'])) {
            $this->with(['translation' => function ($query) use ($language) {
                $query->where([$this->languageField => $language]);
            }]);
        }

        return $this;
    }