zope: Changing i18n domain for any view

This is the result of researching for almost two days and coming up with a two-line solution.

We noticed a problem in Naaya portal toolkit – odd translation messages like “zope.viewlet.interfaces.IViewletManager” got stored in our translation dictionary. It seemed that Products.Five has an unusual i18n markup. Who on Earth would want to translate the name of an interface? That’s technical info, not natural language.

We didn’t want to patch/fork Products.Five, nor hard-code exception patterns. So we came up with this:

<configure xmlns="http://namespaces.zope.org/zope"
         i18n_domain="zope">
   <!-- overrides Products.Five.utilities.browser configure.zcml
   to get Five msgids out of our domain -->
   <include package="Products.Five.utilities.browser" />
 
</configure>

in overrides.zcml of our i18n custom package (naaya.i18n). This basically overrides their zcml configuration with the exact content, except we explicitly set the i18n_domain to.. let’s say.. “five”. And since our translation utility is registered for “default” domain, our translation service will no longer handle messages in Products.Five.utilities.browser templates.