diff options
author | Marius Gedminas <marius@gedmin.as> | 2004-10-21 11:45:01 +0000 |
---|---|---|
committer | Marius Gedminas <marius@gedmin.as> | 2004-10-21 11:45:01 +0000 |
commit | d200718f045beba8180af84f56b9d85ec3d3db5c (patch) | |
tree | a484cc70a76a786c74539a30ea2472182e69514a | |
parent | 433e1e643a51cd60b8608f8d13655ef856b709f0 (diff) | |
download | zope-tal-d200718f045beba8180af84f56b9d85ec3d3db5c.tar.gz |
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>.
-rw-r--r-- | talgettext.py | 7 | ||||
-rw-r--r-- | tests/test_talgettext.py | 30 |
2 files changed, 35 insertions, 2 deletions
diff --git a/talgettext.py b/talgettext.py index 036bc19..3e6d2b6 100644 --- a/talgettext.py +++ b/talgettext.py @@ -94,10 +94,13 @@ class POEngine(DummyEngine): 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 diff --git a/tests/test_talgettext.py b/tests/test_talgettext.py index 56d6858..1d31435 100644 --- a/tests/test_talgettext.py +++ b/tests/test_talgettext.py @@ -18,7 +18,11 @@ $Id$ """ 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 @@ class test_POEngine(unittest.TestCase): "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 |