diff --git a/Loader/XliffFileLoader.php b/Loader/XliffFileLoader.php
index 31b3251b..ffe4bbbd 100644
--- a/Loader/XliffFileLoader.php
+++ b/Loader/XliffFileLoader.php
@@ -112,16 +112,20 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, s
continue;
}
- if (isset($translation->target) && 'needs-translation' === (string) $translation->target->attributes()['state']) {
+ $source = (string) (isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source);
+
+ if (isset($translation->target)
+ && 'needs-translation' === (string) $translation->target->attributes()['state']
+ && \in_array((string) $translation->target, [$source, (string) $translation->source], true)
+ ) {
continue;
}
- $source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source;
// If the xlf file has another encoding specified, try to convert it because
// simple_xml will always return utf-8 encoded values
$target = $this->utf8ToCharset((string) ($translation->target ?? $translation->source), $encoding);
- $catalogue->set((string) $source, $target, $domain);
+ $catalogue->set($source, $target, $domain);
$metadata = [
'source' => (string) $translation->source,
@@ -144,7 +148,7 @@ private function extractXliff1(\DOMDocument $dom, MessageCatalogue $catalogue, s
$metadata['id'] = (string) $attributes['id'];
}
- $catalogue->setMetadata((string) $source, $metadata, $domain);
+ $catalogue->setMetadata($source, $metadata, $domain);
}
}
}
diff --git a/Resources/bin/translation-status.php b/Resources/bin/translation-status.php
index 8064190d..42fa1c69 100644
--- a/Resources/bin/translation-status.php
+++ b/Resources/bin/translation-status.php
@@ -162,11 +162,11 @@ function extractLocaleFromFilePath($filePath)
function extractTranslationKeys($filePath): array
{
$translationKeys = [];
- $contents = new \SimpleXMLElement(file_get_contents($filePath));
+ $contents = new SimpleXMLElement(file_get_contents($filePath));
foreach ($contents->file->body->{'trans-unit'} as $translationKey) {
$translationId = (string) $translationKey['id'];
- $translationKey = (string) $translationKey->source;
+ $translationKey = (string) ($translationKey['resname'] ?? $translationKey->source);
$translationKeys[$translationId] = $translationKey;
}
diff --git a/Tests/Loader/XliffFileLoaderTest.php b/Tests/Loader/XliffFileLoaderTest.php
index b64b6f95..d8a08bbb 100644
--- a/Tests/Loader/XliffFileLoaderTest.php
+++ b/Tests/Loader/XliffFileLoaderTest.php
@@ -52,9 +52,17 @@ public function testLoadRawXliff()
- with
+ with
note
+
+
+ baz
+
+
+
+ buz
+