[Checkins] SVN: grokcore.chameleon/trunk/ Fix translation issue with Chameleon 2.9 and higher.

Sylvain Viollow cvs-admin at zope.org
Thu Oct 11 12:26:13 UTC 2012


Log message for revision 127963:
  Fix translation issue with Chameleon 2.9 and higher.
  

Changed:
  U   grokcore.chameleon/trunk/buildout.cfg
  U   grokcore.chameleon/trunk/setup.py
  U   grokcore.chameleon/trunk/src/grokcore/chameleon/components.py
  U   grokcore.chameleon/trunk/src/grokcore/chameleon/configure.zcml
  U   grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml

-=-
Modified: grokcore.chameleon/trunk/buildout.cfg
===================================================================
--- grokcore.chameleon/trunk/buildout.cfg	2012-10-11 09:25:33 UTC (rev 127962)
+++ grokcore.chameleon/trunk/buildout.cfg	2012-10-11 12:26:09 UTC (rev 127963)
@@ -6,11 +6,11 @@
 extensions = buildout.dumppickedversions
 
 [versions]
-grokcore.chameleon = 
-Chameleon = 2.8.4
+grokcore.chameleon =
+Chameleon = 2.9.2
 ordereddict = 1.1
 unittest2 = 0.5.1
-z3c.pt = 2.2.2
+z3c.pt = 2.2.3
 
 [interpreter]
 recipe = zc.recipe.egg

Modified: grokcore.chameleon/trunk/setup.py
===================================================================
--- grokcore.chameleon/trunk/setup.py	2012-10-11 09:25:33 UTC (rev 127962)
+++ grokcore.chameleon/trunk/setup.py	2012-10-11 12:26:09 UTC (rev 127963)
@@ -4,7 +4,7 @@
 version = '1.0.3.dev0'
 
 install_requires = [
-    'Chameleon >= 2.8.4',
+    'Chameleon >= 2.9',
     'grokcore.component',
     'grokcore.view',
     'setuptools',

Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/components.py
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/components.py	2012-10-11 09:25:33 UTC (rev 127962)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/components.py	2012-10-11 12:26:09 UTC (rev 127963)
@@ -49,14 +49,22 @@
         }
 
     def render(self, **vars):
-        if 'target_language' not in vars:
-            try:
-                target_language = zope.i18n.negotiate(vars['request'])
-            except:
-                target_language = None
-            vars['target_language'] = target_language
+        # zope.i18n.translate will call negociate to retrieve the
+        # target_language if it is None.
+        request = vars.get('request')
+
+        def translate(
+            msgid, domain=None, mapping=None, target_language=None,
+            default=None, context=None):
+
+            return zope.i18n.translate(
+                msgid, domain, mapping, request, target_language, default)
+
+        vars['translate'] = translate
+
         return super(PageTemplate, self).render(**vars)
 
+
 def _module_relative_to_abs(ctx, filename):
     # Taken and adapted from z3c.pth.pagetemplate.
     if os.path.isabs(filename):

Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/configure.zcml
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/configure.zcml	2012-10-11 09:25:33 UTC (rev 127962)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/configure.zcml	2012-10-11 12:26:09 UTC (rev 127963)
@@ -4,6 +4,7 @@
 
   <include package="grokcore.view" file="meta-minimal.zcml" />
   <include package="grokcore.view" />
+
   <grok:grok package="." />
 
 </configure>

Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml	2012-10-11 09:25:33 UTC (rev 127962)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml	2012-10-11 12:26:09 UTC (rev 127963)
@@ -15,6 +15,7 @@
   <include package="zope.traversing.browser"/>
   <include package="zope.container"/>
   <include package="zope.i18n" />
+  <include package="zope.publisher" />
   <include package="zope.app.appsetup"/>
   <include package="grokcore.viewlet"/>
   <include package="grokcore.chameleon"/>



More information about the checkins mailing list