8000 bug #9952 [Translator] Fix Empty translations with Qt files (vlefort) · symfony/symfony@b2d594d · GitHub
[go: up one dir, main page]

Skip to content

Commit b2d594d

Browse files
committed
bug #9952 [Translator] Fix Empty translations with Qt files (vlefort)
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #9952). Discussion ---------- [Translator] Fix Empty translations with Qt files | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | n/a | Fixed tickets | no | License | MIT | Doc PR | When you use ts files, QtLinguist, generate empty string for all translations, even if there are not translated yet. It could be a good idea to generate an entry in the MessageCatalogue only if translation value is not empty. Commits ------- 1c220be [Translator] Fix Empty translations with Qt files
2 parents 3ae496e + 7eacc5a commit b2d594d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Symfony/Component/Translation/Loader/QtFileLoader.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,15 @@ public function load($resource, $locale, $domain = 'messages')
5353
if ($nodes->length == 1) {
5454
$translations = $nodes->item(0)->nextSibling->parentNode->parentNode->getElementsByTagName('message');
5555
foreach ($translations as $translation) {
56-
$catalogue->set(
57-
(string) $translation->getElementsByTagName('source')->item(0)->nodeValue,
58-
(string) $translation->getElementsByTagName('translation')->item(0)->nodeValue,
59-
$domain
60-
);
56+
$translationValue = (string) $translation->getElementsByTagName('translation')->item(0)->nodeValue;
57+
58+
if (!empty($translationValue)) {
59+
$catalogue->set(
60+
(string) $translation->getElementsByTagName('source')->item(0)->nodeValue,
61+
$translationValue,
62+
$domain
63+
);
64+
}
6165
$translation = $translation->nextSibling;
6266
}
6367
$catalogue->addResource(new FileResource($resource));

0 commit comments

Comments
 (0)
0