From abe21e5b3a5f6446e2ec6b5c4ff2556269166f6d Mon Sep 17 00:00:00 2001
From: Guillaume Michon <guillaume@nexedi.com>
Date: Thu, 16 Mar 2006 16:00:39 +0000
Subject: [PATCH] Make sure Message instances are passed as unicode to Template

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6120 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/patches/Localizer.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/product/ERP5Type/patches/Localizer.py b/product/ERP5Type/patches/Localizer.py
index 812518229a..ca5cbbdcc2 100755
--- a/product/ERP5Type/patches/Localizer.py
+++ b/product/ERP5Type/patches/Localizer.py
@@ -21,7 +21,7 @@ try:
 except ImportError:
   from Products.ERP5Type.patches.string import Template
 
-
+from Products.ERP5Type.Message import Message
 from zLOG import LOG
 
 class LocalizerPatchError(Exception):
@@ -39,7 +39,6 @@ def Localizer_translate(self, domain, msgid, mapping=None, *args, **kw):
     """
       This translate() method use Localizer and support catalog aliases.
     """
-
     # This dict define the alias between old Translation Service catalog id
     #   and new Localizer Message Catalog.
     message_catalog_aliases = { "Default": "default"
@@ -70,9 +69,12 @@ def Localizer_translate(self, domain, msgid, mapping=None, *args, **kw):
         translated_str = translated_str.decode('utf8')
       # make sure all values in the mapping are unicode
       for k, v in mapping.items():
-        if isinstance(v, str) :
+        if isinstance(v, str):
           v = v.decode('utf8')
+        elif isinstance(v, Message):
+          v = str(v).decode('utf8')
         unicode_mapping[k] = v
+      
       translated_str = Template(translated_str).substitute(unicode_mapping)
     return translated_str
 
-- 
2.30.9