Symfony2 Route global {_locale} requirements

Viewed 4277

I have in my routing.yml specified the parameter _locale requirements in every single route and I think that must be something to simplify this situation.

routing.yml

ProjectBaseBundle_index:
    pattern:  /{_locale}
    defaults: { _controller: ProjectBaseBundle:Default:index }
    requirements:
        _locale: en|es

ProjectBaseBundle_privacy:
    pattern:  /privacy/{_locale}
    defaults: { _controller: ProjectBaseBundle:Default:privacy }
    requirements:
        _locale: en|es

.....

ProjectBaseBundle_legal:
    pattern:  /legal/{_locale}
    defaults: { _controller: ProjectBaseBundle:Default:legal }
    requirements:
        _locale: en|es

I am using Symfony2.1 beta 3

Is possible to specify a global _locale requirements for all my routes?

2 Answers
Related