Closed
Description
Hi, i'm using ApiPlatform + Symfony 4.3.3 to build a web application. I can't find a way to set the locale for my request. It always fallbacks back to the default locale set in Symfony.
I tried using a RequestListener but it ignores the value i set.
public function onKernelRequest(RequestEvent $event)
{
$token = $this->tokenStorage->getToken();
$user = ($token && $token->getUser()) ? $token->getUser() : null;
$request = $event->getRequest();
if(!$user || !($user instanceof User)) {
$request->setLocale('it');
} else {
$request->setLocale($user->getLang()->getLang());
}
}
How can i set the locale for my request?
Thanks