@see TranslatorInterface

{@inheritdoc}
330159
public function npgettext($context, $original, $plural, $value)
    {
        return $this->dnpgettext($this->domain, $context, $original, $plural, $value);
    }
36123
public function viewLog(TranslatorInterface $translator, $id)
    {
        // Find Template
        $log = $this
            ->getDoctrine()
            ->getRepository($this->getParameter('pd_mailer.mail_log_class'))
            ->findOneBy(['id' => $id]);
        if (!$log) throw $this->createNotFoundException();

        $data = [
            $translator->trans('mail_templateid') => $log->getTemplateId(),
            $translator->trans('mail_mid') => $log->getMailId(),
            $translator->trans('mail_to') => implode(PHP_EOL, $this->implodeKeyValue($log->getTo(), ' -> ')),
            $translator->trans('mail_from') => implode(PHP_EOL, $this->implodeKeyValue($log->getFrom(), ' -> ')),
            $translator->trans('mail_subject') => $log->getSubject(),
            $translator->trans('mail_language') => $log->getLanguage(),
            $translator->trans('mail_content_type') => $log->getContentType(),
            $translator->trans('date') => date('Y-m-d H:i:s', $log->getDate()->getTimestamp()),
            $translator->trans('mail_reply_to') => $log->getReplyTo(),
            $translator->trans('mail_header') => '<code>' . str_replace(PHP_EOL, '<br/>', htmlspecialchars($log->getHeader())) . '</code>',
            $translator->trans('mail_status') => $log->getStatus() . ' = ' . $this->swiftEventFilter($translator, $log->getStatus()),
            $translator->trans('mail_exception') => str_replace(PHP_EOL, '<br/>', htmlspecialchars($log->getException())),
        ];

        // JSON Response
        return $this->json($data);
    }
