Catalogue
2 months ago
Command
2 months ago
DataCollector
2 months ago
DependencyInjection
2 months ago
Dumper
2 months ago
Exception
2 months ago
Extractor
2 months ago
Formatter
2 months ago
Loader
2 months ago
Provider
2 months ago
Reader
2 months ago
Resources
2 months ago
Util
2 months ago
Writer
2 months ago
DataCollectorTranslator.php
2 months ago
IdentityTranslator.php
2 months ago
LoggingTranslator.php
2 months ago
MessageCatalogue.php
2 months ago
MessageCatalogueInterface.php
2 months ago
MetadataAwareInterface.php
2 months ago
PseudoLocalizationTranslator.php
2 months ago
TranslatableMessage.php
2 months ago
Translator.php
2 months ago
TranslatorBag.php
2 months ago
TranslatorBagInterface.php
2 months ago
TranslatableMessage.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | namespace ProfilePressVendor\Symfony\Component\Translation; |
| 12 | |
| 13 | use ProfilePressVendor\Symfony\Contracts\Translation\TranslatableInterface; |
| 14 | use ProfilePressVendor\Symfony\Contracts\Translation\TranslatorInterface; |
| 15 | /** |
| 16 | * @author Nate Wiebe <nate@northern.co> |
| 17 | */ |
| 18 | class TranslatableMessage implements TranslatableInterface |
| 19 | { |
| 20 | private $message; |
| 21 | private $parameters; |
| 22 | private $domain; |
| 23 | public function __construct(string $message, array $parameters = [], ?string $domain = null) |
| 24 | { |
| 25 | $this->message = $message; |
| 26 | $this->parameters = $parameters; |
| 27 | $this->domain = $domain; |
| 28 | } |
| 29 | public function __toString(): string |
| 30 | { |
| 31 | return $this->getMessage(); |
| 32 | } |
| 33 | public function getMessage(): string |
| 34 | { |
| 35 | return $this->message; |
| 36 | } |
| 37 | public function getParameters(): array |
| 38 | { |
| 39 | return $this->parameters; |
| 40 | } |
| 41 | public function getDomain(): ?string |
| 42 | { |
| 43 | return $this->domain; |
| 44 | } |
| 45 | public function trans(TranslatorInterface $translator, ?string $locale = null): string |
| 46 | { |
| 47 | return $translator->trans($this->getMessage(), array_map(static function ($parameter) use ($translator, $locale) { |
| 48 | return $parameter instanceof TranslatableInterface ? $parameter->trans($translator, $locale) : $parameter; |
| 49 | }, $this->getParameters()), $this->getDomain(), $locale); |
| 50 | } |
| 51 | } |
| 52 |