Skip to content

Commit 9351b9b

Browse files
committed
minor #9862 [Routing] Add documentation for prefixing i18n routes with a locale (kbond, javiereguiluz)
This PR was merged into the 4.1 branch. Discussion ---------- [Routing] Add documentation for prefixing i18n routes with a locale I was not aware initially that the new i18n routing covered this feature of the JMSI18nRoutingBundle. Commits ------- c70d200 Simplified e45736e [Routing] add documentation for prefixing i18n routes with a locale
2 parents 04e8fa2 + c70d200 commit 9351b9b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

routing.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,23 @@ should be used during the request. Defining routes this way also eliminated the
210210
need for duplicate registration of routes which minimizes the risk for any bugs
211211
caused by definition inconsistency.
212212

213+
A common requirement for internationalized applications is to prefix all routes
214+
with a locale. This can be done by defining a different prefix for each locale
215+
(and setting an empty prefix for your default locale if you prefer it):
216+
217+
.. configuration-block::
218+
219+
.. code-block:: yaml
220+
221+
# config/routes/annotations.yaml
222+
controllers:
223+
resource: '../src/Controller/'
224+
type: annotation
225+
prefix:
226+
en: '' # don't prefix URLs for English, the default locale
227+
fr: '/fr'
228+
es: '/es'
229+
213230
.. _routing-requirements:
214231

215232
Adding {wildcard} Requirements

0 commit comments

Comments
 (0)