[Zope3-checkins] CVS: Zope3/src/zope/tal - driver.py:1.4 dummyengine.py:1.7 interfaces.py:1.5 talgettext.py:1.11 talinterpreter.py:1.19

Barry Warsaw barry@zope.com
Thu, 17 Apr 2003 16:05:45 -0400


Update of /cvs-repository/Zope3/src/zope/tal
In directory cvs.zope.org:/tmp/cvs-serv14704/src/zope/tal

Modified Files:
	driver.py dummyengine.py interfaces.py talgettext.py 
	talinterpreter.py 
Log Message:
Make the various i18n interfaces more consistent in their argument
order.  Some required domain before msgid, others had those two
reversed.  We standardize on msgid before domain because msgid can be
a MessageID instance which carries its domain around with it.  So in
that case we don't need to specify domain and can make it an argument
with a default value of None.

Update all found call sites of the old order, fixed interfaces and
tests.  Ran the tests and z3.py with Python 2.2.2 -- I hope I got them
all!


=== Zope3/src/zope/tal/driver.py 1.3 => 1.4 ===
--- Zope3/src/zope/tal/driver.py:1.3	Thu Apr  3 14:42:08 2003
+++ Zope3/src/zope/tal/driver.py	Thu Apr 17 16:05:14 2003
@@ -52,7 +52,7 @@
 FILE = "tests/input/test01.xml"
 
 class TestTranslations(DummyTranslationService):
-    def translate(self, domain, msgid, mapping=None, context=None,
+    def translate(self, msgid, domain=None, mapping=None, context=None,
                   target_language=None, default=None):
         if msgid == 'timefmt':
             return '%(minutes)s minutes after %(hours)s %(ampm)s' % mapping
@@ -65,10 +65,10 @@
             return 'mailto:bperson@dom.ain'
         elif msgid == 'origin':
             return '%(name)s was born in %(country)s' % mapping
-        return DummyTranslationService.translate(self, domain, msgid,
-                                                 mapping, context,
-                                                 target_language,
-                                                 default=default)
+        return DummyTranslationService.translate(
+            self, msgid, domain, mapping, context,
+            target_language, default=default)
+
 
 class TestEngine(DummyEngine):
     def __init__(self, macros=None):


=== Zope3/src/zope/tal/dummyengine.py 1.6 => 1.7 ===
--- Zope3/src/zope/tal/dummyengine.py:1.6	Thu Apr  3 14:42:08 2003
+++ Zope3/src/zope/tal/dummyengine.py	Thu Apr 17 16:05:14 2003
@@ -189,9 +189,9 @@
     def getDefault(self):
         return Default
 
-    def translate(self, domain, msgid, mapping, default=None):
-        return self.translationService.translate(domain, msgid, mapping,
-                                                 default=default)
+    def translate(self, msgid, domain=None, mapping=None, default=None):
+        return self.translationService.translate(
+            msgid, domain, mapping, default=default)
 
 
 class Iterator:
@@ -216,7 +216,7 @@
 class DummyTranslationService:
     __implements__ = ITranslationService
 
-    def translate(self, domain, msgid, mapping=None, context=None,
+    def translate(self, msgid, domain=None, mapping=None, context=None,
                   target_language=None, default=None):
         # This is a fake translation service which simply uppercases non
         # ${name} placeholder text in the message id.


=== Zope3/src/zope/tal/interfaces.py 1.4 => 1.5 ===
--- Zope3/src/zope/tal/interfaces.py:1.4	Tue Apr 15 17:25:21 2003
+++ Zope3/src/zope/tal/interfaces.py	Thu Apr 17 16:05:14 2003
@@ -126,9 +126,7 @@
         """
         """
 
-    # XXX msgid should come first, with domain defaulting to None.  When msgid
-    # is a MessageID, domain tags along and needn't be specified.
-    def translate(domain, msgid, mapping=None, default=None):
+    def translate(msgid, domain=None, mapping=None, default=None):
         """
         See ITranslationService.translate()
         """


=== Zope3/src/zope/tal/talgettext.py 1.10 => 1.11 ===
--- Zope3/src/zope/tal/talgettext.py:1.10	Tue Apr 15 17:28:07 2003
+++ Zope3/src/zope/tal/talgettext.py	Thu Apr 17 16:05:14 2003
@@ -83,7 +83,7 @@
         if msgid is None:
             return None
         # XXX We need to pass in one of context or target_language
-        return self.engine.translate(self.i18nContext.domain, msgid, i18ndict,
+        return self.engine.translate(msgid, self.i18nContext.domain, i18ndict,
                                      position=self.position, default=default)
 
 
@@ -106,7 +106,9 @@
     def evaluateBoolean(self, expr):
         return True # dummy
 
-    def translate(self, domain, msgid, mapping, position, default=None):
+    def translate(self, msgid, domain=None, mapping=None, default=None,
+                  # XXX position is not part of the ITALESEngine interface
+                  position=None):
         # assume domain and mapping are ignored; if they are not,
         # unit test must be updated.
         if msgid not in self.catalog:
@@ -206,11 +208,10 @@
     def evaluatePathOrVar(self, expr):
         return 'who cares'
 
-    def translate(self, domain, msgid, mapping, position,
-                  default=None):
+    def translate(self, msgid, domain=None, mapping=None, default=None,
+                  position=None):
         if msgid not in self.base:
-            POEngine.translate(self, domain, msgid, mapping, position,
-                               default=default)
+            POEngine.translate(self, msgid, domain, mapping, default, position)
         return 'x'
 
 


=== Zope3/src/zope/tal/talinterpreter.py 1.18 => 1.19 ===
--- Zope3/src/zope/tal/talinterpreter.py:1.18	Tue Apr 15 17:31:52 2003
+++ Zope3/src/zope/tal/talinterpreter.py	Thu Apr 17 16:05:14 2003
@@ -473,10 +473,8 @@
             self.interpret(stuff[1])
             return
         if isinstance(text, MessageID):
-            # Translate this now.  XXX passing None for the domain is bogus
-            # but necessary based on the signature of .translate().  We should
-            # switch msgid and domain, since domains tag along in MessageIDs.
-            text = self.engine.translate(None, text)
+            # Translate this now.
+            text = self.engine.translate(text)
         # '&' must be done first!
         s = text.replace(
             "&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
@@ -617,8 +615,8 @@
         if not self.i18nInterpolate:
             return msgid
         # XXX We need to pass in one of context or target_language
-        return self.engine.translate(self.i18nContext.domain,
-                                     msgid, i18ndict, default=default)
+        return self.engine.translate(msgid, self.i18nContext.domain,
+                                     i18ndict, default=default)
 
     def do_rawtextColumn(self, (s, col)):
         self._stream_write(s)