nuxeo-localizer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Nuxeo-localizer] user prefered language


From: Olivier Nibart
Subject: RE: [Nuxeo-localizer] user prefered language
Date: Mon, 18 Nov 2002 12:22:44 +0100

Hi Juan,

Thanks a lot for you answer.
First the 'small' things :

>Are you sure you want to remove the "complex" languages?

Well, fondamentally no, but I did it because I thought there was a problem
with those, I was wrong, it was a kind of 'side effect' of the the problem I
eventually found (I explain it later).

>>import string
>You don't really need to import "string", since Python 2 the string
>functions are included as method of the string objects. And, by the
>way, it isn't used in the code.
Ok, thanks for that tip. It was there because I've used it before and forget
to remove it...
It motivated me to go further in python, and here is an URL that may be
interesting for other readers of that list :
http://www.python.org/peps/pep-0290.html

>    q = user_languages[lang]  if q > quality:
>    language, quality = lang, q
>I think this piece of code is not well formatted, the expression
>"user_languages[lang]  if q > quality" will raise a syntax error
Absolutely, this is actually a 'cut and paste' bug, sorry...  

Now about the qualities set to one :

After further investigations, I found what put me into trouble....
It appears that MSIE (unfortunately used by most of the people in world)
send an HTTP_ACCEPT_LANGUAGE wich is correctly parsed (I've tested version
4.0, 5.5, 6.0) with the accept_language.parse method, but... send an
HTTP_USER_AGENT starting with 'Mozilla/4', thus falling into your
non-complient user agents procedure, which is wrong in that case.

I changed the __init__.py that way :
-------------
    user_agent = request['HTTP_USER_AGENT']
    if (user_agent.startswith('Mozilla/4'))
        and (user_agent.find('MSIE') == -1):
        # Netscape 4.x
-------------
(please note that the test line is broken only for the mail formatting, it's
not break in the actual code)

I don't know what would happen with MSIE < 4.0, I don't have that version...

So, what do you think about it ?

Regards,

Olivier Nibart




reply via email to

[Prev in Thread] Current Thread [Next in Thread]