Created
September 18, 2020 08:38
-
-
Save fedetibaldo/83881a8d61edc3c54c83f2f1b23fa8b2 to your computer and use it in GitHub Desktop.
Get Current Language ISO Code in TYPO3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use TYPO3\CMS\Core\Context\Context; | |
use TYPO3\CMS\Core\Utility\GeneralUtility; | |
// ... | |
$context = GeneralUtility::makeInstance(Context::class); | |
/** @var TYPO3\CMS\Core\Site\Entity\Site */ | |
$site = $GLOBALS['TYPO3_REQUEST']->getAttribute('site'); | |
$langId = $context->getPropertyFromAspect('language', 'id'); | |
/** @var TYPO3\CMS\Core\Site\Entity\SiteLanguage */ | |
$language = $site->getLanguageById($langId); | |
$langCode = $language->getTwoLetterIsoCode(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment