summaryrefslogtreecommitdiffstats
path: root/Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
diff options
context:
space:
mode:
authorStefan Suhren <suhren.stefan@fh-swf.de>2015-05-11 15:02:33 +0200
committerStefan Suhren <suhren.stefan@fh-swf.de>2015-05-11 15:02:33 +0200
commita7e17cb70e9306f8887bd2b5ca1a37edcbe3ea0f (patch)
treebf6e04c9bdba66e249fd6b78391e132da130848c /Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
parentea3fed0df4eaedd820f3f405502b62efe5952f8f (diff)
downloadInternetTechnologien-a7e17cb70e9306f8887bd2b5ca1a37edcbe3ea0f.tar.gz
InternetTechnologien-a7e17cb70e9306f8887bd2b5ca1a37edcbe3ea0f.zip
Let composer manage its own files
Diffstat (limited to 'Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php')
-rw-r--r--Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php109
1 files changed, 0 insertions, 109 deletions
diff --git a/Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php b/Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
deleted file mode 100644
index 58d1973..0000000
--- a/Aufgabe06/vendor/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php
+++ /dev/null
@@ -1,109 +0,0 @@
-<?php
-
-/*
- * This file is part of the Symfony package.
- *
- * (c) Fabien Potencier <fabien@symfony.com>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Symfony\Component\Translation\Dumper;
-
-use Symfony\Component\Translation\MessageCatalogue;
-
-/**
- * XliffFileDumper generates xliff files from a message catalogue.
- *
- * @author Michel Salib <michelsalib@hotmail.com>
- */
-class XliffFileDumper extends FileDumper
-{
- /**
- * @var string
- */
- private $defaultLocale;
-
- /**
- * {@inheritdoc}
- */
- public function dump(MessageCatalogue $messages, $options = array())
- {
- if (array_key_exists('default_locale', $options)) {
- $this->defaultLocale = $options['default_locale'];
- } else {
- $this->defaultLocale = \Locale::getDefault();
- }
-
- parent::dump($messages, $options);
- }
-
- /**
- * {@inheritdoc}
- */
- protected function format(MessageCatalogue $messages, $domain)
- {
- $dom = new \DOMDocument('1.0', 'utf-8');
- $dom->formatOutput = true;
-
- $xliff = $dom->appendChild($dom->createElement('xliff'));
- $xliff->setAttribute('version', '1.2');
- $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');
-
- $xliffFile = $xliff->appendChild($dom->createElement('file'));
- $xliffFile->setAttribute('source-language', str_replace('_', '-', $this->defaultLocale));
- $xliffFile->setAttribute('target-language', str_replace('_', '-', $messages->getLocale()));
- $xliffFile->setAttribute('datatype', 'plaintext');
- $xliffFile->setAttribute('original', 'file.ext');
-
- $xliffBody = $xliffFile->appendChild($dom->createElement('body'));
- foreach ($messages->all($domain) as $source => $target) {
- $translation = $dom->createElement('trans-unit');
-
- $translation->setAttribute('id', md5($source));
- $translation->setAttribute('resname', $source);
-
- $s = $translation->appendChild($dom->createElement('source'));
- $s->appendChild($dom->createTextNode($source));
-
- // Does the target contain characters requiring a CDATA section?
- $text = 1 === preg_match('/[&<>]/', $target) ? $dom->createCDATASection($target) : $dom->createTextNode($target);
-
- $t = $translation->appendChild($dom->createElement('target'));
- $t->appendChild($text);
-
- $metadata = $messages->getMetadata($source, $domain);
- if (null !== $metadata && array_key_exists('notes', $metadata) && is_array($metadata['notes'])) {
- foreach ($metadata['notes'] as $note) {
- if (!isset($note['content'])) {
- continue;
- }
-
- $n = $translation->appendChild($dom->createElement('note'));
- $n->appendChild($dom->createTextNode($note['content']));
-
- if (isset($note['priority'])) {
- $n->setAttribute('priority', $note['priority']);
- }
-
- if (isset($note['from'])) {
- $n->setAttribute('from', $note['from']);
- }
- }
- }
-
- $xliffBody->appendChild($translation);
- }
-
- return $dom->saveXML();
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getExtension()
- {
- return 'xlf';
- }
-}