[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/t Indicate dynamic
message IDs by replacing dynamic parts with XXX instead of
Marius Gedminas
marius at pov.lt
Thu Oct 21 07:45:02 EDT 2004
Log message for revision 28229:
Indicate dynamic message IDs by replacing dynamic parts with XXX instead of
removing them. See the newly-added unit test for examples. See also
<http://zope.org/Collectors/Zope3-dev/300>.
Changed:
U Zope3/trunk/src/zope/tal/talgettext.py
U Zope3/trunk/src/zope/tal/tests/test_talgettext.py
-=-
Modified: Zope3/trunk/src/zope/tal/talgettext.py
===================================================================
--- Zope3/trunk/src/zope/tal/talgettext.py 2004-10-21 09:44:28 UTC (rev 28228)
+++ Zope3/trunk/src/zope/tal/talgettext.py 2004-10-21 11:45:01 UTC (rev 28229)
@@ -94,10 +94,13 @@
DummyEngine.__init__(self, macros)
def evaluate(*args):
- return '' # who cares
+ # If the result of evaluate ever gets into a message ID, we want
+ # to notice the fact in the .pot file.
+ return 'XXX'
def evaluatePathOrVar(*args):
- return '' # who cares
+ # Actually this method is never called.
+ return 'XXX'
def evaluateSequence(self, expr):
return (0,) # dummy
Modified: Zope3/trunk/src/zope/tal/tests/test_talgettext.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_talgettext.py 2004-10-21 09:44:28 UTC (rev 28228)
+++ Zope3/trunk/src/zope/tal/tests/test_talgettext.py 2004-10-21 11:45:01 UTC (rev 28229)
@@ -18,7 +18,11 @@
"""
import sys
import unittest
+import operator
+from StringIO import StringIO
+from zope.tal.htmltalparser import HTMLTALParser
+from zope.tal.talgettext import POTALInterpreter
from zope.tal.talgettext import POEngine
from zope.tal.tests import utils
@@ -40,6 +44,32 @@
"POEngine catalog does not properly store message ids"
)
+ def test_dynamic_msgids(self):
+ sample_source = """
+ <p i18n:translate="">
+ Some
+ <span tal:replace="string:strange">dynamic</span>
+ text.
+ </p>
+ <p i18n:translate="">
+ A <a tal:attributes="href path:dynamic">link</a>.
+ </p>
+ """
+ p = HTMLTALParser()
+ p.parseString(sample_source)
+ program, macros = p.getCode()
+ engine = POEngine()
+ engine.file = 'sample_source'
+ POTALInterpreter(program, macros, engine, stream=StringIO(),
+ metal=False)()
+ msgids = []
+ for domain in engine.catalog.values():
+ msgids += domain.keys()
+ msgids.sort()
+ self.assertEquals(msgids,
+ ['A <a href="XXX">link</a>.', 'Some XXX text.'])
+
+
def test_suite():
suite = unittest.makeSuite(test_POEngine)
return suite
More information about the Zope3-Checkins
mailing list