[!!!][BUGFIX] Localization fallback does not work in Backend
authorXavier Perseguers <xavier@typo3.org>
Mon, 15 Oct 2012 11:35:42 +0000 (13:35 +0200)
committerXavier Perseguers <xavier@typo3.org>
Tue, 16 Oct 2012 12:02:17 +0000 (14:02 +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/15634
Reviewed-by: Dominique Feyer
Tested-by: Dominique Feyer
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php
typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php

index c93d385..8ad8750 100644 (file)
@@ -80,7 +80,11 @@ class LocallangXmlParser extends \TYPO3\CMS\Core\Localization\Parser\AbstractXml
                $bodyOfFileTag = $root->data->languageKey;
                // 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 c80bb06..21db175 100644 (file)
@@ -120,12 +120,12 @@ class LocallangXmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @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) {
                        $this->assertEquals($expectedLabel, $LOCAL_LANG['fr'][$key][0]['target']);