[Zope] changing default language

Jean-Francois.Doyon at CCRS.NRCan.gc.ca Jean-Francois.Doyon at CCRS.NRCan.gc.ca
Wed Nov 24 10:57:45 EST 2004


Samuele,

Yup, use an "Access Rule".

Basically, create a python script that has the logic you need (Read cookie
value, set HTTP_ACCEPT_LANGUAGE as needed).

Then just set that python script as an access rule in the root of your site.

This is assuming you use the PlacelessTranslationService.  If you use
Localizer, the same idea should be applicable, although I don't think it
uses HTTP_ACCEPT_LANGUAGE to determine language?)

For instance. I have 2 access rules, one in the root of each folder for each
language, here's one:

request = container.REQUEST
request.set('HTTP_ACCEPT_LANGUAGE', 'en')

In your case, because language is determined not by the URL path, but by a
cookie, just alter the code to read the cookie, and put it in the root of
your site, and that should do it!

Cheers,
J.F.

-----Original Message-----
From: zope-bounces at zope.org [mailto:zope-bounces at zope.org]On Behalf Of
Samuele Giovanni Tonon
Sent: November 24, 2004 10:51 AM
To: zope at zope.org
Subject: [Zope] changing default language


hi to all,
i'm playing with i18n:translate tag of ZPT.

I would like a way to force i18n to show me the right language which is 
NOT setted on the browser, but on a cookie setted by a user preference
interface.

I tried some way to do that but none worked; i think that there can be
only two solutions to that :
Find a way to overwrite the default language of the browser (is it 
possible ? or it's something that has to be done only on to the browser ? )

Find a way to tell i18n:translate="" to change to i18n:translate="lang"
(where lang is a tal variable that stores the language user preference); 
however i was not able to find how to do that evaluation of lang and
i18n:target="string:something" seems not to work.

Any other solutions ? Any hints ?

Many thanks
Samuele

_______________________________________________
Zope maillist  -  Zope at zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


More information about the Zope mailing list