Open ellmetha opened 1 year ago
@ellmetha I've started some work on this. I needed a few clarifications.
Accept-Language
vs localized route - when Accept-Language
is fr
but localized route is /de/post/1
, what will the content be translated into? My guess is to follow the de
but just in case my assumptions are wrong.@kates Thanks for looking into that! To answer your question, the language extracted from the route path should always have precedence.
Description
The framework should let users easily configure localized routes. There are two types of localized routes to consider:
/cars
and/voitures
)/en/cars
and/fr/voitures
)In order to let users define such routes, let's add the ability to leverage a
#localized
block when defining routes. For example:This method should accept the following arguments:
prefix
- whether or not a locale prefix (eg./en/
or/fr/
depending on the activated locales) should be used for the generated routes (should default tofalse
)prefix_default_locale
- whether or not the default locale should be prefixed whenprefix: true
is usedUsing
#localized
would instruct the routing map that the wrapped path must be localized and that their actual "paths" must be treated as localization paths. For example, the associated translations could look like this:When generating the full URL of localized routes, the associated translations should be used in order to generate the localized URL and (optionally) prefix it with the current locale.