[Zope] Use of HTTP_ACCEPT_LANGUAGE in Zope
Tino Wildenhain
tino@wildenhain.de
Thu, 09 Mar 2000 01:05:59 +0100
Hello,
Sin Hang Kin wrote:
>
> I am making a new head zope index_html file, I think it is now about time to
> make use of the HTTP_ACCEPT_LANGUAGE which is sent by the browser to
> indicate the perferred language.
Good idea. Zope needs some more languages anyway.
Apache for example has mod_negotiation for this.
> The variable is a string like:
>
> lang1, lang2;q=p1,lang3;q=p2....
>
> while lang1, lang2, lang3 is the perferenced languages.
please not: the q argument is not meaningless.
> I have think of the following ways to make such brenches in zope:
>
> 1. by setting the lang variable in the REQUEST
> 2. by transfer to the brench of lang/
> 3. brench calls of index_lang
I think a better way would be to implement a true negotiation mechanism.
That is, if the request comes, zope has to look for languages available
and rates them according to the language preferences coming from the UA.
Then it sends out the highest rated document, that might be the first
of the items in accept-language.
So each document (could be a folder?) schould have an attribute to
identify
its language capabilities.
A simple branch would imply you have all documents in all requrired
languages.
I in doupt you can make this happen.
> What will be the perferred way to make such a brench? I want to hear from
> all.
>
> In building the brench code : I have come up with the code:
>
> <dtml-in "_.string.split(HTTP_ACCEPT_LANGUAGE, ',')">
> .....do thing according to sequence-item
> </dtml-in>
>
> but on the second argument, the sequence-item may contain ;q=0.5 which need
> to be trancated. How can I trancated that in dtml?
Easy with a second string.split(_.['sequence-item'],";")[0]
Regards
Tino Wildenhain