/** * {@inheritdoc} */ public function getTranslation($locale) { $locale = strtolower($locale); if (isset($this->cacheTranslation[$locale])) { return $this->cacheTranslation[$locale]; } /* @var \Sonatra\Bundle\MailerBundle\Model\LayoutInterface|\Sonatra\Bundle\MailerBundle\Model\MailInterface|TranslationTrait $this */ $self = clone $this; if (!TranslationUtil::find($self, $locale) && false !== ($pos = strrpos($locale, '_'))) { TranslationUtil::find($self, substr($locale, 0, $pos)); } $this->cacheTranslation[$locale] = $self; return $self; }
/** * Get the translated layout of mail. * * @param MailInterface $mail The mail * * @return LayoutInterface|null */ protected function getTranslatedLayout(MailInterface $mail) { $layout = $mail->getLayout(); if (null !== $layout) { $layout = TranslationUtil::translateLayout($layout, $this->getLocale(), $this->translator); } return $layout; }
/** * Get the translated layout. * * @param string $layout The name of layout * * @return TwigLayout * * @throws UnknownLayoutException When the layout template does not exist * @throws InvalidArgumentException When the layout is not a twig layout */ public function getTranslatedLayout($layout) { $template = $this->layoutLoader->load($layout); $template = TranslationUtil::translateLayout($template, $this->getTemplater()->getLocale(), $this->translator); if (!$template instanceof TwigLayout) { $msg = 'The "%s" layout is not a twig layout'; throw new InvalidArgumentException(sprintf($msg, $layout)); } return $template; }