[FLOW3-general] Setting the current locale correctly
David Sporer
david.sporer at gmail.com
Sun Oct 21 16:08:30 CEST 2012
Hi,
I'm currently translating my page.
I'm saving the currently selected language in the session.
If my page is called the selected language is shown if I add the
initializeView to the controller.
$this->language is the Instance of my Language object that is stored in the
session.
public function initializeView(\TYPO3\FLOW3\Mvc\View\ViewInterface $view) {
$detector= new \TYPO3\FLOW3\I18n\Detector();
$this->lang =
$detector->detectLocaleFromHttpHeader($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
// set language if it's not already set in the current session
if($this->language->getLanguage()===NULL){
$this->languageService->getConfiguration()->setCurrentLocale($this->lang);
}else{
$locale = new
\TYPO3\FLOW3\I18n\Locale($this->language->getLanguage());
$this->languageService->getConfiguration()->setCurrentLocale($locale);
}
}
Is it possible to set the CurrentLocale only once in my switchLanguageAction
so I don't have to create a initializeView method for every Controller?
I've seen that there's also a setDefaultLocale() Method but that would
change the default language for all users not only the user that visits the
page right now right?
Best regards
David
More information about the FLOW3-general
mailing list