Skip to content

Add optional ITranslationDomain factory for registerTranslations #8

@tseaver

Description

@tseaver

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.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.

with patch: https://bugs.launchpad.net/zope.i18n/+bug/428882/+attachment/714923/+files/add_factory.diff

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions