Bug #86683

locallangXMLOverride not working due to incorrect language file path

Added by Philipp Seiler about 2 months ago. Updated 3 days ago.

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

100%

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

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

test_86683.zip (8.39 KB) Sebastien Convers, 2018-10-30 15:53


Related issues

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

Associated revisions

Revision 591da85d (diff)
Added by Achim Fritz 3 days ago

[BUGFIX] Do not resolve languageFilePath to absolutePath

Resolving the path here breaks the localization Override
in the LocalizationFactory Class

Resolves: #86683
Releases: master
Change-Id: Ib7037bcfba0dd02cf46c1b31f98d7808e7974b3c
Reviewed-on: https://review.typo3.org/59024
Reviewed-by: Daniel Goerz <>
Tested-by: TYPO3com <>
Reviewed-by: Helmut Hummel <>
Tested-by: Helmut Hummel <>
Reviewed-by: Georg Ringer <>
Tested-by: Georg Ringer <>

History

#1 Updated by Tymoteusz Motylewski about 2 months ago

  • Related to Bug #86674: Overriding translations does not fully works added

#2 Updated by Joerg Kummer about 2 months ago

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.

#3 Updated by Sebastien Convers about 1 month 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.

#4 Updated by Sebastien Convers about 1 month ago

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

#5 Updated by Gerrit Code Review 7 days 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

#6 Updated by Gerrit Code Review 7 days 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

#7 Updated by Gerrit Code Review 7 days 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

#8 Updated by Gerrit Code Review 7 days 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

#9 Updated by Gerrit Code Review 6 days 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

#10 Updated by Gerrit Code Review 6 days 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

#11 Updated by Anonymous 3 days ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF