Skip to content

[Routing] Add information about internationalized routing #9510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,40 @@ route::
Translating Routes
------------------

Symfony doesn't support defining routes with different contents depending on the
user language. In those cases, you can define multiple routes per controller,
one for each supported language; or use any of the bundles created by the
community to implement this feature, such as `JMSI18nRoutingBundle`_ and
Symfony support for internationalized routes depending on the user locale.

For YAML configuration you can define an array in the `path` option to add
a different path per locale:

.. code-block:: yaml

contact:
controller: App\Controller\ContactController::send
path:
en: /send-us-an-email
nl: /stuur-ons-een-email

This option is available as well for XML and annotations:

.. code-block:: php-annotations

use Symfony\Component\Routing\Annotation\Route;

class ContactController
{
/**
* @Route({
* "en": "/send-us-an-email",
* "nl": "/stuur-ons-een-email"
* }, name="contact")
*/
public function send()
{
// ...
}
}

For more advanced needs you can look on community bundles such as `JMSI18nRoutingBundle`_ and
`BeSimpleI18nRoutingBundle`_.

Keep Going!
Expand Down