diff --git a/routing.rst b/routing.rst index 68daa866c4f..69f5b5a9330 100644 --- a/routing.rst +++ b/routing.rst @@ -210,6 +210,23 @@ should be used during the request. Defining routes this way also eliminated the need for duplicate registration of routes which minimizes the risk for any bugs caused by definition inconsistency. +A common requirement for internationalized applications is to prefix all routes +with a locale. This can be done by defining a different prefix for each locale +(and setting an empty prefix for your default locale if you prefer it): + +.. configuration-block:: + + .. code-block:: yaml + + # config/routes/annotations.yaml + controllers: + resource: '../src/Controller/' + type: annotation + prefix: + en: '' # don't prefix URLs for English, the default locale + fr: '/fr' + es: '/es' + .. _routing-requirements: Adding {wildcard} Requirements