I am a beginner in TYPO3 :) and I want to get the current language in an external php file.
How can I do that?
Thanks a lot.
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 = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Context\Context::class);
// The requested language of the current page as integer (uid)
$currentLanguageUid = $context->getPropertyFromAspect('language', 'id');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With