[Zope3-checkins] SVN: Zope3/branches/3.3/ TAL interpreter now
properly translate i18n Messages when inserted as structure
Dmitry Vasiliev
dima at hlabs.spb.ru
Fri Jul 7 09:08:31 EDT 2006
Log message for revision 69024:
TAL interpreter now properly translate i18n Messages when inserted as structure
Changed:
U Zope3/branches/3.3/doc/CHANGES.txt
U Zope3/branches/3.3/src/zope/tal/talinterpreter.py
U Zope3/branches/3.3/src/zope/tal/tests/test_talinterpreter.py
-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt 2006-07-07 13:08:02 UTC (rev 69023)
+++ Zope3/branches/3.3/doc/CHANGES.txt 2006-07-07 13:08:31 UTC (rev 69024)
@@ -10,6 +10,9 @@
Bugfixes
+ - TAL interpreter didn't translate i18n Messages when inserted
+ as structure;
+
- Fixed issue 667: ZPT repeat "oddness"
- Fixed issue 646: TAL interpreter doesn't translate i18n
Modified: Zope3/branches/3.3/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/branches/3.3/src/zope/tal/talinterpreter.py 2006-07-07 13:08:02 UTC (rev 69023)
+++ Zope3/branches/3.3/src/zope/tal/talinterpreter.py 2006-07-07 13:08:31 UTC (rev 69024)
@@ -748,7 +748,10 @@
if structure is self.Default:
self.interpret(block)
return
- text = unicode(structure)
+ if isinstance(structure, I18nMessageTypes):
+ text = self.translate(structure)
+ else:
+ text = unicode(structure)
if not (repldict or self.strictinsert):
# Take a shortcut, no error checking
self.stream_write(text)
@@ -765,10 +768,9 @@
if structure is self.Default:
self.interpret(block)
else:
- if isinstance(structure, TypesToTranslate):
- text = self.translate(structure)
- else:
- text = unicode(structure)
+ if not isinstance(structure, TypesToTranslate):
+ structure = unicode(structure)
+ text = self.translate(structure)
if not (repldict or self.strictinsert):
# Take a shortcut, no error checking
self.stream_write(text)
Modified: Zope3/branches/3.3/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- Zope3/branches/3.3/src/zope/tal/tests/test_talinterpreter.py 2006-07-07 13:08:02 UTC (rev 69023)
+++ Zope3/branches/3.3/src/zope/tal/tests/test_talinterpreter.py 2006-07-07 13:08:31 UTC (rev 69024)
@@ -223,6 +223,16 @@
'<span i18n:translate="" tal:replace="structure bar"/>')
self._check(program, 'BARVALUE\n')
+ # i18n messages defined in Python are translated automatically
+ # (no i18n:translate necessary)
+ program, macros = self._compile(
+ '<span tal:content="structure foo"/>')
+ self._check(program, '<span>FOOVALUE</span>\n')
+
+ program, macros = self._compile(
+ '<span tal:replace="structure foo"/>')
+ self._check(program, 'FOOVALUE\n')
+
def test_structure_text_translate(self):
program, macros = self._compile(
'<span tal:content="structure string:BaR"/>')
More information about the Zope3-Checkins
mailing list