[Checkins] SVN: z3c.pt/trunk/ Added support for translation of tag body.
Malthe Borch
mborch at gmail.com
Mon Sep 1 16:06:27 EDT 2008
Log message for revision 90665:
Added support for translation of tag body.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/i18n.txt
U z3c.pt/trunk/src/z3c/pt/translation.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-01 20:05:25 UTC (rev 90664)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-01 20:06:26 UTC (rev 90665)
@@ -15,6 +15,8 @@
Features
+- Added support for translation of tag body. [malthe]
+
- Added security configuration for the TALES iterator (repeat
dictionary). This is made conditional on the availability of the
application security framework. [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/i18n.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/i18n.txt 2008-09-01 20:05:25 UTC (rev 90664)
+++ z3c.pt/trunk/src/z3c/pt/i18n.txt 2008-09-01 20:06:26 UTC (rev 90665)
@@ -243,11 +243,16 @@
>>> body = """\
... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
+ ... xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ ... xmlns:tal="http://xml.zope.org/namespaces/tal">
... <span i18n:domain="test" i18n:translate="tid"
... title="Title" i18n:attributes="title aid">
- ... Default
+ ... Default, "default", 'default'
... </span>
+ ... <span i18n:domain="test" i18n:translate=""
+ ... tal:content="string:tid">
+ ... Default, "default", 'default'
+ ... </span>
... </div>"""
Not passing a language:
@@ -256,8 +261,11 @@
>>> print template.render()
<div>
<span title="Title">
- Default
+ Default, "default", 'default'
</span>
+ <span>
+ Default, "default", 'default'
+ </span>
</div>
Passing German:
@@ -265,4 +273,5 @@
>>> print template.render(target_language='de')
<div>
<span title="Mock translation of 'aid'.">Mock translation of 'tid'.</span>
+ <span>Mock translation of 'tid'.</span>
</div>
Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py 2008-09-01 20:05:25 UTC (rev 90664)
+++ z3c.pt/trunk/src/z3c/pt/translation.py 2008-09-01 20:06:26 UTC (rev 90665)
@@ -187,8 +187,12 @@
if msgid:
raise ValueError(
"Can't use message id with dynamic content translation.")
+
+ _.append(clauses.Assign(content, self.symbols.tmp))
+ content = self.translate_expression(
+ types.value(self.symbols.tmp), default=
+ repr(text.replace("'", "\'")))
- _.append(clauses.Translate())
_.append(clauses.Write(content))
# include
@@ -527,7 +531,7 @@
_locals = {}
exec suite.code in suite._globals, _locals
render = _locals['render']
-
+
return ByteCodeTemplate(render, self.root, self.parser, stream)
class ByteCodeTemplate(object):
More information about the Checkins
mailing list