Lennart Regebro wrote:
On 1/18/06, Jürgen Herrmann <[EMAIL PROTECTED]> wrote:


- how can i set the target language for the translation in the zpt?


That's tricky! :) You need either Localizer or the plone tool for that
now, I think. But it's mentioned in the documentation. By default it
just picks the language from the list of languages in your browser, I
think?


Yeah, it does. In Silva 1.5, under development, I've overridden an adapter that negotates the language to also consult a cookie ('silva_language') and this appears to work.

Here's the code:

from zope.publisher.browser import BrowserLanguages

# new language extractor that looks in the silva_language cookie first,
# then fall back on browser setting
class SilvaLanguages(BrowserLanguages):
    def getPreferredLanguages(self):
        languages = super(
            SilvaLanguages, self).getPreferredLanguages()
        cookie_language = self.request.cookies.get('silva_language')
        if cookie_language is not None:
            languages = [cookie_language] + languages
        return languages

and then some ZCML in overrides.zcml in the product:

  <adapter
     for="zope.publisher.interfaces.http.IHTTPRequest"
     provides="zope.i18n.interfaces.IUserPreferredLanguages"
     factory=".adapters.languageprovider.SilvaLanguages"
    />

It's not perfect that this override is global now, but I guess eventually we could make it a local adapter override for the Silva site..

Regards,

Martijn
_______________________________________________
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 )

Reply via email to