Skip to content

Commit

Permalink
Reword
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Jun 21, 2024
1 parent b3d272d commit e1b69a1
Showing 1 changed file with 7 additions and 45 deletions.
52 changes: 7 additions & 45 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2416,53 +2416,15 @@ with a locale. This can be done by defining a different prefix for each locale
;
};
.. tip::

If the special :ref:`_locale <routing-locale-parameter>` routing parameter
is set on any of the imported routes, that route will only be available
with the prefix for that locale. This is useful when you want to import
a collection of routes which contains a route that should only exist
in one of the locales:

.. configuration-block::

.. code-block:: php-annotations
// src/Controller/CompanyController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class CompanyController extends AbstractController
{
/**
* @Route("/about-us/en-only", locale="en", name="about_us")
*/
public function about(): Response
{
// ...
}
}
.. code-block:: php-attributes
// src/Controller/CompanyController.php
namespace App\Controller;
.. note::

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
If a route being imported includes the special :ref:`_locale <routing-locale-parameter>`
parameter in its own definition, Symfony will only import it for that locale
and not for the other configured locale prefixes.

class CompanyController extends AbstractController
{
#[Route('/about-us/en-only', locale: 'en', name: 'about_us')]
public function about(): Response
{
// ...
}
}
E.g. if a route contains ``locale: 'en'`` in its definition and it's being
imported with ``en`` (prefix: empty) and ``nl`` (prefix: ``/nl``) locales,
that route will be available only in ``en`` locale and not in ``nl``.

Another common requirement is to host the website on a different domain
according to the locale. This can be done by defining a different host for each
Expand Down

0 comments on commit e1b69a1

Please sign in to comment.