[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL - TALGenerator.py:1.58.6.2

Barry Warsaw barry@wooz.org
Wed, 26 Jun 2002 17:24:15 -0400


Update of /cvs-repository/Zope3/lib/python/Zope/TAL
In directory cvs.zope.org:/tmp/cvs-serv8480/lib/python/Zope/TAL

Modified Files:
      Tag: tal-i18n-refactor-branch
	TALGenerator.py 
Log Message:
Finishing up the TAL/I18n refactoring.

emitEndElement(): Handle two situations separately: 1) a tag has both
an i18n:translate attribute and no i18n:name attribute.  These have to
get insertTranslation emited before the end tag; 2) a tag has both
i18n:translate and i18n:name.  These have to get insertTranslation
after the end tag.  All current test cases now pass.


=== Zope3/lib/python/Zope/TAL/TALGenerator.py 1.58.6.1 => 1.58.6.2 ===
                 i18nNameAction = I18N_CONTENT
             self.emitSubstitution(content, {})
-        if msgid is not None:
+        # If we're looking at an implicit msgid, emit the insertTranslation
+        # opcode now, so that the end tag doesn't become part of the implicit
+        # msgid.  If we're looking at an explicit msgid, it's better to emit
+        # the opcode after the i18nVariable opcode so we can better handle
+        # 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 and not varname:
             self.emitTranslation(msgid, i18ndata)
         if optTag:
             self.emitOptTag(name, optTag, isend)
@@ -739,6 +745,10 @@
             # o varname[1] will be None for the first two actions and the
             #   replacement tal expression for the third action.
             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 repeat:
             self.emitRepeat(repeat)
         if condition: