[Zope3-dev] Re: i18n domains vs. unique message ids -OR- why Shakespearean English was better

Godefroid Chapelle gotcha at swing.be
Mon Aug 18 12:58:09 EDT 2003


Philipp von Weitershausen wrote:
> Zope's i18n machinery provides two possible solutions to this problem 
> which I call to be discussed on:
> 
> 1. Have unique message ids for both nouns and verbs like the above. The
>    noun 'View' would have the message id 'view_component' while the verb
>    'View' would be 'view_permission'. They could thus be translated
>    separately and thus differently.
> 
>    The problem with this solution is that there is no way to manually
>    specify the message id while still providing a default value with
>    both zope.i18n.messageid.MessageIDFactory and the ZCML schema field
>    zope.configuration.fields.MessageID. And the above stated problem
>    with 'View' just happens to involve these two cases
> 
>    We would therefore have to provide an English translation to Zope3 as
>    well, containg at least translation for these kinds of message ids.

I think we cannot force english users to use the i18n machinery as most 
of them have not touched it ;-) Further, if we think of the Zope2 use 
case I state above, I think the message id path is not the good path.

> 
> 2. Use different i18n domains, such as 'zope_permissions',
>    'zope_components', 'zope_config' etc. One might argue that this is
>    actually what i18n domains are made for, keeping apart certain
>    terminology within an application.
> 
>    The problem with this solution is that
> 
>    a) we'd have to have more than just ZopeMessageIDFactory which can be
>       handily imported as _. OTOH, there might only be few modules that
>       actually would have to use more than one i18n domain.
> 
>    b) we'd have to do i18ngeddon, meaning going through the source and
>       changing ZopeMessageIDFactory to something else where appropriate
>       for python code, setting i18n:domain in ZPTs and i18n_domain in
>       ZCML.
> 

This is quite a heavy process and would also cost a lot each time 
someone wants to i18n a product which has not been. What I mean is that 
enforcing the use of multiple domains for each products is really too 
strict situation to me.

Anyway, i18n MessageId class has already the solution to your problem :

class MessageID(unicode):
     """Message ID.

     This is a string used as a message ID.  It has a domain attribute 
that is
     its source domain, and a default attribute that is its default text to
     display when there is no translation.  domain may be None meaning 
there is
     no translation domain.  default may also be None, in which case the
     message id itself implicitly serves as the default text.

     MessageID objects also have a mapping attribute which must be set after
     construction of the object.  This is used when translating and
     substituting variables.
     """

     __slots__ = ('domain', 'default', 'mapping')

     def __new__(cls, ustr, domain=None, default=None):


Did you see the default argument to the constructor ;-) ?


> Thoughts?
> 
> Phil

  Cheers...





More information about the Zope3-dev mailing list