/** * Sets the request on the language manager. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The Event to process. */ public function onKernelRequestLanguage(GetResponseEvent $event) { if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST) { $request = $event->getRequest(); $this->negotiator->setCurrentUser($this->currentUser); $this->negotiator->reset(); if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) { $this->languageManager->setNegotiator($this->negotiator); $this->languageManager->setConfigOverrideLanguage($this->languageManager->getCurrentLanguage()); } // After the language manager has initialized, set the default langcode // for the string translations. $langcode = $this->languageManager->getCurrentLanguage()->getId(); $this->translation->setDefaultLangcode($langcode); } }
/** * Initializes the injected language manager with the negotiator. * * This should be called right after instantiating the negotiator to make it * available to the language manager without introducing a circular * dependency. */ public function initLanguageManager() { $this->languageManager->setNegotiator($this); }