[Zope3-Users] i18n questions

Marco Mariani marco at sferacarta.com
Thu Jun 1 09:25:29 EDT 2006


Stephan Richter wrote:

>> - How do a write/register a negotiator that choose a language based on
>> an attribute of the user object and then falls back to normal browser
>> negotiation if that attribute isn't present?
> 
> Just implement the right interface and register it. This is not too hard and I 
> think there are code examples out there.

There is an example on Philipp's book.

I don't have it here, but this for instance FORCES italian all the way:


from zope.publisher.browser import BrowserLanguages

class BrowserItalianLanguage(BrowserLanguages):

    def getPreferredLanguages(self):
#        langs = super(BrowserFormLanguages, self).getPreferredLanguages()
        return ['it']



and then in overrides.zcml:

  <adapter
      for="zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.i18n.interfaces.IUserPreferredLanguages"
      factory="my.package.BrowserItalianLanguage"
      />



of course you would normally get 'langs' from the super method and
manipulate it before returning





More information about the Zope3-users mailing list