Search code examples
extbasetypo3-9.x

How do I get the sys_language_uid with extbase


In TYPO3 9.5 is only $GLOBALS['TSFE']->sys_language_isocode available. How do I get the numeric sys_languagae_uid in my controller?


Solution

  • You can use the new Context singleton for this:

    $context = GeneralUtility::makeInstance(Context::class);
    return (int)$context->getPropertyFromAspect('language', 'id');
    

    This will return the numerical "sys_language_uid". When you look into the docblock of the Context class (see public/typo3/sysext/core/Classes/Context/Context.php, there is also a list of possible aspects you may use. There also is a documentation available.