Exception
1 year ago
Provider
1 year ago
Test
1 year ago
Util
1 year ago
DataCollectorTranslator.php
1 year ago
IdentityTranslator.php
1 year ago
LoggingTranslator.php
1 year ago
MessageCatalogue.php
1 year ago
MessageCatalogueInterface.php
1 year ago
MetadataAwareInterface.php
1 year ago
PseudoLocalizationTranslator.php
1 year ago
TranslatableMessage.php
1 year ago
Translator.php
1 year ago
TranslatorBag.php
1 year ago
TranslatorBagInterface.php
1 year ago
index.php
3 years ago
TranslatableMessage.php
40 lines
| 1 | <?php |
| 2 | namespace MailPoetVendor\Symfony\Component\Translation; |
| 3 | if (!defined('ABSPATH')) exit; |
| 4 | use MailPoetVendor\Symfony\Contracts\Translation\TranslatableInterface; |
| 5 | use MailPoetVendor\Symfony\Contracts\Translation\TranslatorInterface; |
| 6 | class TranslatableMessage implements TranslatableInterface |
| 7 | { |
| 8 | private $message; |
| 9 | private $parameters; |
| 10 | private $domain; |
| 11 | public function __construct(string $message, array $parameters = [], ?string $domain = null) |
| 12 | { |
| 13 | $this->message = $message; |
| 14 | $this->parameters = $parameters; |
| 15 | $this->domain = $domain; |
| 16 | } |
| 17 | public function __toString() : string |
| 18 | { |
| 19 | return $this->getMessage(); |
| 20 | } |
| 21 | public function getMessage() : string |
| 22 | { |
| 23 | return $this->message; |
| 24 | } |
| 25 | public function getParameters() : array |
| 26 | { |
| 27 | return $this->parameters; |
| 28 | } |
| 29 | public function getDomain() : ?string |
| 30 | { |
| 31 | return $this->domain; |
| 32 | } |
| 33 | public function trans(TranslatorInterface $translator, ?string $locale = null) : string |
| 34 | { |
| 35 | return $translator->trans($this->getMessage(), \array_map(static function ($parameter) use($translator, $locale) { |
| 36 | return $parameter instanceof TranslatableInterface ? $parameter->trans($translator, $locale) : $parameter; |
| 37 | }, $this->getParameters()), $this->getDomain(), $locale); |
| 38 | } |
| 39 | } |
| 40 |