[Zope3-checkins] CVS: Zope3/src/zope/tal - talgenerator.py:1.9.4.4 talinterpreter.py:1.22.4.4

Godefroid Chapelle gotcha at swing.be
Thu Aug 14 10:39:22 EDT 2003


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

Modified Files:
      Tag: srichter-i18n-macro-interaction-branch
	talgenerator.py talinterpreter.py 
Log Message:
- all tests pass

- checkin before small refactoring



=== Zope3/src/zope/tal/talgenerator.py 1.9.4.3 => 1.9.4.4 ===
--- Zope3/src/zope/tal/talgenerator.py:1.9.4.3	Fri Aug  8 16:31:35 2003
+++ Zope3/src/zope/tal/talgenerator.py	Thu Aug 14 09:38:46 2003
@@ -623,20 +623,25 @@
             if repeatWhitespace:
                 self.emitText(repeatWhitespace)
         if content:
-            todo["content"] = content
-        if replace:
+            if varname:
+                todo['i18nvar'] = (varname, None, I18N_CONTENT)
+                todo["content"] = content
+                self.pushProgram()
+            else:
+                todo["content"] = content
+        elif replace:
             # tal:replace w/ i18n:name has slightly different semantics.  What
             # we're actually replacing then is the contents of the ${name}
             # placeholder.
             if varname:
-                todo['i18nvar'] = (varname, replace)
+                todo['i18nvar'] = (varname, replace, I18N_REPLACE)
             else:
                 todo["replace"] = replace
             self.pushProgram()
         # i18n:name w/o tal:replace uses the content as the interpolation
         # dictionary values
         elif varname:
-            todo['i18nvar'] = (varname, None)
+            todo['i18nvar'] = (varname, None, I18N_EXPRESSION)
             self.pushProgram()
         if msgid is not None:
             self.i18nLevel += 1
@@ -679,10 +684,12 @@
         self.emitStartTag(name, self.replaceAttrs(attrlist, repldict), isend)
         if optTag:
             self.pushProgram()
-        if content:
+        if content and not varname:
             self.pushProgram()
         if msgid is not None:
             self.pushProgram()
+        if content and varname:
+            self.pushProgram()
         if todo and position != (None, None):
             todo["position"] = position
         self.todoPush(todo)
@@ -739,7 +746,8 @@
         # tags with both of them in them (and in the latter case, the contents
         # would be thrown away for msgid purposes).
         if msgid is not None:
-            if not varname:
+            if (not varname) or (
+                varname and (varname[2] == I18N_CONTENT)):
                 self.emitTranslation(msgid, i18ndata)
             self.i18nLevel -= 1
         if optTag:
@@ -767,11 +775,13 @@
             #   - I18N_EXPRESSION for explicit tal:replace
             # o varname[1] will be None for the first two actions and the
             #   replacement tal expression for the third action.
+            assert i18nNameAction == varname[2]
             self.emitI18nVariable(varname[0], i18nNameAction, varname[1])
         # Do not test for "msgid is not None", i.e. we only want to test for
         # explicit msgids here.  See comment above.
-        if msgid is not None and varname:
-            self.emitTranslation(msgid, i18ndata)
+        if msgid is not None: 
+            if varname and (varname[2] <> I18N_CONTENT):
+                self.emitTranslation(msgid, i18ndata)
         if repeat:
             self.emitRepeat(repeat)
         if condition:


=== Zope3/src/zope/tal/talinterpreter.py 1.22.4.3 => 1.22.4.4 ===
--- Zope3/src/zope/tal/talinterpreter.py:1.22.4.3	Fri Aug  8 12:46:30 2003
+++ Zope3/src/zope/tal/talinterpreter.py	Thu Aug 14 09:38:46 2003
@@ -492,7 +492,6 @@
             if isinstance(value, MessageID):
                 # Translate this now.
                 value = self.engine.translate(value)
-
         # Either the i18n:name tag is nested inside an i18n:translate in which
         # case the last item on the stack has the i18n dictionary and string
         # representation, or the i18n:name and i18n:translate attributes are




More information about the Zope3-Checkins mailing list