@@ -2416,53 +2416,15 @@ with a locale. This can be done by defining a different prefix for each locale
2416
2416
;
2417
2417
};
2418
2418
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
-
2427
- .. configuration-block ::
2428
-
2429
- .. code-block :: php-annotations
2430
-
2431
- // src/Controller/CompanyController.php
2432
- namespace App\Controller;
2433
-
2434
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2435
- use Symfony\Component\HttpFoundation\Response;
2436
- use Symfony\Component\Routing\Annotation\Route;
2437
-
2438
- class CompanyController extends AbstractController
2439
- {
2440
- /**
2441
- * @Route("/about-us/en-only", locale="en", name="about_us")
2442
- */
2443
- public function about(): Response
2444
- {
2445
- // ...
2446
- }
2447
- }
2448
-
2449
- .. code-block :: php-attributes
2450
-
2451
- // src/Controller/CompanyController.php
2452
- namespace App\Controller;
2419
+ .. note ::
2453
2420
2454
- use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
2455
- use Symfony\Component\HttpFoundation\Response;
2456
- use Symfony\Component\Routing\Annotation\Route;
2421
+ If a route being imported includes the special :ref: ` _locale < routing-locale-parameter >`
2422
+ parameter in its own definition, Symfony will only import it for that locale
2423
+ and not for the other configured locale prefixes.
2457
2424
2458
- class CompanyController extends AbstractController
2459
- {
2460
- #[Route('/about-us/en-only', locale: 'en', name: 'about_us')]
2461
- public function about(): Response
2462
- {
2463
- // ...
2464
- }
2465
- }
2425
+ E.g. if a route contains ``locale: 'en' `` in its definition and it's being
2426
+ imported with ``en `` (prefix: empty) and ``nl `` (prefix: ``/nl ``) locales,
2427
+ that route will be available only in ``en `` locale and not in ``nl ``.
2466
2428
2467
2429
Another common requirement is to host the website on a different domain
2468
2430
according to the locale. This can be done by defining a different host for each
0 commit comments