[Zope3-checkins] CVS: Zope3/src/zope/i18n - messageid.py:1.4
Barry Warsaw
barry@zope.com
Tue, 15 Apr 2003 17:17:48 -0400
Update of /cvs-repository/Zope3/src/zope/i18n
In directory cvs.zope.org:/tmp/cvs-serv25980/src/zope/i18n
Modified Files:
messageid.py
Log Message:
Add `mapping' to MessageID attributes; the interpolation mapping now
tags along as well. It can't be set via the constructor and always
gets initialized to an empty dictionary, but this makes it convenient
for extending the mapping at the _() wrap location.
Also, if the default is None, set the default string to ustr (i.e. not
self since we want a real Unicode object here).
=== Zope3/src/zope/i18n/messageid.py 1.3 => 1.4 ===
--- Zope3/src/zope/i18n/messageid.py:1.3 Wed Apr 9 17:22:35 2003
+++ Zope3/src/zope/i18n/messageid.py Tue Apr 15 17:17:48 2003
@@ -24,14 +24,22 @@
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')
+ __slots__ = ('domain', 'default', 'mapping')
def __new__(cls, ustr, domain=None, default=None):
self = unicode.__new__(cls, ustr)
self.domain = domain
- self.default = default
+ if default is None:
+ self.default = ustr
+ else:
+ self.default = default
+ self.mapping = {}
return self