[Zope3-Users] Problems with internationalization

Dmitry Vasiliev dima at hlabs.spb.ru
Sat Jul 21 10:26:19 EDT 2007


Jeremy Cook wrote:
> Thanks Dmitry,
> 
> I can see how it should work. However I am still having trouble. My 
> application is initially based on the wcsite example and is intended 
> to be really not any more complex than that so I wanted to keep it 
> that way. However I have probably inherited something from wcsite
> that I don't fully understand. I made a small amount of progress but
> I still get the following error with ++lang++test:
> 
> 2007-07-19T13:18:26 ERROR SiteError http://neshamn.no/++lang++test 
> Traceback (most recent call last):
[skip]
> line 117, in setPreferredLanguages raise
> NotCompatibleAdapterError("Adapter not compatible with " 
> NotCompatibleAdapterError: Adapter not compatible with 
> zope.i18n.interfaces.IModifiableBrowserLanguages has been used. 
> 129.177.20.93 - - [19/Jul/2007:13:18:26 +0200] "GET /++lang++test 
> HTTP/1.1" 500 84 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; 
> rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5"
> 
> I am not sure which adapter it is referring to and I am not sure how 
> to find out either. Since my site will only be in Norwegian, I have a
>  workaround which is to hard code the locale to 'no' so that dates
> and such are formatted correctly, but I would still like to
> understand what is wrong here.
> 
> Any ideas?

Ok, let's look briefly at the ++lang++ internals. When "++lang++" string
is encountered in the path the zope.traverse.namespace.lang's adapter
traverse() method will be called. The method then try to get an object
implementing IModifiableUserPreferredLanguages from the request and
set language with help of the setPreferredLanguages() method. The
default IModifiableUserPreferredLanguages implementation
zope.app.publisher.browser.ModifiableBrowserLanguages expects some
preparation work has been done for language overriding to work (see the 
base class for details).

Now let's look that's wrong with your code. At wcsite.languages there is
FixedLanguage adapter which prevents ModifiableBrowserLanguages adapter
to work mainly because it's always return hardcoded language. So if you
want to use ++lang++ namespace you need to modify your overrides.zcml to
remove FixedLanguage registration.

-- 
Dmitry Vasiliev <dima at hlabs.spb.ru>
http://hlabs.spb.ru



More information about the Zope3-users mailing list