public function changeLanguageAction(Request $request, $oldLocale, $locale)
    {
        $params = [];

        $translationRoute = $this->getTranslationRoute($request->headers->get('referer'), $oldLocale, $locale);

        $request->setLocale($locale);

        if (!is_array($translationRoute)) {
            $routeName = $translationRoute;
        } else {
            $routeName = $translationRoute['_route'];
            unset($translationRoute['_route']);
            foreach ($translationRoute as $key => $var) {
                $params[$key] = $var;
            }
        }

        $params['_locale'] = $locale;

        $parts = parse_url($request->headers->get('referer'));

        if (array_key_exists('query', $parts) && $parts['query']) {
            parse_str($parts['query'], $query);

            $params = array_merge($query, $params);
        }

        $newURL = $this->get('router')->generate($routeName, $params);

        $response = new RedirectResponse($newURL);

        if ($this->getPageHelper()->isAllowLocaleCookie()) {
            $response->headers->setCookie(new Cookie('_locale', $locale));
        }

        return $response;
    }