Commit fad3a13a authored by Lennart Regebro's avatar Lennart Regebro

Fix for issue #1888. Merge from branch for that purpose.

parent 50f43e1f
......@@ -56,6 +56,11 @@ Zope Changes
- DateIndex now properly removes documents from both indexes if
the value is None
- Collector #1888: Some parts of the TALInterpreter would not pass a
default when translating, yet expect a string back. This would cause
an error (usually "NoneType has no attribute 'replace'") in the case
the message was not translated.
Zope 2.8.1 (2005/08/11)
Features added
......
......@@ -506,7 +506,8 @@ class TALInterpreter:
return
if isinstance(text, MessageID):
# Translate this now.
text = self.engine.translate(text.domain, text, text.mapping)
text = self.engine.translate(text.domain, text,
text.mapping, text.default)
s = escape(text)
self._stream_write(s)
i = s.rfind('\n')
......@@ -542,8 +543,9 @@ class TALInterpreter:
# evaluate() does not do any I18n, so we do it here.
if isinstance(value, MessageID):
# Translate this now.
# XXX
value = self.engine.translate(value.domain, value,
value.mapping)
value.mapping, value.default)
if not structure:
value = cgi.escape(ustr(value))
......
......@@ -70,6 +70,7 @@ class I18NCornerTestCase(TestCaseBase):
self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
self.engine.setLocal('bar', 'BaRvAlUe')
self.engine.setLocal('raw', ' \tRaW\n ')
self.engine.setLocal('noxlt', MessageID("don't translate me"))
def _check(self, program, expected):
result = StringIO()
......@@ -286,6 +287,17 @@ class I18NCornerTestCase(TestCaseBase):
"Foo <span tal:replace='bar' i18n:name='bar' /></div>")
self._check(program, u"<div>FOO \u00C0</div>\n")
def test_for_untranslated_messageid_simple(self):
program, macros = self._compile('<span tal:content="noxlt"/>')
self._check(program, "<span>don't translate me</span>\n")
def test_for_untranslated_messageid_i18nname(self):
program, macros = self._compile(
'<div i18n:translate="" >'
'<span tal:replace="python: noxlt" i18n:name="foo_name"/>'
'</div>')
self._check(program, "<div>don't translate me</div>\n")
class I18NErrorsTestCase(TestCaseBase):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment