Bug #86683
closedlocallangXMLOverride not working due to incorrect language file path
100%
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
Updated by Tymoteusz Motylewski about 6 years ago
- Related to Bug #86674: Overriding translations does not fully works added
Updated by Joerg Kummer about 6 years ago
- File test_86683_1.0.0.zip test_86683_1.0.0.zip added
I can not reproduce on 9.5.0 and 9.5.1-dev.
I have written an extension with testcases for this issue, compatible wit 8.7 and 9.5
This extension modifies the backend web module item titles for page-module and viewpage-modul, in default (en) and german language, by adding '(Test #86683)' to the text.
Please help us to reproduce the named behaviour by your adoptions to the attached test extension.
Updated by Sebastien Convers about 6 years ago
I can confirm the behaviour on 9.5.1
It seems to happened only for extbase extension (?)
Ex: in my ext_localconf.php
// WORKS
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:felogin/Resources/Private/Language/locallang.xlf'][] = 'EXT:my_ext/Resources/Private/Language/locallang.xlf';
// DON'T WORK
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:indexed_search/Resources/Private/Language/locallang.xlf'][] = 'EXT:my_ext/Resources/Private/Language/locallang.xlf';
// DON'T WORK
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:news/Resources/Private/Language/locallang.xlf'][] = 'EXT:my_ext/Resources/Private/Language/locallang.xlf';
If i change the previous lines to :
// WORKS
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['/full/path/to/ext/indexed_search/Resources/Private/Language/locallang.xlf'][] = 'EXT:my_ext/Resources/Private/Language/locallang.xlf';
// WORKS
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['/full/path/to/ext/news/Resources/Private/Language/locallang.xlf'][] = 'EXT:my_ext/Resources/Private/Language/locallang.xlf';
@Joerg Kummer: Try overriding news or indexed_search in your test extension, and you'll see.
Updated by Sebastien Convers about 6 years ago
- File test_86683.zip test_86683.zip added
I updated the "text_86683" extension with override for indexed_search and news.
You'll see it's not working. To make it work, replace in ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:indexed_search
By
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['/your/full/path/to/sysext/indexed_search
And
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:news
By
$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['/your/full/path/to/ext/news
Updated by Gerrit Code Review almost 6 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59024
Updated by Gerrit Code Review almost 6 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59024
Updated by Gerrit Code Review almost 6 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59024
Updated by Gerrit Code Review almost 6 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59024
Updated by Gerrit Code Review almost 6 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59024
Updated by Gerrit Code Review almost 6 years ago
Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59024
Updated by Anonymous almost 6 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 591da85d3f75d1e5ca4901571106a551f9bd8620.
Updated by Rémy DANIEL almost 6 years ago
- Has duplicate Bug #87022: Localization Utility use the full path for locallang files added