[z3-five] i18n ready for merging
Philipp von Weitershausen
philipp at weitershausen.de
Thu Jun 30 12:18:18 CEST 2005
Hi there,
the philikon-i18n-2 branch is ready for merging to the trunk. Malcolm
Cleaton from Jamkit and I sprinted on this topic before EP and completed
the missing tests. The behaviour is now as follows:
Translation
-----------
Five registers its own translation service mockup with the Page
Templates machinery and prevents any other product from also doing so.
That means, Five always assumes control over ZPT i18n. When a certain
domain has not been registered the Zope3 way, Five's translation service
will see that the utility lookup fails; in that case it uses the next
available fallback translation service. In case of no other translation
service installed, that is just a dummy fallback. In case you have
Localizer and PTS installed, it falls back to that.
Preferred languages and negotiation
-----------------------------------
Fallback translation services such as PTS and Localizer have their own
way of determining the user-preferred languages and negotiating that
with the available languages in the respective domain. Zope 3
translation domains typically adapt the request to
IUserPreferredLanguages to get a list of preferred languages; then they
use the INegotiator utility to negotiate between the preferred and
available languages.
The goal of the sprint was to allow both fallback translation services
(PTS, Localizer) and Zope 3 translation domains come to the same
conclusion regarding which language should be chosen. The use case is
that you have a site running Localizer or PTS and a bunch of "old"
products using either one of those for translation. Now you have an
additional, "new" Five-based product using Zope 3 translation domains.
Most of the time, a page contains user messages from more than one
domain, so you would all domains be translated to the same language.
Adjusting behaviour to your environment
---------------------------------------
The default behaviour for choosing languages in Five is the one of Zope
3: analyze the Accept-Language HTTP header and nothing more. In
addition, Malcolm and I provided IUserPreferredLanguages adapter for
Localizer and PTS that choose languages the exact same way Localizer or
PTS would. So, if you're using Five in a Localizer-environment, you need
this in your product's overrides.zcml:
<adapter
for="zope.publisher.interfaces.http.IHTTPRequest"
provides="zope.i18n.interfaces.IUserPreferredLanguages"
factory="Products.Five.i18n.LocalizerLanguages"
/>
If you're using PTS:
<adapter
for="zope.publisher.interfaces.http.IHTTPRequest"
provides="zope.i18n.interfaces.IUserPreferredLanguages"
factory="Products.Five.i18n.PTSLanguages"
/>
That way Zope 3 translation domains will always come to the same
conclusion regarding the language as your original translation service
would.
I would like to merge this branch some time next week. Please test your
product(s) with the branch and let me know if you encounter any
problems. Malcolm and I also provided test cases for environments where
a full-blown CPS installation is provided
(browser/tests/cps_test_localizer.py) and another one where the PTS
product is installed (browser/tests/pts_test_languages.py). Please run
them in case you encounter problems and let me know if they pass or not.
Thanks,
Philipp
More information about the z3-five
mailing list