public function onKernelRequest(GetResponseEvent $event)
  {
      $currentLocale = $this->getCurrentLocale();
      $requestedLocale = $this->getRequestedLocale();

      if ($requestedLocale && $currentLocale != $requestedLocale) {
          $request = $event->getRequest();
          // ugly backwards compatibility fix for symfony 2.0 (start)
          if (!method_exists($request, 'setLocale')) {
              $request = $request->getSession();
          }
          // ugly backwards compatibility fix for symfony 2.0 (end)
          if (!setlocale(LC_MESSAGES, $requestedLocale.'.UTF-8', $requestedLocale.'.utf8', $requestedLocale.'.utf-8', $requestedLocale.'UTF8')) {
              $request->setLocale(null);
              throw new InvalidParameterException("Requested locale '$requestedLocale' could not be set. Is this locale installed? Hint: Execute 'locale -a' on the Linux command line to list installed locales.");
          }
          $request->setLocale($requestedLocale);
      }

      $this->setupGetText();
  }