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;
/**
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) {
}
}
+ if (isset($attributes['id'])) {
+ $metadata['id'] = (string) $attributes['id'];
+ }
+
$catalogue->setMetadata((string) $source, $metadata, $domain);
}
}
* @param \DOMDocument $dom
* @param string $schema source of the schema
*
- * @throws \RuntimeException
* @throws InvalidResourceException
*/
private function validateSchema($file, \DOMDocument $dom, $schema)
$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);
$parts = explode('/', str_replace('\\', '/', $tmpfile));
}
}
+
$drive = '\\' === DIRECTORY_SEPARATOR ? array_shift($parts).'/' : '';
$newPath = 'file:///'.$drive.implode('/', array_map('rawurlencode', $parts));
*
* @param \DOMDocument $dom
*
- * @throws \InvalidArgumentException
+ * @throws InvalidArgumentException
*
* @return string
*/
$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);
return '1.2';
}
- /*
+ /**
* @param \SimpleXMLElement|null $noteElement
* @param string|null $encoding
*
return $notes;
}
+ /** @var \SimpleXMLElement $xmlNote */
foreach ($noteElement as $xmlNote) {
$noteAttributes = $xmlNote->attributes();
$note = array('content' => $this->utf8ToCharset((string) $xmlNote, $encoding));