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;
17 use Symfony\Component\Translation\Exception\LogicException;
20 * YamlFileDumper generates yaml files from a message catalogue.
22 * @author Michel Salib <michelsalib@hotmail.com>
24 class YamlFileDumper extends FileDumper
29 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
31 if (!class_exists('Symfony\Component\Yaml\Yaml')) {
32 throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
35 $data = $messages->all($domain);
37 if (isset($options['as_tree']) && $options['as_tree']) {
38 $data = ArrayConverter::expandToTree($data);
41 if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) {
42 return Yaml::dump($data, $inline);
45 return Yaml::dump($data);
51 protected function getExtension()