Add locale and requirements to all routes - Symfony2
Use JMS18nRoutingBundle (documentation) for this purpose. No custom loader, no coding ...
The bundle is able to prefix all your routes with the locale without changing anything except some configuration for the bundle. It's the quickest ( and my recommended ) solution to get you started.
You can even translate existing routes for different locales.
A quick introduction can be found in this coderwall post.
You can do it this way, in your global configuration file
customsite:
resource: "@CustomSiteBundle/Resources/config/routing.yml"
prefix: /{_locale}
requirements:
_locale: fr|en
defaults: { _locale: fr}
Quite slow reaction, but had some similar issue.
Nice to know is that you can also drop the {_locale} prefix when importing the resource. You would then be required to add {_locale} to every specific route.
This way you can catch the www.domain.com without a locale from inside your bundle, without having to rewrite the requirements and the defaults.
You could however, always define the www.domain.com route in your global routing configuration.