Issue Task Closed

#91971Add language ISO information to the Language Aspect

Xavier Perseguers 08/11/20, 09:40 updated 12/05/23, 07:53

Description

Until TYPO3 v8 a developer could get the 2-letter ISO code of the current language by accessing:

$GLOBALS['TSFE']->lang

In TYPO3 v9, this information is still freely available (not deprecated), although marked as internal but it changed to default instead of en. The change is logical since it was always supposed to be a TYPO3 language and not an ISO code but this is a breaking change and forces developers to adapt.

In TYPO3 v9, the official way to access (current) $GLOBALS['TSFE']->lang is to do

$GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTypo3Language()

and the only way to get the former content, the real ISO code, is to do

$GLOBALS['TYPO3_REQUEST']->getAttribute('language')->getTwoLetterIsoCode()

Both of them are bad since it means replacing a $GLOBALS[] by another one.

I would expect to be able to read that information using the Language Aspect introduced in TYPO3 v9 (https://usetypo3.com/9lts-api-classes.html#c717) for example like that:

GeneralUtility::makeInstance(Context::class)->getAspect('language')->getTwoLetterIsoCode()

So in my opinion, the language aspect should be extended to provide really useful ISO information as well.

Reviews 0

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