X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fsymfony%2Ftranslation%2FLoader%2FXliffFileLoader.php;fp=vendor%2Fsymfony%2Ftranslation%2FLoader%2FXliffFileLoader.php;h=e3cab6543744539fc27caee6be8db3b226011661;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=4e2b7c182ba38510fbdd061c2eeb9eb9ea535b7e;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/vendor/symfony/translation/Loader/XliffFileLoader.php b/vendor/symfony/translation/Loader/XliffFileLoader.php index 4e2b7c182..e3cab6543 100644 --- a/vendor/symfony/translation/Loader/XliffFileLoader.php +++ b/vendor/symfony/translation/Loader/XliffFileLoader.php @@ -15,6 +15,7 @@ use Symfony\Component\Config\Util\XmlUtils; use Symfony\Component\Translation\MessageCatalogue; use Symfony\Component\Translation\Exception\InvalidResourceException; use Symfony\Component\Translation\Exception\NotFoundResourceException; +use Symfony\Component\Translation\Exception\InvalidArgumentException; use Symfony\Component\Config\Resource\FileResource; /** @@ -98,6 +99,7 @@ class XliffFileLoader implements LoaderInterface if ($notes = $this->parseNotesMetadata($translation->note, $encoding)) { $metadata['notes'] = $notes; } + if (isset($translation->target) && $translation->target->attributes()) { $metadata['target-attributes'] = array(); foreach ($translation->target->attributes() as $key => $value) { @@ -105,6 +107,10 @@ class XliffFileLoader implements LoaderInterface } } + if (isset($attributes['id'])) { + $metadata['id'] = (string) $attributes['id']; + } + $catalogue->setMetadata((string) $source, $metadata, $domain); } } @@ -166,7 +172,6 @@ class XliffFileLoader implements LoaderInterface * @param \DOMDocument $dom * @param string $schema source of the schema * - * @throws \RuntimeException * @throws InvalidResourceException */ private function validateSchema($file, \DOMDocument $dom, $schema) @@ -198,7 +203,7 @@ class XliffFileLoader implements LoaderInterface $schemaSource = file_get_contents(__DIR__.'/schema/dic/xliff-core/xliff-core-2.0.xsd'); $xmlUri = 'informativeCopiesOf3rdPartySchemas/w3c/xml.xsd'; } else { - throw new \InvalidArgumentException(sprintf('No support implemented for loading XLIFF version "%s".', $xliffVersion)); + throw new InvalidArgumentException(sprintf('No support implemented for loading XLIFF version "%s".', $xliffVersion)); } return $this->fixXmlLocation($schemaSource, $xmlUri); @@ -223,6 +228,7 @@ class XliffFileLoader implements LoaderInterface $parts = explode('/', str_replace('\\', '/', $tmpfile)); } } + $drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : ''; $newPath = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts)); @@ -262,7 +268,7 @@ class XliffFileLoader implements LoaderInterface * * @param \DOMDocument $dom * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return string */ @@ -278,7 +284,7 @@ class XliffFileLoader implements LoaderInterface $namespace = $xliff->attributes->getNamedItem('xmlns'); if ($namespace) { if (substr_compare('urn:oasis:names:tc:xliff:document:', $namespace->nodeValue, 0, 34) !== 0) { - throw new \InvalidArgumentException(sprintf('Not a valid XLIFF namespace "%s"', $namespace)); + throw new InvalidArgumentException(sprintf('Not a valid XLIFF namespace "%s"', $namespace)); } return substr($namespace, 34); @@ -289,7 +295,7 @@ class XliffFileLoader implements LoaderInterface return '1.2'; } - /* + /** * @param \SimpleXMLElement|null $noteElement * @param string|null $encoding * @@ -303,6 +309,7 @@ class XliffFileLoader implements LoaderInterface return $notes; } + /** @var \SimpleXMLElement $xmlNote */ foreach ($noteElement as $xmlNote) { $noteAttributes = $xmlNote->attributes(); $note = array('content' => $this->utf8ToCharset((string) $xmlNote, $encoding));