From 6a86e447efc5e24b35578d7987a2e48b4d819d43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Thu, 3 Oct 2013 22:55:42 +0200 Subject: [PATCH] =?utf8?q?Mise=20=C3=A0=20jour=20fonction=20utilitaire=20?= =?utf8?q?=C2=AB=C2=A0translate=C2=A0=C2=BB.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- utils.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/utils.py b/utils.py index b3fc3c7..0982bc7 100755 --- a/utils.py +++ b/utils.py @@ -16,23 +16,16 @@ Global utilities """ from AccessControl import ModuleSecurityInfo -# TODO: trouver une solution… from zope.i18n import translate as i18ntranslate from zope.i18nmessageid import MessageFactory +from zope.globalrequest import getRequest security = ModuleSecurityInfo('Products.photoprint.utils') security.declarePublic('translate') -def translate(message, context): - """ Translate i18n message. - """ - # GTS = getGlobalTranslationService() - if isinstance(message, Exception): - try: - message = message[0] - except (TypeError, IndexError): - pass - return i18ntranslate(message, domain='photoprint', context=context.REQUEST) +def translate(msgid, mapping=None, default=None) : + """ traduction dans le domaine photoprint """ + return i18ntranslate(msgid, domain='photoprint', mapping=mapping, context=getRequest(), default=default) security.declarePublic('Message') Message = _ = MessageFactory('photoprint') -- 2.20.1