Skip to content

Commit 42eafc0

Browse files
committed
Document the effect of setting locale on a route with locale prefixes
When using localized routes and importing a collection of routes, the imported routes can be prefixed with a different prefix for each locale. This makes it easy to have localized routes for /en/about-us and /nl/over-ons without having to define multiple routes. This behavior is implemented in the `Symfony\Component\Routing\Loader\Configurator\Traits\PrefixTrait` by replacing the original route with a cloned version for each locale prefix. However, any route which has a default value for the `_locale` parameter will only be prefixed with the prefix for that locale and will not be cloned for the other locale prefixes.
1 parent ef7b670 commit 42eafc0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

routing.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,6 +2416,14 @@ with a locale. This can be done by defining a different prefix for each locale
24162416
;
24172417
};
24182418
2419+
.. tip::
2420+
2421+
If the special :ref:`_locale <routing-locale-parameter>` routing parameter
2422+
is set on any of the imported routes, that route will only be available
2423+
with the prefix for that locale. This is useful when you want to import
2424+
a collection of routes which contains a route that should only exist
2425+
in one of the locales.
2426+
24192427
Another common requirement is to host the website on a different domain
24202428
according to the locale. This can be done by defining a different host for each
24212429
locale.

0 commit comments

Comments
 (0)