Detect locale and alter url (redirect) to include locale

前端 未结 1 939
旧巷少年郎
旧巷少年郎 2021-01-14 04:02

What i want to do is, to detect the language of a users browser and redirect him to a page containing the locale in url.

I thought, the easiest way would be, to regi

相关标签:
1条回答
  • 2021-01-14 04:16

    Add, before your code:

    public function onKernelRequest(GetResponseEvent $event)
    {
        if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
            return;
        }
    
        $request = $event->getRequest();
        if ($request->getRequestFormat() !== 'html') {
            return;
        }
    
        [CODE]
    
    0 讨论(0)
提交回复
热议问题