Skip to content

Commit

Permalink
[FrameworkBundle] added routing internationalization
Browse files Browse the repository at this point in the history
In your routing.yml:

homepage:
    pattern:  /:_locale
    defaults: { _controller: MyBundle:MyController:index, _locale: en }
    requirements: { _locale: (en|fr) }

In your PHP template:

<?php echo $view['session']->getLocale() ?>
  • Loading branch information
Francis Besset authored and fabpot committed Nov 13, 2010
1 parent 6f898a5 commit 35148c5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/RequestListener.php
Expand Up @@ -99,6 +99,10 @@ protected function initializeRequestAttributes(Request $request, $master)
}

$request->attributes->add($parameters);

if ($locale = $request->attributes->get('_locale')) {
$request->getSession()->setLocale($locale);
}
} elseif (null !== $this->logger) {
$this->logger->err(sprintf('No route found for %s', $request->getPathInfo()));
}
Expand Down

0 comments on commit 35148c5

Please sign in to comment.