[!!!][BUGFIX] Localization fallback does not work in Backend
authorXavier Perseguers <xavier@typo3.org>
Tue, 16 Oct 2012 12:03:28 +0000 (14:03 +0200)
committerXavier Perseguers <xavier@typo3.org>
Tue, 16 Oct 2012 12:06:07 +0000 (14:06 +0200)
The ll-XML parser internally falls-back to English when looking for a
non-existing language translation. This prevents the localization
fallback mechanism to detect that the translation did not exist or was
only partially available and thus take the language dependency into
account to return a proper label.

Change-Id: I4095d20ec8fc08105dfff108c7e3865f468ddb91
Fixes: #41996
Releases: 4.6, 4.7, 6.0
Reviewed-on: http://review.typo3.org/15709
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
t3lib/l10n/parser/class.t3lib_l10n_parser_llxml.php
tests/t3lib/l10n/parser/class.t3lib_l10n_parser_llxmlTest.php

index 9dcf937..101e38a 100644 (file)
@@ -86,7 +86,11 @@ class t3lib_l10n_parser_Llxml extends t3lib_l10n_parser_AbstractXml {
                        // Check if the source llxml file contains localized records
                $localizedBodyOfFileTag = $root->data->xpath("languageKey[@index='" . $this->languageKey . "']");
 
-               $parsedData = $this->getParsedDataForElement($bodyOfFileTag, $element);
+               if ($element === 'source' || $this->languageKey === 'default') {
+                       $parsedData = $this->getParsedDataForElement($bodyOfFileTag, $element);
+               } else {
+                       $parsedData = array();
+               }
                if ($element === 'target' && isset($localizedBodyOfFileTag[0]) && $localizedBodyOfFileTag[0] instanceof SimpleXMLElement) {
                        $parsedDataTarget = $this->getParsedDataForElement($localizedBodyOfFileTag[0], $element);
                        $mergedData = array_merge($parsedData, $parsedDataTarget);
index 04b8e02..96543b6 100644 (file)
@@ -124,13 +124,13 @@ class t3lib_l10n_parser_llxmlTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function canParseLlxmlInFrenchAndReturnsDefaultLabelsIfNoTranslationIsFound() {
+       public function canParseLlxmlInFrenchAndReturnsNullLabelsIfNoTranslationIsFound() {
                $LOCAL_LANG = $this->parser->getParsedData($this->llxmlFileNames['locallangOnlyDefaultLanguage'], 'fr');
 
                $expectedLabels = array(
-                       'label1' => 'This is label #1',
-                       'label2' => 'This is label #2',
-                       'label3' => 'This is label #3',
+                       'label1' => NULL,
+                       'label2' => NULL,
+                       'label3' => NULL,
                );
 
                foreach ($expectedLabels as $key => $expectedLabel) {