From c15df9d1985eb33b224c19939e7e43822c263e49 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Sat, 21 Jul 2018 12:32:45 +0200 Subject: [PATCH 1/2] [Routing] Add locale fallback to internationalized routes --- routing.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/routing.rst b/routing.rst index 3c1c4558e62..7d4aa603cb4 100644 --- a/routing.rst +++ b/routing.rst @@ -210,6 +210,17 @@ 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. +.. tip:: + + If you use full locales (language + territory) in your application (e.g. `fr_FR`), + you can use the language part only in your routes configurations (e.g. `fr`). + + It also prevents you from repeating yourself when you want to use the same route path + for several full locales that share the same language (e.g. `fr_FR` and `fr_BE`). + +.. versionadded:: 4.2 + The feature to fall back on the language part only was introduced in Symfony 4.2. + 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): From 02cc739771a70cc0608476c454f7857a60ce57da Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 4 Sep 2018 14:54:53 +0200 Subject: [PATCH 2/2] Minor reword --- routing.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/routing.rst b/routing.rst index 7d4aa603cb4..80c5beeb91e 100644 --- a/routing.rst +++ b/routing.rst @@ -212,11 +212,10 @@ caused by definition inconsistency. .. tip:: - If you use full locales (language + territory) in your application (e.g. `fr_FR`), - you can use the language part only in your routes configurations (e.g. `fr`). - - It also prevents you from repeating yourself when you want to use the same route path - for several full locales that share the same language (e.g. `fr_FR` and `fr_BE`). + If the application uses full language + territory locales (e.g. ``fr_FR``, + ``fr_BE``), you can use the language part only in your routes (e.g. ``fr``). + This prevents having to define multiple paths when you want to use the same + route path for locales that share the same language. .. versionadded:: 4.2 The feature to fall back on the language part only was introduced in Symfony 4.2.