You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The framework should let users easily configure localized routes. There are two types of localized routes to consider:
localized routes whose paths are translated (eg. /cars and /voitures)
localized routes whose paths are translated and that are prefixed by the current locale (eg. /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:
Marten.routes.draw do
localized(prefix:true) do
path "routes.article_list", ArticleListHandler, name:"article_list"
path "routes.article_detail", ArticleDetailHandler, name:"article_detail"
path "routes.my_app", MyApp::ROUTES, name:"my_app"endend
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 to false)
prefix_default_locale - whether or not the default locale should be prefixed when prefix: true is used
Using #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.
Implementation
Make it possible to define translated route paths.
Make it possible to define route paths prefixed with locales.
Make sure that the I18n middleware can activate specific locales when locale route prefixes are used.
Document these new capabilities in the routing documentation section.
The text was updated successfully, but these errors were encountered:
@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.
@ellmetha Hey, sorry, I wasn't able to finish the work. I've been moved to a Go language in my work. BTW, what seem to be a simple setting of locale context is now an exercise in dealing with reverse path lookup.
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.
Implementation
The text was updated successfully, but these errors were encountered: