Unset the _locale parameter if it is there and not needed
SymfonyRoute $route:
array $parameters:
protected function unsetLocaleIfNotNeeded(SymfonyRoute $route, array &$parameters) {
$locale = $this
->getLocale($parameters);
if (null !== $locale) {
if (preg_match('/' . $route
->getRequirement('_locale') . '/', $locale) && $locale == $route
->getDefault('_locale')) {
$compiledRoute = $route
->compile();
if (!in_array('_locale', $compiledRoute
->getVariables())) {
unset($parameters['_locale']);
}
}
}
}