From a15ab2062fd3436a7acc0214e9b507226ec36ce7 Mon Sep 17 00:00:00 2001
From: Kevin Deldycke <kevin@nexedi.com>
Date: Tue, 24 Jan 2006 10:59:21 +0000
Subject: [PATCH] translate() method support language and mapping as parameters

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5273 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ListBox.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index e3f84844be..e2607df420 100755
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -546,8 +546,8 @@ class ListBoxWidget(Widget.Widget):
           list_action += '&reset=1'
         object_list = []
 
-        #translate = portal_object.translation_service.translate
-        # This translate() method has the same prototype as the one defined in Translation Service
+        # This translate() method has the same prototype as the one defined
+        #   in Translation Service, but use Localizer.
         global localizer, msg_catalog_binding
         localizer = portal_object.Localizer
         msg_catalog_binding = { "ui"     : "erp5_ui"
@@ -565,10 +565,13 @@ class ListBoxWidget(Widget.Widget):
           localizer_cat = localizer[localizer_cat_id]
           if default == None:
             default = []
-          return localizer_cat.gettext( message = msgid
-                                      , lang    = None
-                                      , default = default
-                                      )
+          translated_str = localizer_cat.gettext( message = msgid
+                                                , lang    = target_language
+                                                , default = default
+                                                )
+          if type(mapping) is type({}):
+            return string.Template(translated_str).substitute(mapping)
+          return translated_str
 
         # Make sure list_result_item is defined
         list_result_item = []
-- 
2.30.9