Skip to content

[Routing] Add documentation for prefixing i18n routes with a locale #9862

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

Merged
merged 2 commits into from
Jun 1, 2018
Merged
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
17 changes: 17 additions & 0 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,23 @@ should be used during the request. Defining routes this way also eliminated the
need for duplicate registration of routes which minimizes the risk for any bugs
caused by definition inconsistency.

A common requirement for internationalized applications is to prefix all routes
with a locale. This can be done by defining a different prefix for each locale
(and setting an empty prefix for your default locale if you prefer it):

.. configuration-block::

.. code-block:: yaml

# config/routes/annotations.yaml
controllers:
resource: '../src/Controller/'
type: annotation
prefix:
en: '' # don't prefix URLs for English, the default locale
fr: '/fr'
es: '/es'

.. _routing-requirements:

Adding {wildcard} Requirements
Expand Down