package and depencies
This commit is contained in:
@@ -28,10 +28,7 @@ use Symfony\Component\Translation\Util\XliffUtils;
|
||||
*/
|
||||
class XliffFileLoader implements LoaderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load($resource, string $locale, string $domain = 'messages')
|
||||
public function load(mixed $resource, string $locale, string $domain = 'messages'): MessageCatalogue
|
||||
{
|
||||
if (!class_exists(XmlUtils::class)) {
|
||||
throw new RuntimeException('Loading translations from the Xliff format requires the Symfony Config component.');
|
||||
@@ -104,6 +101,10 @@ class XliffFileLoader implements LoaderInterface
|
||||
|
||||
$file->registerXPathNamespace('xliff', $namespace);
|
||||
|
||||
foreach ($file->xpath('.//xliff:prop') as $prop) {
|
||||
$catalogue->setCatalogueMetadata($prop->attributes()['prop-type'], (string) $prop, $domain);
|
||||
}
|
||||
|
||||
foreach ($file->xpath('.//xliff:trans-unit') as $translation) {
|
||||
$attributes = $translation->attributes();
|
||||
|
||||
@@ -227,6 +228,6 @@ class XliffFileLoader implements LoaderInterface
|
||||
|
||||
private function isXmlString(string $resource): bool
|
||||
{
|
||||
return 0 === strpos($resource, '<?xml');
|
||||
return str_starts_with($resource, '<?xml');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user