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 #1

Updated by Tymoteusz Motylewski over 5 years ago

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

Updated by Joerg Kummer over 5 years 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.

Actions #3

Updated by Sebastien Convers over 5 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.

Actions #4

Updated by Sebastien Convers over 5 years 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

Actions #5

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

Actions #6

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

Actions #7

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

Actions #8

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

Actions #9

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

Actions #10

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

Actions #11

Updated by Anonymous over 5 years ago

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

Updated by Rémy DANIEL about 5 years ago

  • Has duplicate Bug #87022: Localization Utility use the full path for locallang files added
Actions #13

Updated by Benni Mack almost 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF