Downsides of moving from Products to lib/python?

Hanno Schlichting plone at hannosch.info
Sat Aug 25 11:38:29 UTC 2007


Hi,

I'll just comment on the translation aspect :)

Maurits van Rees wrote:
> 2. Translations from i18n and locales directories do not get loaded.
>    You can add <i18n:registerTranslations directory="locales" /> and
>    then that will get loaded, but this is done in a Zope 3 way that is
>    not getting picked by the Zope 2 or Plone translation machinery.
>    For starters, the po files do not get listed in the PTS in the
>    Zope Control Panel.
> 
>    Plone 3.0 of course has templates in lib/python that need
>    translations.  But those translations are in
>    Products/PloneTranslations, so they get picked up as usual.
> 
>    So if you want to have a package in lib/python that needs
>    translation, then you will also have to make a Product for the
>    Products dir that contains the actual translations.

Just because po files aren't listed in the Control_Panel/PTS doesn't
mean they won't get picked up. Starting in Plone 2.5 PTS is not the main
translation service anymore but the one from Five is. This one will load
a translation registered for Zope3 first and fall back to PTS if none is
found.

This means that as soon as you register your translations in the Zope3
way with locales folders and the configure zcml snippet, everything
works fine both in pure Zope3 code as well as in Zope2 code.

If you use the i18n folder layout your translations will not be
available in pure Zope3 code (like ViewPageTemplateFiles used a lot for
viewlets for example). We have introduced a simple proxy object in Plone
3.0 here, which you can use to register i18n-folder-based translations
for Zope3 as well (see CMFPlone/i18nl10n.py PTSTranslationDomain).

In Plone 3.5 PTS itself is mostly deprecated and the mo file cache as
well as the Control_Panel entry are gone. Instead it will register all
po files found in a i18n folder as Zope3 ITranslationDomain utilities in
the same way the ones found in locales folders are treated.

> So I have two questions really:
> 
> A. Is there a way to have po files in lib/python get picked up by
>    Zope 2 after all?

Simple answer: Just use the locales folder layout and register it via
zcml. This should be the preferred way for all add-on products or
packages targeting Plone 3.0 or newer. In Plone 4.0 or 4.5 the support
for the i18n folder layout will probably be removed.

Hanno





More information about the Product-Developers mailing list