2009-09-13 14:37:46 |
Ethan Jucovy |
description |
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.py's `handler` or forking its `registerTranslations` function.
The attached patch adds an optional `factory` argument to both `registerTranslations` and `handler` so that custom ZCML directives can invoke `registerTranslations` with their choice of ITranslationDomain.
It might also be worth checking that the provided `factory` implements (or can be adapted to?) ITranslationDomain, and preventing startup if it does not.
The <registerTranslations/> directive could also be extended with an optional `factory` parameter whose default is zope.i18n.translationdomain.TranslationDomain. This isn't necessary, though, and it's arguably cleaner to write new directives for particular overrides. |
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.py's `handler` or forking its `registerTranslations` function.
The attached patch adds an optional `factory` argument to both `registerTranslations` and `handler` so that custom ZCML directives can invoke `registerTranslations` with their choice of ITranslationDomain.
It might also be worth checking that the object returned by the provided `factory` implements (or can be adapted to?) ITranslationDomain, and preventing startup if it does not.
The <registerTranslations/> directive could also be extended with an optional `factory` parameter whose default is zope.i18n.translationdomain.TranslationDomain. This isn't necessary, though, and it's arguably cleaner to write new directives for particular overrides. |
|