From b74a186d8da401c587c4154c6008ff5bcf85e9cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Wed, 31 Jul 2013 16:12:57 +0200 Subject: [PATCH] =?utf8?q?On=20utilise=20la=20requ=C3=AAte=20globale=20pou?= =?utf8?q?r=20traduire.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 252af4e..7c5ceb7 100755 --- a/utils.py +++ b/utils.py @@ -28,6 +28,7 @@ from types import StringType from random import randrange from Acquisition import aq_base from quopri import encodestring +from zope.globalrequest import getRequest from AccessControl.PermissionRole import rolesForPermissionOn from AccessControl import ModuleSecurityInfo from AccessControl import getSecurityManager @@ -195,7 +196,7 @@ security.declarePublic('Message') Message = MessageFactory('plinn') security.declarePublic('translate') -def translate(message, context): +def translate(message, context=None): """ Translate i18n message. """ if isinstance(message, Exception): @@ -203,7 +204,11 @@ def translate(message, context): message = message[0] except (TypeError, IndexError): pass - return i18ntranslate(message, domain='plinn', context=context.REQUEST) + if not context : + request = getRequest() + else : + request = context.REQUEST + return i18ntranslate(message, domain='plinn', context=request) security.declarePublic('desacc') desacc = Utf8Utils.desacc -- 2.20.1