]> git.immae.eu Git - github/wallabag/wallabag.git/blame - vendor/symfony/translation/Symfony/Component/Translation/Dumper/QtFileDumper.php
gitignore vendor
[github/wallabag/wallabag.git] / vendor / symfony / translation / Symfony / Component / Translation / Dumper / QtFileDumper.php
CommitLineData
4f5b44bd
NL
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\Dumper;
13
14use Symfony\Component\Translation\MessageCatalogue;
15
16/**
17 * QtFileDumper generates ts files from a message catalogue.
18 *
19 * @author Benjamin Eberlei <kontakt@beberlei.de>
20 */
21class QtFileDumper extends FileDumper
22{
23 /**
24 * {@inheritDoc}
25 */
26 public function format(MessageCatalogue $messages, $domain)
27 {
28 $dom = new \DOMDocument('1.0', 'utf-8');
29 $dom->formatOutput = true;
30 $ts = $dom->appendChild($dom->createElement('TS'));
31 $context = $ts->appendChild($dom->createElement('context'));
32 $context->appendChild($dom->createElement('name', $domain));
33
34 foreach ($messages->all($domain) as $source => $target) {
35 $message = $context->appendChild($dom->createElement('message'));
36 $message->appendChild($dom->createElement('source', $source));
37 $message->appendChild($dom->createElement('translation', $target));
38 }
39
40 return $dom->saveXML();
41 }
42
43 /**
44 * {@inheritDoc}
45 */
46 protected function getExtension()
47 {
48 return 'ts';
49 }
50}