776577
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collPersonImageI18ns) {
                foreach ($this->collPersonImageI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildPersonImageI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildPersonImageI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addPersonImageI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }
1201657
public function remove(TranslatorInterface $translator)
    {
        $hash = spl_object_hash($translator);

        unset($this->translators[$hash]);

        return $this;
    }
949664
private function mapTranslation(ClassMetadata $metadata)
    {
        // In the case A -> B -> TranslationInterface, B might not have mapping defined as it
        // is probably defined in A, so in that case, we just return.
        if (!isset($this->configs[$metadata->name])) {
            return;
        }

        $metadata->mapManyToOne([
            'fieldName'    => 'translatable' ,
            'targetEntity' => $this->configs[$metadata->name],
            'inversedBy'   => 'translations' ,
            'joinColumns'  => [[
                'name'                 => 'translatable_id',
                'referencedColumnName' => 'id',
                'onDelete'             => 'CASCADE',
                'nullable'             => false,
            ]],
        ]);

        if (!$metadata->hasField('locale')) {
            $metadata->mapField([
                'fieldName' => 'locale',
                'type'      => 'string',
                'nullable'  => false,
            ]);
        }

        // Map unique index.
        $columns = [
            $metadata->getSingleAssociationJoinColumnName('translatable'),
            'locale'
        ];

        if (!$this->hasUniqueConstraint($metadata, $columns)) {
            $constraints = isset($metadata->table['uniqueConstraints']) ? $metadata->table['uniqueConstraints'] : [];

            $constraints[$metadata->getTableName().'_uniq_trans'] = [
                'columns' => $columns,
            ];

            $metadata->setPrimaryTable([
                'uniqueConstraints' => $constraints,
            ]);
        }
    }
633805
public function translate($locale) {
		$localeEntity = clone $this;
		$localeEntity->setLocale($locale);
		if(isset($this->data['translations'][$locale]))
			$localeEntity->_set($this->data['translations'][$locale]);
		unset($localeEntity->data['translations'][$locale]);
		$localeEntity->data['translations'][$this->getLocale()] = $this->data['properties'];

		return $localeEntity;
	}
675843
public function translate($id, $params = null, $domain = null, $locale = null) {
		if ($domain === null) {
			$domain = $this->handleDomain($id);
		}
		
		if ($locale === null) {
			$locale = $this->getLocale();
		} else {
			$locale = $this->normalizeLocale($locale);
		}
		
		$translation = $this->getTranslation($id, $domain, $locale, $this->fallbackLocales);
		
		if ($translation === null) {
			return $this->handleFailure($id);
		}
		
		if (! empty($this->plugins)) {
			$translation = $this->handlePlugins($locale, $translation, $params);
		}
		
		if ($params === null) {
			return $translation;
		}
		
		return strtr($translation, $this->normalizeParams($params));
	}
896893
public function dtatransFilter($id)
    {
        $translator = $this->_container->get('translator');
        $callback   = function($id) {
            $path = $this->_container->get('kernel')->locateResource('@AliDatatableBundle/Resources/translations/messages.en.yml');
            return \Symfony\Component\Yaml\Yaml::parse(file_get_contents($path))['ali']['common'][explode('.', $id)[2]];
        };
        return $translator->trans($id) === $id ? $callback($id) : $translator->trans($id);
    }
739952
public function getTranslator($type, array $params = [])
    {
        $result = null;

        if (!isset($params['language'])) {
            throw new \Exception('Need \'language\' param');
        }
        switch ($type) {
            case interfaces\Translator::TRANSLATOR_FILE:
                $result = new FileTranslator();
                if (!isset($params['dir'])) {
                    throw new \Exception('Need \'dir\' param');
                }
                $result->setDir($params['dir']);
                $result->setLanguage($params['language']);
                break;
            case interfaces\Translator::TRANSLATOR_ARRAY:
                $result = new ArrayTranslator();
                if (!isset($params['map'])) {
                    throw new \Exception('Need \'map\' param');
                }
                $result->setMap($params['map']);
                $result->setLanguage($params['language']);
                break;
            case interfaces\Translator::TRANSLATOR_DB:
                $result = new DBTranslator();
                if (!isset($params['aliasFieldName'])) {
                    throw new \Exception('Need \'aliasFieldName\' param');
                }
                if (!isset($params['languageFieldName'])) {
                    throw new \Exception('Need \'languageFieldName\' param');
                }
                if (!isset($params['resultFieldName'])) {
                    throw new \Exception('Need \'resultFieldName\' param');
                }
                if (!isset($params['table'])) {
                    throw new \Exception('Need \'table\' param');
                }
                if (!isset($params['connection'])) {
                    throw new \Exception('Need \'connection\' param');
                }
                $result->setAliasFieldName($params['aliasFieldName']);
                $result->setResultFieldName($params['resultFieldName']);
                $result->setTableName($params['table']);
                $result->setLanguageFieldName($params['languageFieldName']);
                $result->setQueryBuilder(\pwf\basic\db\QueryBuilder::select()
                        ->setConditionBuilder(\pwf\basic\db\QueryBuilder::getConditionBuilder()));
                $result->setConnection(is_string($params['connection']) ? \pwf\basic\Application::$instance->getComponent($params['connection'])
                            : $params['connection']);
                $result->setLanguage($params['language']);
                break;
        }

        return $result;
    }
1362448
public function translate($keyName, array $data = [], ?LocaleTransfer $localeTransfer = null)
    {
        return $this->glossaryFacade->translate($keyName, $data ,$localeTransfer);
    }
165772
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $translationMode = $input->getOption('mode');

        // HOTFIX: translated actually appears to be "translator".
        if ($translationMode == 'translated') {
            $translationMode = 'translator';
        }

        $allLanguages = ($input->getArgument('languages') == 'all');

        $project = new Project($this->getApi());

        $project->setSlug($this->project);

        $resources = $project->getResources();

        foreach ($resources as $resource) {
            $this->handleResource($resource, $translationMode, $allLanguages, $output);
        }
    }
787482
public function translate($language = null, $fallback = true)
    {
        if ($this->relationLoaded('translations')) {
            $this->load('translations');
        }

        return (new Translator($this))->translate($language, $fallback);
    }
281620
public function setTranslator(TranslatorInterface $translator)
    {
        $args = \func_get_args();
        if (isset($args[1]) && $args[1]) {
            @trigger_error(
                'The '.__METHOD__.' method is deprecated since version 3.9 and will be removed in 4.0.',
                E_USER_DEPRECATED
            );
        }

        $this->translator = $translator;
    }
556693
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $services = $serviceLocator->getServiceLocator();
        /* @var $translator \Zend\Mvc\I18n\Translator */
        $translator = $services->get('MvcTranslator');

        return new TranslatePlural($translator);
    }
912134
public static function translateMail(MailInterface $template, $locale, TranslatorInterface $translator = null)
    {
        if (null === $template->getTranslationDomain()) {
            $template = $template->getTranslation($locale);
        } elseif (null !== $translator) {
            static::injectTranslatorValues($translator, $template);
        }

        return $template;
    }
552025
public function addTranslation(string $key, string $translation): MetaboxInterface
    {
        $this->l10n[$key] = $translation;

        return $this;
    }
225724
public function addTranslation(TranslationInterface $translation)
    {
        if (!$this->translations->contains($translation)) {
            $this->translations[$translation->getLocale()] = $translation;
            $translation->setTranslatable($this);
        }
    
        return $this;
    }