[Zope3-checkins] CVS: Zope3/src/zope/i18n - messageid.py:1.9
Philipp von Weitershausen
philikon at philikon.de
Fri Feb 20 04:25:09 EST 2004
Update of /cvs-repository/Zope3/src/zope/i18n
In directory cvs.zope.org:/tmp/cvs-serv11800
Modified Files:
messageid.py
Log Message:
Converted MessageID test to doctest.
=== Zope3/src/zope/i18n/messageid.py 1.8 => 1.9 ===
--- Zope3/src/zope/i18n/messageid.py:1.8 Tue Dec 16 09:54:01 2003
+++ Zope3/src/zope/i18n/messageid.py Fri Feb 20 04:24:38 2004
@@ -28,6 +28,44 @@
MessageID objects also have a mapping attribute which must be set after
construction of the object. This is used when translating and
substituting variables.
+
+ To instanciate MessageIDs, it is recommended to use MessageIDFactory:
+
+ >>> fact = MessageIDFactory('test')
+
+ Now we can use the factory to make MessageIDs. Note that MessageID
+ is a subclass of unicode:
+
+ >>> id = fact(u'this is a test')
+ >>> isinstance(id, MessageID)
+ True
+ >>> isinstance(id, unicode)
+ True
+
+ Additional parameters, such as the i18n domain and the default
+ text are available through attributes:
+
+ >>> id.domain
+ 'test'
+ >>> id.default
+ u'this is a test'
+
+ You can also reset the default text:
+
+ >>> id.default = u'blah'
+ >>> id.default
+ u'blah'
+
+ It is quite common to pass an abstract identifier as message id
+ and then a default text:
+
+ >>> id = fact(u'test-id', 'default test')
+ >>> id
+ u'test-id'
+ >>> id.default
+ u'default test'
+ >>> id.domain
+ 'test'
"""
__slots__ = ('domain', 'default', 'mapping')
More information about the Zope3-Checkins
mailing list