Skip to content

Commit

Permalink
add test: automatic messageid translation
Browse files Browse the repository at this point in the history
  • Loading branch information
d-maurer committed Jul 22, 2020
1 parent 0e250ae commit d9ff939
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Products/PageTemplates/tests/testTranslation.py
Expand Up @@ -14,7 +14,10 @@
from unittest import TestCase

from z3c.pt import pagetemplate
from zope.component import provideAdapter
from zope.component.testing import PlacelessSetup
from zope.i18nmessageid import ZopeMessageFactory as _
from zope.traversing.adapters import DefaultTraversable

from ..PageTemplate import PageTemplate
from .util import useChameleonEngine
Expand All @@ -41,6 +44,7 @@ class TranslationTests(PlacelessSetup, TestCase):

def setUp(self):
super(TranslationTests, self).setUp()
provideAdapter(DefaultTraversable, (None,))
useChameleonEngine()

def test_translation_body(self):
Expand All @@ -58,6 +62,11 @@ def test_translation_replace(self):
t.write("""<p i18n:translate="" tal:replace="string:x">text</p>""")
self.assertEqual(t(), "translated")

def test_translation_msgid(self):
t = PageTemplate()
t.write("""<p tal:replace="options/msgid">text</p>""")
self.assertEqual(t(msgid=_(u"x")), "translated")

def test_no_translation_body(self):
t = PageTemplate()
t.write("""<p>text</p>""")
Expand Down

0 comments on commit d9ff939

Please sign in to comment.