[Erp5-dev] a patch for Localizer patch

Bartłomiej Górny bartek at erp5.pl
Thu Dec 21 16:39:52 CET 2006


Hello

There is sometimes a problem with GlobalTranslationService - in 
ERP5Type/patches/Localizer.py it relies on acquisition to find the Localizer 
object. But if we are processing an email received by zope, we are in context 
of ZMailIn instance, and Localizer can't be found.

So we should either do the simplest thing possible - return untranslated 
message:

Index: ERP5Type/patches/Localizer.py
===================================================================
--- ERP5Type/patches/Localizer.py       (rĂŠvision 11733)
+++ ERP5Type/patches/Localizer.py       (copie de travail)
@@ -83,9 +83,13 @@
   if context is None:
     # Placeless!
     return msgid
+  # XXX patch -because if context is ZMailIn, it is at the site root
+  # and does not find Localizer by acquisition
+  try:
+    return context.Localizer.translate(domain, msgid, *args, **kw)
+  except AttributeError:
+    return msgid

-  return context.Localizer.translate(domain, msgid, *args, **kw)
-
 # Apply the monkey patch.
 from Products.Localizer.Localizer import Localizer
 Localizer.translate = Localizer_translate

or assume the site is under /erp5, or use some other way of finding ERP5Site 
and get Localizer from there.

Bartek



More information about the Erp5-dev mailing list