[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/t Fixed issue with <pre> and i18n:name

Dmitry Vasiliev dima at hlabs.spb.ru
Mon May 2 08:09:51 EDT 2005


Log message for revision 30228:
  Fixed issue with <pre> and i18n:name
  

Changed:
  U   Zope3/trunk/src/zope/tal/talinterpreter.py
  U   Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py

-=-
Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py	2005-05-02 11:21:10 UTC (rev 30227)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py	2005-05-02 12:09:51 UTC (rev 30228)
@@ -601,7 +601,10 @@
                     self.interpret(program)
                 finally:
                     self.popStream()
-                value = normalize(tmpstream.getvalue())
+                if self.html and self._currentTag == "pre":
+                    value = tmpstream.getvalue()
+                else:
+                    value = normalize(tmpstream.getvalue())
             finally:
                 self.restoreState(state)
         else:
@@ -646,6 +649,7 @@
         #
         # Use a temporary stream to capture the interpretation of the
         # subnodes, which should /not/ go to the output stream.
+        currentTag = self._currentTag
         tmpstream = StringIO()
         self.pushStream(tmpstream)
         try:
@@ -657,7 +661,7 @@
         # the top of the i18nStack.
         default = tmpstream.getvalue()
         if not msgid:
-            if self.html and self._currentTag == "pre":
+            if self.html and currentTag == "pre":
                 msgid = default
             else:
                 msgid = normalize(default)

Modified: Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py	2005-05-02 11:21:10 UTC (rev 30227)
+++ Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py	2005-05-02 12:09:51 UTC (rev 30228)
@@ -364,6 +364,25 @@
             '<pre>THIS IS TEXT <B> FOR</B> BARVALUE.</pre>\n',
             result.getvalue())
 
+    def test_raw_msgids_and_i18ntranslate_i18nname(self):
+        xlatdmn = self._getCollectingTranslationDomain()
+        result = StringIO()
+        program, macros = self._compile(
+            '<div i18n:translate=""> This is text\n \tfor\n'
+            '<pre i18n:name="bar" i18n:translate=""> \tbar\n </pre>.</div>')
+        self.interpreter = TALInterpreter(program, {}, self.engine,
+                                          stream=result)
+        self.interpreter()
+        msgids = list(xlatdmn.data)
+        msgids.sort()
+        self.assertEqual(2, len(msgids))
+        self.assertEqual(' \tbar\n ', msgids[0][0])
+        self.assertEqual('This is text for ${bar}.', msgids[1][0])
+        self.assertEqual({'bar': '<pre> \tBAR\n </pre>'}, msgids[1][1])
+        self.assertEqual(
+            u'<div>THIS IS TEXT FOR <pre> \tBAR\n </pre>.</div>\n',
+            result.getvalue())
+
     def test_for_handling_unicode_vars(self):
         # Make sure that non-ASCII Unicode is substituted correctly.
         # http://collector.zope.org/Zope3-dev/264



More information about the Zope3-Checkins mailing list