nginx_accept_language_module
nginx_accept_language_module copied to clipboard
Add option for cookie checking [feature request]
A handy option, besides checking the accept language header, would be also to check an optional cookie value for a language code as well.
Maybe the following optional config statement:
accept_language_cookie <name of cookie to check>
And give the value of the cookie preference over the language order given in the accept language header.
This would allow the application to override the automagic language value (by setting a cookie), in case the uise would like to choose a language other than what their browser is set to.
I actually do this on my nginx configuration file:
set_from_accept_language $lang en fr de;
map $cookie_lang $header_lang { default $cookie_lang; "" $lang; }
So I set $header_lang to the value of either the lang cookie or if there's no cookie to the value of my set_from_accept_language.
I'm planning to write a case a study in the next few weeks of how I use this in production together with Varnish.