Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3 - Get the current language in an external php file

Tags:

typo3

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.

like image 420
Ahmed Ala Dali Avatar asked Mar 10 '11 09:03

Ahmed Ala Dali


3 Answers

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

like image 130
konsolenfreddy Avatar answered Oct 30 '22 22:10

konsolenfreddy


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();
like image 16
Pierre Fru Avatar answered Oct 30 '22 20:10

Pierre Fru


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');   
like image 8
John Miller Avatar answered Oct 30 '22 20:10

John Miller