[Zope3-checkins] CVS: Zope3/src/zope/app/pagetemplate - engine.py:1.7
Barry Warsaw
barry@wooz.org
Tue, 25 Mar 2003 15:21:58 -0500
Update of /cvs-repository/Zope3/src/zope/app/pagetemplate
In directory cvs.zope.org:/tmp/cvs-serv25905/src/zope/app/pagetemplate
Modified Files:
engine.py
Log Message:
Add an ITranslator interface and a Translator implementation of that
interface. This is basically a glue class for specifying the domain,
context, and locale in one packet and then providing a translate()
method which just takes the message id and mapping.
Glue this into the Zope app's page template engine.
Also removed some unused code and fix some typos.
=== Zope3/src/zope/app/pagetemplate/engine.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/pagetemplate/engine.py:1.6 Tue Mar 25 15:07:16 2003
+++ Zope3/src/zope/app/pagetemplate/engine.py Tue Mar 25 15:21:27 2003
@@ -28,12 +28,11 @@
import ExpressionEngine, RegistrationError, Context
from zope.app.interfaces.traversing import ITraverser
-from zope.component import getService
from zope.app.traversing.adapters import Traverser
from zope.proxy.introspection import removeAllProxies
from zope.security.proxy import ProxyFactory
from zope.security.builtins import RestrictedBuiltins
-
+from zope.i18n.translate import Translator
def zopeTraverser(object, path_items, econtext):
"""Traverses a sequence of names, first trying attributes then items.
@@ -63,8 +62,9 @@
return macro
def translate(self, domain, msgid, mapping):
- ts = getService(self.context, 'Translation')
- return ts.translate(domain, msgid, mapping, self.request)
+ # XXX should we cache the translator instance?
+ translator = Translator(self.request.locale, domain, self.context)
+ return translator.translate(msgid, mapping)
class ZopeEngine(ExpressionEngine):