从Symfony2中的路由访问locale变量

I got the following issue. I am developing a project in which the routes will depend upon the locale variable. Currently is working but it has some issues that I would like to fix.

The structure I got is this one:

AppBundle
->config
  ->routing.en.yml #routes in English
  ->routing.es.yml #routes in Spanish
  ->routing.php    #in charge of making the magic

#/app/config/routing.yml
app:
    resource: "@AppBundle/config/routing.php"
    type:  php

fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

#@AppBundle/config/routing.es.yml
about_us:
   path: /nosotros
   defaults: { _controller: AppBundle:Default:about }

#@AppBundle/config/routing.en.yml
about_us:
   path: /about_us
   defaults: { _controller: AppBundle:Default:about }

The php file is invoked and this is what it does

//@AppBundle/config/routing.php
<?php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
use Symfony\Component\Yaml\Yaml;

$collection = new RouteCollection();
$collection->addCollection(
   $loader->import("@AppBundle/Controller/", "annotation")
);

$config = Yaml::parse(__DIR__."/../../../app/config/parameters.yml");
$locale = $config["parameters"]["locale"];

$routes =  Yaml::parse(__DIR__."/routing.{$locale}.yml");
foreach($routes as $name => $data)
{
   $collection->add($name, new Route($data["path"],$data["defaults"]));
}

return $collection;

It so far works but the problem is that is reading from the file and not from the session. I would like to know how can I inject that value from the session

Once again i am plagued with my lack of reputation and cannot just leave a comment on your post.

From what I understand, you want to make some routes available only for a given locale. For example, a french user will be able to access the route /bonjour but an english gentleman will only have the equivalent route /hello.

It is a bit weird. Why not make all routes available and change the locale to match the route? For example our french fellow will have a page in english if he tries to access the /hello url. Seems a lot more simple and handy.