From 59175bf79f670c05c85aca616784783e17079330 Mon Sep 17 00:00:00 2001
From: Sebastien Robin <seb@nexedi.com>
Date: Thu, 9 Mar 2006 16:23:59 +0000
Subject: [PATCH] added try/except because sometimes get_context does not work

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6064 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../portal_skins/erp5_core/Base_translateString.xml      | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.xml
index dab4633386..729a33b857 100755
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_translateString.xml
@@ -69,9 +69,11 @@
             <value> <string>from Products.CMFCore.utils import getToolByName\n
 translation_service = getToolByName(context, \'Localizer\', None)\n
 if translation_service is not None :\n
-  return translation_service.translate(catalog, msg, **kw).encode(encoding)\n
-else :\n
-  return msg\n
+  try:\n
+    return translation_service.translate(catalog, msg, **kw).encode(encoding)\n
+  except AttributeError: # This happens in unit testing, because it is not able to find something with get_context()\n
+    pass\n
+return msg\n
 </string> </value>
         </item>
         <item>
@@ -129,6 +131,7 @@ else :\n
                             <string>translation_service</string>
                             <string>_getattr_</string>
                             <string>_apply_</string>
+                            <string>AttributeError</string>
                           </tuple>
                         </value>
                     </item>
-- 
2.30.9