summaryrefslogtreecommitdiff
path: root/tests/test_talinterpreter.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_talinterpreter.py')
-rw-r--r--tests/test_talinterpreter.py34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/test_talinterpreter.py b/tests/test_talinterpreter.py
index f9158ee..651c0d7 100644
--- a/tests/test_talinterpreter.py
+++ b/tests/test_talinterpreter.py
@@ -32,6 +32,7 @@ from zope.tal.dummyengine import DummyTranslationDomain
from zope.tal.tests import utils
from zope.i18nmessageid import Message
+
class TestCaseBase(unittest.TestCase):
def _compile(self, source):
@@ -164,6 +165,25 @@ class I18NCornerTestCaseBase(TestCaseBase):
'<span tal:replace="foo" />')
self._check(program, 'FOOVALUE\n')
+ def test_attributes_translation(self):
+ program, macros = self._compile(
+ '<span tal:attributes="test bar"/>')
+ self._check(program, '<span test="BaRvAlUe" />\n')
+
+ program, macros = self._compile(
+ '<span test="bar" i18n:attributes="test"/>')
+ self._check(program, '<span test="BAR" />\n')
+
+ program, macros = self._compile(
+ '<span tal:attributes="test bar" i18n:attributes="test"/>')
+ self._check(program, '<span test="BARVALUE" />\n')
+
+ # i18n messages defined in Python are translated automatically
+ # (no i18n:attributes necessary)
+ program, macros = self._compile(
+ '<span tal:attributes="test foo"/>')
+ self._check(program, '<span test="FOOVALUE" />\n')
+
def test_text_variable_translate(self):
program, macros = self._compile(
'<span tal:content="bar"/>')
@@ -203,6 +223,16 @@ class I18NCornerTestCaseBase(TestCaseBase):
'<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"/>')
@@ -315,7 +345,7 @@ class I18NCornerTestCaseBase(TestCaseBase):
('endScope', ()),
('rawtextOffset', ('.', 1))])),
('endScope', ()),
-('rawtextOffset', ('</div>', 6))
+('rawtextOffset', ('</div>', 6))
]
self._check(program,
'<div>THIS IS TEXT FOR <span>BARVALUE</span>.</div>\n')
@@ -466,7 +496,7 @@ class I18NCornerTestCaseMessage(I18NCornerTestCaseBase):
return Message(msgid, domain=domain, default=default, mapping=mapping)
class UnusedExplicitDomainTestCase(I18NCornerTestCaseMessage):
-
+
def setUp(self):
# MultipleDomainsDummyEngine is a Engine
# where default domain transforms to uppercase