globalrequest a été intégré à Zope.
[photoprint.git] / utils.py
index 9f4fb8a..b3fc3c7 100755 (executable)
--- a/utils.py
+++ b/utils.py
 """
 Global utilities
 
 """
 Global utilities
 
-$Id: utils.py 651 2009-02-04 15:38:20Z pin $
-$URL: http://svn.luxia.fr/svn/labo/projects/zope/photoprint/trunk/utils.py $
+
+
 """
 
 from AccessControl import ModuleSecurityInfo
 """
 
 from AccessControl import ModuleSecurityInfo
-from Products.PageTemplates.GlobalTranslationService import getGlobalTranslationService
+# TODO: trouver une solution…
+from zope.i18n import translate as i18ntranslate
 from zope.i18nmessageid import MessageFactory
 
 security = ModuleSecurityInfo('Products.photoprint.utils')
 from zope.i18nmessageid import MessageFactory
 
 security = ModuleSecurityInfo('Products.photoprint.utils')
@@ -25,13 +26,13 @@ security.declarePublic('translate')
 def translate(message, context):
        """ Translate i18n message.
        """
 def translate(message, context):
        """ Translate i18n message.
        """
-       GTS = getGlobalTranslationService()
+       GTS = getGlobalTranslationService()
        if isinstance(message, Exception):
                try:
                        message = message[0]
                except (TypeError, IndexError):
                        pass
        if isinstance(message, Exception):
                try:
                        message = message[0]
                except (TypeError, IndexError):
                        pass
-       return GTS.translate('photoprint', message, context=context)
+       return i18ntranslate(message, domain='photoprint', context=context.REQUEST)
 
 security.declarePublic('Message')
 Message = _ = MessageFactory('photoprint')
 
 security.declarePublic('Message')
 Message = _ = MessageFactory('photoprint')