Commit 5b227edf authored by Lennart Regebro's avatar Lennart Regebro

Committing fix.

parent 1d3503c2
...@@ -58,6 +58,11 @@ Zope Changes ...@@ -58,6 +58,11 @@ Zope Changes
- DateIndex now properly removes documents from both indexes if - DateIndex now properly removes documents from both indexes if
the value is None 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) Zope 2.8.1 (2005/08/11)
Features added Features added
......
...@@ -531,7 +531,8 @@ class TALInterpreter: ...@@ -531,7 +531,8 @@ class TALInterpreter:
return return
if isinstance(text, I18nMessageTypes): if isinstance(text, I18nMessageTypes):
# Translate this now. # Translate this now.
text = self.engine.translate(text.domain, text, text.mapping) text = self.engine.translate(text.domain, text,
text.mapping, text.default)
s = cgi.escape(text) s = cgi.escape(text)
self._stream_write(s) self._stream_write(s)
i = s.rfind('\n') i = s.rfind('\n')
...@@ -571,8 +572,9 @@ class TALInterpreter: ...@@ -571,8 +572,9 @@ class TALInterpreter:
# evaluate() does not do any I18n, so we do it here. # evaluate() does not do any I18n, so we do it here.
if isinstance(value, I18nMessageTypes): if isinstance(value, I18nMessageTypes):
# Translate this now. # Translate this now.
# XXX
value = self.engine.translate(value.domain, value, value = self.engine.translate(value.domain, value,
value.mapping) value.mapping, value.default)
if not structure: if not structure:
value = cgi.escape(ustr(value)) value = cgi.escape(ustr(value))
......
...@@ -70,6 +70,7 @@ class I18NCornerTestCase(TestCaseBase): ...@@ -70,6 +70,7 @@ class I18NCornerTestCase(TestCaseBase):
self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default')) self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
self.engine.setLocal('bar', 'BaRvAlUe') self.engine.setLocal('bar', 'BaRvAlUe')
self.engine.setLocal('raw', ' \tRaW\n ') self.engine.setLocal('raw', ' \tRaW\n ')
self.engine.setLocal('noxlt', MessageID("don't translate me"))
def _check(self, program, expected): def _check(self, program, expected):
result = StringIO() result = StringIO()
...@@ -286,6 +287,17 @@ class I18NCornerTestCase(TestCaseBase): ...@@ -286,6 +287,17 @@ class I18NCornerTestCase(TestCaseBase):
"Foo <span tal:replace='bar' i18n:name='bar' /></div>") "Foo <span tal:replace='bar' i18n:name='bar' /></div>")
self._check(program, u"<div>FOO \u00C0</div>\n") 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): 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