You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
895 B

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Dumper;
  11. use Symfony\Component\Translation\MessageCatalogue;
  12. /**
  13. * JsonFileDumper generates an json formatted string representation of a message catalogue.
  14. *
  15. * @author singles
  16. */
  17. class JsonFileDumper extends FileDumper
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = [])
  23. {
  24. $flags = $options['json_encoding'] ?? \JSON_PRETTY_PRINT;
  25. return json_encode($messages->all($domain), $flags);
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. protected function getExtension()
  31. {
  32. return 'json';
  33. }
  34. }