[BUGFIX] Invalid fallback for non-localized labels
authorXavier Perseguers <xavier@typo3.org>
Tue, 24 Jul 2012 14:10:30 +0000 (16:10 +0200)
committerXavier Perseguers <xavier@typo3.org>
Tue, 24 Jul 2012 15:11:49 +0000 (17:11 +0200)
Whenever a record is not translated, Pootle exports the localization file
with only the "source" element and no "target" element.

Change-Id: Ib4b849abdeff4b045af7a7bcd8550719f814557f
Fixes: #39220
Releases: 6.0, 4.7, 4.6
Reviewed-on: http://review.typo3.org/13020
Reviewed-by: Helmut Hummel
Reviewed-by: Oliver Hader
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
t3lib/l10n/parser/class.t3lib_l10n_parser_xliff.php

index f85f9e3..8606e03 100644 (file)
@@ -57,10 +57,18 @@ class t3lib_l10n_parser_Xliff extends t3lib_l10n_parser_AbstractXml {
                                                );
                                        } else {
                                                        // @todo Support "approved" attribute
-                                               $parsedData[(string)$translationElement['id']][0] = array(
-                                                       'source' => (string)$translationElement->source,
-                                                       'target' => (string)$translationElement->target,
-                                               );
+                                               if (!empty($translationElement->target)) {
+                                                       $parsedData[(string)$translationElement['id']][0] = array(
+                                                               'source' => (string)$translationElement->source,
+                                                               'target' => (string)$translationElement->target,
+                                                       );
+                                               } else {
+                                                               // No target element => not yet translated
+                                                       $parsedData[(string)$translationElement['id']][0] = array(
+                                                               'source' => (string)$translationElement->source,
+                                                               'target' => (string)$translationElement->source,
+                                                       );
+                                               }
                                        }
                                } elseif ($translationElement->getName() === 'group' && isset($translationElement['restype']) && (string)$translationElement['restype'] === 'x-gettext-plurals') {
                                                // This is a translation with plural forms
@@ -79,10 +87,18 @@ class t3lib_l10n_parser_Xliff extends t3lib_l10n_parser_AbstractXml {
                                                                );
                                                        } else {
                                                                        // @todo Support "approved" attribute
-                                                               $parsedTranslationElement[(int)$formIndex] = array(
-                                                                       'source' => (string)$translationPluralForm->source,
-                                                                       'target' => (string)$translationPluralForm->target,
-                                                               );
+                                                               if (!empty($translationPluralForm->target)) {
+                                                                       $parsedTranslationElement[(int)$formIndex] = array(
+                                                                               'source' => (string)$translationPluralForm->source,
+                                                                               'target' => (string)$translationPluralForm->target,
+                                                                       );
+                                                               } else {
+                                                                               // No target element => not yet translated
+                                                                       $parsedTranslationElement[(int)$formIndex] = array(
+                                                                               'source' => (string)$translationPluralForm->source,
+                                                                               'target' => (string)$translationPluralForm->source,
+                                                                       );
+                                                               }
                                                        }
                                                }
                                        }