Issue Bug Closed

#105523LocalizationUtility never displays default value if TypoScript overrides exist

portrino DEV 10/30/24, 16:04 updated 12/02/25, 14:32

Description

Situation

There is a bug in LocalizationUtility->translate() in v12 and v13
https://github.com/TYPO3/typo3/blob/12.4/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php#L82
https://github.com/TYPO3/typo3/blob/13.4/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php#L78

It checks if TypoScript overrides exist and if there are ANY overrides for the current $languageKey the $value is set to an empty string.

$overrideLabels = static::loadTypoScriptLabels($extensionName);
$languageKey = $locale->getName();
// @todo: probably cannot handle "de-DE" and "de" fallbacks
if ($value === null && isset($overrideLabels[$languageKey])) {
    $value = '';
}

This prevents the TranslateViewHelper from returning the default value:

if ($value === null) {
    return self::handleDefaultValue($default, $translateArguments);
}

Fix

Check if the actually requested $key is set in the $overrideLabels instead.

Reviews 3