aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 19:26:54 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-03 19:26:54 +0200
commit4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch)
tree6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
parent2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff)
downloadwallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz
wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst
wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip
twig implementation
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php')
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
new file mode 100644
index 00000000..0d258aad
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
@@ -0,0 +1,66 @@
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 * XliffFileDumper generates xliff files from a message catalogue.
18 *
19 * @author Michel Salib <michelsalib@hotmail.com>
20 */
21class XliffFileDumper extends FileDumper
22{
23 /**
24 * {@inheritDoc}
25 */
26 protected function format(MessageCatalogue $messages, $domain)
27 {
28 $dom = new \DOMDocument('1.0', 'utf-8');
29 $dom->formatOutput = true;
30
31 $xliff = $dom->appendChild($dom->createElement('xliff'));
32 $xliff->setAttribute('version', '1.2');
33 $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
34
35 $xliffFile = $xliff->appendChild($dom->createElement('file'));
36 $xliffFile->setAttribute('source-language', $messages->getLocale());
37 $xliffFile->setAttribute('datatype', 'plaintext');
38 $xliffFile->setAttribute('original', 'file.ext');
39
40 $xliffBody = $xliffFile->appendChild($dom->createElement('body'));
41 foreach ($messages->all($domain) as $source => $target) {
42 $translation = $dom->createElement('trans-unit');
43
44 $translation->setAttribute('id', md5($source));
45 $translation->setAttribute('resname', $source);
46
47 $s = $translation->appendChild($dom->createElement('source'));
48 $s->appendChild($dom->createTextNode($source));
49
50 $t = $translation->appendChild($dom->createElement('target'));
51 $t->appendChild($dom->createTextNode($target));
52
53 $xliffBody->appendChild($translation);
54 }
55
56 return $dom->saveXML();
57 }
58
59 /**
60 * {@inheritDoc}
61 */
62 protected function getExtension()
63 {
64 return 'xlf';
65 }
66}