Get rid of a deprecation warning by using the new immutable

i18n Messages. Made DummyEngine work with them.
parent 3d0c2bb1
......@@ -22,17 +22,6 @@ from TALDefs import NAME_RE, TALESError, ErrorInfo
from ITALES import ITALESCompiler, ITALESEngine
from DocumentTemplate.DT_Util import ustr
IDomain = None
try:
from Zope2.I18n.ITranslationService import ITranslationService
from Zope2.I18n.IDomain import IDomain
except ImportError:
pass
if IDomain is None:
# Before 2.7, or not in Zope
class ITranslationService: pass
class IDomain: pass
class _Default:
pass
Default = _Default()
......@@ -234,7 +223,6 @@ class Iterator:
return 1
class DummyDomain:
__implements__ = IDomain
def translate(self, msgid, mapping=None, context=None,
target_language=None, default=None):
......@@ -246,8 +234,10 @@ class DummyDomain:
# things back together.
# simulate an unknown msgid by returning None
text = msgid
if msgid == "don't translate me":
text = default
if default is not None:
text = default
else:
text = msgid.upper()
......@@ -257,7 +247,6 @@ class DummyDomain:
return cre.sub(repl, text)
class DummyTranslationService:
__implements__ = ITranslationService
def translate(self, domain, msgid, mapping=None, context=None,
target_language=None, default=None):
......
......@@ -28,7 +28,7 @@ from TAL.TALInterpreter import TALInterpreter
from TAL.DummyEngine import DummyEngine, DummyTranslationService
from TAL.TALInterpreter import interpolate
from TAL.tests import utils
from zope.i18nmessageid import MessageID
from zope.i18nmessageid import Message
class TestCaseBase(unittest.TestCase):
......@@ -67,10 +67,10 @@ class I18NCornerTestCase(TestCaseBase):
def setUp(self):
self.engine = DummyEngine()
self.engine.setLocal('foo', MessageID('FoOvAlUe', 'default'))
self.engine.setLocal('foo', Message('FoOvAlUe', 'default'))
self.engine.setLocal('bar', 'BaRvAlUe')
self.engine.setLocal('raw', ' \tRaW\n ')
self.engine.setLocal('noxlt', MessageID("don't translate me"))
self.engine.setLocal('noxlt', Message("don't translate me"))
def _check(self, program, expected):
result = StringIO()
......
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