TYPO3 - Get the current language in an external php file

If you've got an instance of the TSFE, you can access the sys_language_uid via $GLOBALS['TSFE']->sys_language_uid


For the V9, $GLOBALS['TSFE']->sys_language_uid is deprecated, it recommanded to use the Language Aspect.

Example :

$languageAspect = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class)->getAspect('language');
$sys_language_uid = $languageAspect->getId();

TYPO3 9+

$context = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);

// The requested language of the current page as integer (uid)
$currentLanguageUid = $context->getPropertyFromAspect('language', 'id');

Tags:

Typo3