Skip to content

Commit

Permalink
Committing fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
regebro committed Sep 7, 2005
1 parent 1d3503c commit 5b227ed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/CHANGES.txt
Expand Up @@ -58,6 +58,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
Expand Down
6 changes: 4 additions & 2 deletions lib/python/TAL/TALInterpreter.py
Expand Up @@ -531,7 +531,8 @@ def do_insertText_tal(self, stuff):
return
if isinstance(text, I18nMessageTypes):
# 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)
self._stream_write(s)
i = s.rfind('\n')
Expand Down Expand Up @@ -571,8 +572,9 @@ def do_i18nVariable(self, stuff):
# evaluate() does not do any I18n, so we do it here.
if isinstance(value, I18nMessageTypes):
# 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))
Expand Down
12 changes: 12 additions & 0 deletions lib/python/TAL/tests/test_talinterpreter.py
Expand Up @@ -70,6 +70,7 @@ def setUp(self):
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()
Expand Down Expand Up @@ -286,6 +287,17 @@ def test_for_handling_unicode_vars(self):
"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):

Expand Down

0 comments on commit 5b227ed

Please sign in to comment.