[mod_python] Language selection

Wouter van Marle wouter at squirrel-systems.com
Mon May 22 10:35:51 EDT 2006

On Mon, 2006-05-22 at 09:53 -0400, Jim Gallacher wrote:
> Wouter van Marle wrote:
> > Hi all,
> > 
> > I know it's possible through the http request for browsers to indicate
> > preference for a language.
> > Can anyone explain how that works? Or are there code snippets available
> > for mod_python?
> > 
> > My website now supports four languages (English, Dutch, Chinese
> > Simplified, Chinese Traditional), defaulting to English. If the user
> > wants another language, they have to select it manually. It'd be nice if
> > I can detect there preference and default to that.
> You want to examine the Accept-Language header, which will likely be set 
> by the browser. See RFC-2616 at http://rfc.net/rfc2616.html#s14.4

I found that one in the meantime as well.
Not easy - searching for "language" on google gives heaps of references
to PROGRAMMING languages... 

> Note the important caveat in the RFC:
>     As intelligibility is highly dependent on the individual user, it is
>     recommended that client applications make the choice of linguistic
>     preference available to the user. If the choice is not made
>     available, then the Accept-Language header field MUST NOT be given in
>     the request.

Of course I check for the existence, if not fall back to a default. And
include a separate language selector (had that already).

After I found out the workings of this header the implementation was


> Sorry, I don't have any code snippets.
> Jim

More information about the Mod_python mailing list