Commit b3d272d
committed
minor #19825 [Routing] Document the effect of setting
This PR was squashed before being merged into the 5.4 branch.
Discussion
----------
[Routing] 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 (as documented in [Localized Routes (i18n)](https://symfony.com/doc/current/routing.html#localized-routes-i18n)). 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`](https://github.com/symfony/symfony/blob/7.1/src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php) 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](https://github.com/symfony/symfony/blob/39038406d36a4dc1d320ff8d63d9700e7d08045d/src/Symfony/Component/Routing/Loader/Configurator/Traits/PrefixTrait.php#L45-L46).
I stumbled upon this because I was trying to implement a route which should be available only for a single locale. I couldn't find any mention of this behavior in the routing documentation.
Commits
-------
55215ca [Routing] Document the effect of setting `locale` on a route with locale prefixeslocale on a route with locale prefixes (nicwortel)1 file changed
+48
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2416 | 2416 | | |
2417 | 2417 | | |
2418 | 2418 | | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
| 2430 | + | |
| 2431 | + | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
2419 | 2467 | | |
2420 | 2468 | | |
2421 | 2469 | | |
| |||
0 commit comments