Re: [Zope] A good time to set HTTP_ACCEPT_LANGUAGE

2007-02-01 Thread Dieter Maurer
Peter Bengtsson wrote at 2007-1-30 15:17 +:
My multilingo app now works with PlacelessTranslationService quite fine.
If you change your browser setting with about:config you get the website 
in different languages. Neat! However, what if you're in an internet 
cafe in Kenya using a Zulu web browser and you want the pages to appear 
in English for example?

One solution is to do this::

def __before_publishing_traverse__(self, object, REQUEST):
 lang = self.getUserCookieSettingLang(default='en') # 1.
 REQUEST.environ['HTTP_ACCEPT_LANGUAGE'] = lang

# 1. Trust that this is my custom function for finding out
# which language they really want to use when logged in.

Problems with this approach:
1. It has to be done for every object I publish including images, css etc.

You could use an AccessRule in your root object.



-- 
Dieter
___
Zope maillist  -  Zope@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 )


[Zope] A good time to set HTTP_ACCEPT_LANGUAGE

2007-01-30 Thread Peter Bengtsson

My multilingo app now works with PlacelessTranslationService quite fine.
If you change your browser setting with about:config you get the website 
in different languages. Neat! However, what if you're in an internet 
cafe in Kenya using a Zulu web browser and you want the pages to appear 
in English for example?


One solution is to do this::

def __before_publishing_traverse__(self, object, REQUEST):
lang = self.getUserCookieSettingLang(default='en') # 1.
REQUEST.environ['HTTP_ACCEPT_LANGUAGE'] = lang

# 1. Trust that this is my custom function for finding out
# which language they really want to use when logged in.

Problems with this approach:
1. It has to be done for every object I publish including images, css etc.
2. It feels slightly risky to change the REQUEST.environ object.

Thoughts?


--
Peter Bengtsson,
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com
___
Zope maillist  -  Zope@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 )