Issue Bug Closed

#104774ContentObjectRenderer initializes the LanguageService incorrectly ignoring set "typo3Language"

Denis Mir 08/29/24, 13:22 updated 03/26/25, 21:27

Description

The “\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer” does incorrectly initialize the “\TYPO3\CMS\Core\Localization\LanguageService” which leads to ignoring the set `typo3Language`. Yes it is deprecated but there are discussions about reverting it. (see here https://forge.typo3.org/issues/103887)

“\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getData” does the initialization like so:

$languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class)->createFromSiteLanguage($this->getTypoScriptFrontendController()->getLanguage());

that means it uses

\TYPO3\CMS\Core\Localization\LanguageServiceFactory::createFromSiteLanguage

to init the locale.

This is in contrast to the “\TYPO3\CMS\Extbase\Utility\LocalizationUtility” and the “\TYPO3\CMS\Fluid\ViewHelpers\TranslateViewHelper” which do both use:

\TYPO3\CMS\Core\Localization\Locales::createLocaleFromRequest

to init the locale.

In the end it leads to a mixed usage of locallang files and to a different output for the same language key depending on the context. (extbase or typoscript)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.