4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Dumper;
14 use Symfony\Component\Translation\MessageCatalogue;
15 use Symfony\Component\Translation\Util\ArrayConverter;
16 use Symfony\Component\Yaml\Yaml;
19 * YamlFileDumper generates yaml files from a message catalogue.
21 * @author Michel Salib <michelsalib@hotmail.com>
23 class YamlFileDumper extends FileDumper
28 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
30 if (!class_exists('Symfony\Component\Yaml\Yaml')) {
31 throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
34 $data = $messages->all($domain);
36 if (isset($options['as_tree']) && $options['as_tree']) {
37 $data = ArrayConverter::expandToTree($data);
40 if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) {
41 return Yaml::dump($data, $inline);
44 return Yaml::dump($data);
50 protected function format(MessageCatalogue $messages, $domain)
52 @trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0. Use the formatCatalogue() method instead.', E_USER_DEPRECATED);
54 return $this->formatCatalogue($messages, $domain);
60 protected function getExtension()