molecule
molecule copied to clipboard
Locale Selector Middleware
A more capable i18n middleware than our current locale negotiation middleware.
On an incoming request, it first tries to detect the locale value from the URI, then from a locale cookie, then from Accept-Language header, and finally falls back to the default platform locale.
It will redirect the user to the proper locale URI or, set the locale cookie to the detected locale and add a locale attribute to the request. It will also modify the path info to strip the locale prefix from the path. It should only redirect on head and get requests, not post, put or delete.