Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Translation\Dumper; Chris@0: Chris@0: use Symfony\Component\Translation\MessageCatalogue; Chris@0: Chris@0: /** Chris@0: * JsonFileDumper generates an json formatted string representation of a message catalogue. Chris@0: * Chris@0: * @author singles Chris@0: */ Chris@0: class JsonFileDumper extends FileDumper Chris@0: { Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@17: public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) Chris@0: { Chris@0: if (isset($options['json_encoding'])) { Chris@0: $flags = $options['json_encoding']; Chris@0: } else { Chris@17: $flags = \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0; Chris@0: } Chris@0: Chris@0: return json_encode($messages->all($domain), $flags); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: protected function getExtension() Chris@0: { Chris@0: return 'json'; Chris@0: } Chris@0: }