Catalogue
3 years ago
Command
3 years ago
DataCollector
3 years ago
DependencyInjection
3 years ago
Dumper
3 years ago
Exception
3 years ago
Extractor
3 years ago
Formatter
3 years ago
Loader
3 years ago
Provider
3 years ago
Reader
3 years ago
Resources
3 years ago
Test
3 years ago
Util
3 years ago
Writer
3 years ago
DataCollectorTranslator.php
3 years ago
IdentityTranslator.php
3 years ago
LoggingTranslator.php
3 years ago
MessageCatalogue.php
3 years ago
MessageCatalogueInterface.php
3 years ago
MetadataAwareInterface.php
3 years ago
PseudoLocalizationTranslator.php
3 years ago
TranslatableMessage.php
3 years ago
Translator.php
3 years ago
TranslatorBag.php
3 years ago
TranslatorBagInterface.php
3 years 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 IAWP_SCOPED\Symfony\Component\Translation; |
| 12 | |
| 13 | use IAWP_SCOPED\Symfony\Contracts\Translation\TranslatableInterface; |
| 14 | use IAWP_SCOPED\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 |