Project

General

Profile

Actions

Bug #86683

closed

locallangXMLOverride not working due to incorrect language file path

Added by Philipp Seiler over 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2018-10-18
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
locallang,language,extbase,localconf
Complexity:
Is Regression:
Sprint Focus:

Description

Hi,
i've found a problem with using XML/XLF override files.

Setup language override in an extensions ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:news/Resources/Private/Language/locallang.xlf'][] = 'EXT:' . $_EXTKEY . '/Resources/Private/Language/Extensions/News/locallang.xlf';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['de']['EXT:news/Resources/Private/Language/locallang.xlf'][] = 'EXT:' . $_EXTKEY . '/Resources/Private/Language/Extensions/News/de.locallang.xlf';
https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Internationalization/ManagingTranslations.html

TYPO3\CMS\Core\Classes\Localization\LocalizationFactory->localizationOverride()

Will be called when a locallangXMLOverride configuration is available. Within this method, for every localization file that is present, a check is performed, if an override exists. This is made by checking if an array key of the language file exists in the locallangXMLOverride array.

foreach ($this->store->getSupportedExtensions() as $extension) {
    if (isset($locallangXMLOverride[$languageKey][$fileReferenceWithoutExtension . '.' . $extension]) && is_array($locallangXMLOverride[$languageKey][$fileReferenceWithoutExtension . '.' . $extension])) {
        $overrides = array_merge($overrides, $locallangXMLOverride[$languageKey][$fileReferenceWithoutExtension . '.' . $extension]);
    } elseif (isset($locallangXMLOverride[$fileReferenceWithoutExtension . '.' . $extension]) && is_array($locallangXMLOverride[$fileReferenceWithoutExtension . '.' . $extension])) {
        $overrides = array_merge($overrides, $locallangXMLOverride[$fileReferenceWithoutExtension . '.' . $extension]);
    }
}

Problem is, that the locallangXMLOverride-array is configured with keys like EXT:foo/bar/Resources/Private/Lanugage/foobar.xlf, $fileReferenceWithoutExtension however is the full absolute path to the language file like var/www/html/typo3conf/ext/foo/bar/Resources/Private/Lanugage/foobar.xlf.
Therefore override files are not found, and no override is performed.

TYPO3\CMS\Extbase\Classes\Utility\LocalizationUtility->translate()

At line 89 the following code is executed: $languageFilePath = GeneralUtility::getFileAbsFileName($languageFilePath);.
This leads to the problem with absolute paths describe above.

In TYPO3 8.7.19 this problem is not present, as the translate()-Method is very different from V9.

Regards,
Philipp


Files

test_86683_1.0.0.zip (6.4 KB) test_86683_1.0.0.zip Testing extension with test case of forge issue #86683 Joerg Kummer, 2018-10-26 15:15
test_86683.zip (8.39 KB) test_86683.zip Sebastien Convers, 2018-10-30 15:53

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #86674: Overriding translations does not fully worksClosed2018-10-17

Actions
Has duplicate TYPO3 Core - Bug #87022: Localization Utility use the full path for locallang filesClosed2018-11-28

Actions
Actions

Also available in: Atom PDF