CsvFileDumper.php
1 month ago
DumperInterface.php
2 years ago
FileDumper.php
1 month ago
IcuResFileDumper.php
1 month ago
IniFileDumper.php
1 month ago
JsonFileDumper.php
1 month ago
MoFileDumper.php
1 month ago
PhpFileDumper.php
1 month ago
PoFileDumper.php
1 month ago
QtFileDumper.php
1 month ago
XliffFileDumper.php
1 month ago
YamlFileDumper.php
1 month ago
JsonFileDumper.php
38 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 IAWPSCOPED\Symfony\Component\Translation\Dumper; |
| 12 | |
| 13 | use IAWPSCOPED\Symfony\Component\Translation\MessageCatalogue; |
| 14 | /** |
| 15 | * JsonFileDumper generates an json formatted string representation of a message catalogue. |
| 16 | * |
| 17 | * @author singles |
| 18 | * @internal |
| 19 | */ |
| 20 | class JsonFileDumper extends FileDumper |
| 21 | { |
| 22 | /** |
| 23 | * {@inheritdoc} |
| 24 | */ |
| 25 | public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []) : string |
| 26 | { |
| 27 | $flags = $options['json_encoding'] ?? \JSON_PRETTY_PRINT; |
| 28 | return \json_encode($messages->all($domain), $flags); |
| 29 | } |
| 30 | /** |
| 31 | * {@inheritdoc} |
| 32 | */ |
| 33 | protected function getExtension() : string |
| 34 | { |
| 35 | return 'json'; |
| 36 | } |
| 37 | } |
| 38 |