[Checkins] SVN: z3c.pt/trunk/ Play nice with older translation machinery; pass in a translation context.
Malthe Borch
mborch at gmail.com
Thu Oct 8 10:45:06 EDT 2009
Log message for revision 104929:
Play nice with older translation machinery; pass in a translation context.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/pagetemplate.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2009-10-08 14:40:13 UTC (rev 104928)
+++ z3c.pt/trunk/CHANGES.txt 2009-10-08 14:45:05 UTC (rev 104929)
@@ -1,9 +1,14 @@
Changelog
---------
-1.1 (unreleased)
-~~~~~~~~~~~~~~~~
+In next release...
+~~~~~~~~~~~~~~~~~~
+- Bind translation context (request) to translation method. Although
+ not required in newer versions of the translation machinery, some
+ versions will ask for a translation context in order to negotiate
+ language even when a language is explicitly passed in.
+
- Declare zope security settings for classes when zope.security is present
as the "class" ZCML directive was moved there.
Modified: z3c.pt/trunk/src/z3c/pt/pagetemplate.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/pagetemplate.py 2009-10-08 14:40:13 UTC (rev 104928)
+++ z3c.pt/trunk/src/z3c/pt/pagetemplate.py 2009-10-08 14:45:05 UTC (rev 104929)
@@ -11,7 +11,7 @@
from chameleon.core import clauses
from chameleon.core import generation
from chameleon.core import utils
-
+from chameleon.core.i18n import fast_translate
from chameleon.zpt import template
from chameleon.zpt.interfaces import IExpressionTranslator
@@ -100,7 +100,7 @@
content_type = None
default_parser = language.Parser()
version = 2
-
+
def bind(self, ob, request=None, macro=None, global_scope=True):
def render(target_language=None, request=request, **kwargs):
context = self._pt_get_context(ob, request, kwargs)
@@ -112,8 +112,15 @@
target_language = None
context['target_language'] = target_language
- context["econtext"] = utils.econtext(context)
+ context['econtext'] = utils.econtext(context)
+ # bind translation-method to request
+ def translate(
+ msgid, domain=None, mapping=None, target_language=None, default=None):
+ return fast_translate(
+ msgid, domain, mapping, request, target_language, default)
+ context[config.SYMBOLS.translate] = translate
+
if request is not None and not isinstance(request, basestring):
content_type = self.content_type or 'text/html'
response = request.response
More information about the checkins
mailing list