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

History 38

  1. Garvin Hicking commented <span data-processor="relativetime" data-value="2024-10-31T13:14:03+00:00" > 10/31/24, 13:14 </span>

    Thanks for your report, I believe this indeed is a bug. I’ve created a patch along a test for this scenario.

  2. Garvin Hicking commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2024-11-05T07:50:08+00:00" > 11/05/24, 07:50 </span>

    Applied in changeset commit:092c7d5d0b326efb4a489cae149061ac0ba9a5c8.