[Zope3-checkins] SVN: Zope3/trunk/src/zope/i18n/testmessagecatalog. Added support for use in fallback domains.

Jim Fulton jim at zope.com
Tue Nov 8 17:57:48 EST 2005


Log message for revision 39992:
  Added support for use in fallback domains.
  

Changed:
  U   Zope3/trunk/src/zope/i18n/testmessagecatalog.py
  U   Zope3/trunk/src/zope/i18n/testmessagecatalog.txt

-=-
Modified: Zope3/trunk/src/zope/i18n/testmessagecatalog.py
===================================================================
--- Zope3/trunk/src/zope/i18n/testmessagecatalog.py	2005-11-08 22:57:45 UTC (rev 39991)
+++ Zope3/trunk/src/zope/i18n/testmessagecatalog.py	2005-11-08 22:57:47 UTC (rev 39992)
@@ -28,7 +28,8 @@
         self.domain = domain
 
     def queryMessage(self, msgid, default=None):
-        return u'[[%s][%s]]' % (self.domain, msgid)
+        return u'[[%s][%s]]' % (self.domain or getattr(msgid, 'domain', ''),
+                                msgid)
 
     getMessage = queryMessage
 

Modified: Zope3/trunk/src/zope/i18n/testmessagecatalog.txt
===================================================================
--- Zope3/trunk/src/zope/i18n/testmessagecatalog.txt	2005-11-08 22:57:45 UTC (rev 39991)
+++ Zope3/trunk/src/zope/i18n/testmessagecatalog.txt	2005-11-08 22:57:47 UTC (rev 39992)
@@ -20,3 +20,26 @@
     'test'
 
     >>> cat.reload()
+
+Normally, the catalog's domain overrides the message id's domain:
+
+    >>> import zope.i18nmessageid
+    >>> id = zope.i18nmessageid.MessageFactory('baz.splat')('eek')
+
+    >>> cat.queryMessage(id)
+    u'[[foo.bar][eek]]'
+
+    >>> cat.getMessage(id)
+    u'[[foo.bar][eek]]'
+
+However, if the catalog's domain is '', indicating a fallback domain,
+then the id's domain is used:
+
+    >>> cat = zope.i18n.testmessagecatalog.TestMessageCatalog('')
+
+    >>> cat.queryMessage(id)
+    u'[[baz.splat][eek]]'
+
+    >>> cat.getMessage(id)
+    u'[[baz.splat][eek]]'
+    



More information about the Zope3-Checkins mailing list