src/PHPDish/Bundle/CoreBundle/EventListener/LocaleSubscriber.php
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $locale = null;
        if (!$request->hasPreviousSession()) {
            $locale = $this->getClientPreferredLocale($request);
        } elseif (!$request->attributes->get('_locale')) {
            $locale = $request->getSession()->get('_locale', $this->getClientPreferredLocale($request));
        }

        if ($locale !== null) {
            $request->setLocale($locale);
        }
    }
public function onKernelRequest(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $locale = null;
        if (!$request->hasPreviousSession()) {
            $locale = $this->getClientPreferredLocale($request);
        } elseif (!$request->attributes->get('_locale')) {
            $locale = $request->getSession()->get('_locale', $this->getClientPreferredLocale($request));
        }

        if ($locale !== null) {
            $request->setLocale($locale);
        }
    }
处理request

@param GetResponseEvent $event