-
Notifications
You must be signed in to change notification settings - Fork 9
Description
In https://bugs.launchpad.net/zope.i18n/+bug/428882, Ethan Jucovy (ethan.jucovy@gmail.com) reported:
It is useful to be able to override the default
zope.i18n.translationdomain.TranslationDomain-- for example I have one override that always injects a certain value into the translation mapping, and another that prepends all new catalogs rather than appending them.This is currently difficult without monkeypatching
zope.i18n.zcml.handleror forking itsregisterTranslationsfunction.The attached patch adds an optional
factoryargument to bothregisterTranslationsandhandlerso that custom ZCML directives can invokeregisterTranslationswith their choice ofITranslationDomain.It might also be worth checking that the object returned by the provided
factoryimplements (or can be adapted to?)ITranslationDomain, and preventing startup if it does not.The
<registerTranslations/>directive could also be extended with an optionalfactoryparameter whose default iszope.i18n.translationdomain.TranslationDomain. This isn't necessary, though, and it's arguably cleaner to write new directives for particular overrides.
with patch: https://bugs.launchpad.net/zope.i18n/+bug/428882/+attachment/714923/+files/add_factory.diff