8000 [Routing] Add locale fallback to internationalized routes · symfony/symfony-docs@32051bd · GitHub
[go: up one dir, main page]

Skip to content

Commit 32051bd

Browse files
author
Thomas Calvet
committed
[Routing] Add locale fallback to internationalized routes
1 parent 96d3023 commit 32051bd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

routing.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ 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+
.. tip::
214+
215+
If you use full locales (language + territory) in your application (e.g. `fr_FR`),
216+
you can use the language part only in your routes configurations (e.g. `fr`).
217+
218+
It also prevents you from repeating yourself when you want to use the same route path
219+
for several full locales that share the same language (e.g. `fr_FR` and `fr_BE`).
220+
221+
.. versionadded:: 4.2
222+
The feature to fall back on the language part only was introduced in Symfony 4.2.
223+
213224
A common requirement for internationalized applications is to prefix all routes
214225
with a locale. This can be done by defining a different prefix for each locale
215226
(and setting an empty prefix for your default locale if you prefer it):

0 commit comments

Comments
 (0)
0