Last active
June 28, 2016 14:35
-
-
Save pumatertion/4737302 to your computer and use it in GitHub Desktop.
TYPO3 Flow Setting Locale
How to detect User Language from HTTP Accept Language for usage by translateViewHelper
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 | |
abstract class AbstractMyController extends extends \TYPO3\Flow\Mvc\Controller\ActionController { | |
/** | |
* @Flow\Inject | |
* @var \TYPO3\Flow\I18n\Service | |
*/ | |
protected $i18nService; | |
/** | |
* Initialize Method | |
* Using http accept language header to set the current locale settings | |
*/ | |
public function initializeAction() { | |
parent::initializeAction(); | |
$detector = new \TYPO3\Flow\I18n\Detector(); | |
$acceptLanguageHeader = $this->request->getHttpRequest()->getHeaders()->get('Accept-Language'); | |
$language = $detector->detectLocaleFromHttpHeader($acceptLanguageHeader); | |
$this->i18nService->getConfiguration()->setCurrentLocale($language); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment