No Description

JsonFileDumper.php 893B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. if (!defined('JSON_PRETTY_PRINT')) {
  13. define('JSON_PRETTY_PRINT', 128);
  14. }
  15. /**
  16. * JsonFileDumper generates an json formatted string representation of a message catalogue.
  17. *
  18. * @author singles
  19. */
  20. class JsonFileDumper extends FileDumper
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function format(MessageCatalogue $messages, $domain = 'messages')
  26. {
  27. return json_encode($messages->all($domain), JSON_PRETTY_PRINT);
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. protected function getExtension()
  33. {
  34. return 'json';
  35. }
  36. }