public function __construct(RequestStack
$requestStack, string
$defaultLocale = 'en', RequestContextAwareInterface
$router = null, bool
$useAcceptLanguageHeader = false, array
$enabledLocales =
[]) { $this->defaultLocale =
$defaultLocale;
$this->requestStack =
$requestStack;
$this->router =
$router;
$this->useAcceptLanguageHeader =
$useAcceptLanguageHeader;
$this->enabledLocales =
$enabledLocales;
} public function setDefaultLocale(KernelEvent
$event): void
{ $event->
getRequest()->
setDefaultLocale($this->defaultLocale
);
} public function onKernelRequest(RequestEvent
$event): void
{ $request =
$event->
getRequest();
$this->
setLocale($request);
$this->
setRouterContext($request);
} public function onKernelFinishRequest(FinishRequestEvent
$event): void
{