Evaneos/pyrite — pull request #16 by oliviermadre (2014-08-04 14:11:43+00:00)
Title: Feature routing i18n

Added an i18n router engine, with i18n url generator

Bootstrap of pyrite changed that way :
```
use Pyrite\Routing\Director as RouterDirector;
use Pyrite\Routing\RouteConfigurationBuilderI18n;
use Pyrite\Routing\RouteConfigurationBuilderImpl;

// yml or php (compiled from yml) file
$routingPath = 'file.yml';

$request = Request::createFromGlobals();
$routerDirector = new RouterDirector($request, $routingPath);

// first key is the current locale (taken from container ?), second is the available locales. If not provided, the router builder wil try to get them from the router file, potential unexpected behavior in that case.
$routerBuilder = new RouteConfigurationBuilderI18n('fr', array('fr', 'en', 'es', 'it', 'de'));
$routeConfiguration = $routerDirector->build($routerBuilder);

// here is the route collection for the pyrite kernel
$routeConfiguration->getRouteCollection();
// here is the url generator to inject in the container to make it available anywhere in the application
$routeConfiguration->getUrlGenerator();
```

new syntax in yml files :
```
myRouteName:
route:
pattern: /my-url/
methods: [ get ]
dispatch:
PyriteApplicationFactory: [ ]
```
In that case, "myRouteName" is available in all known locales

```
myRouteName:
route:
pattern:
fr : "/francais/"
es : "/espagnol/"
methods: [ get ]
dispatch:
PyriteApplicationFactory: [ ]
```
In that case, "myRouteName" is available only for "fr" and "es" locales

UrlGeneratorI18n usage :
```
// Creates the url for myRouteName on the currentLocale
$url = $urlGenerator->generate('myRouteName', array());

// Creates the url for myRouteName on the locale FR
$url = $urlGenerator->generate('myRouteName.fr', array());

// Creates the url for myRouteName on the locale ES
$url = $urlGenerator->generate('myRouteName.es', array());

// Throws an exception because the "it" locale isn't registered for that route
$url = $urlGenerator->generate('myRouteName.it', array());

```