From 27a32598deccba1756d1828182ca3c991101f096 Mon Sep 17 00:00:00 2001
From: Mame Coumba Sall <mame@nexedi.com>
Date: Tue, 17 Mar 2009 14:07:23 +0000
Subject: [PATCH] 2009-03-17 mame *modified script to use generic method to
 translate workflow state titles.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26074 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5_core/Base_getWorkflowHistoryItemList.xml     | 11 ++++++-----
 .../erp5_core/ERP5Site_updateTranslationTable.xml     |  6 ++++--
 product/ERP5/bootstrap/erp5_core/bt/revision          |  2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getWorkflowHistoryItemList.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getWorkflowHistoryItemList.xml
index 179be1b85f..e9e0f981d8 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getWorkflowHistoryItemList.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getWorkflowHistoryItemList.xml
@@ -56,6 +56,8 @@
             <value> <string>request = context.REQUEST\n
 from Products.ERP5Type.Document import newTempBase\n
 from Products.ERP5Type.Document import newTempMappedValue\n
+from Products.ERP5Type.Utils import getTranslationStringWithContext\n
+\n
 \n
 marker = []\n
 result = []\n
@@ -78,8 +80,7 @@ def getActorName(actor):\n
       actor_name_cache[actor] = person.getTitle()\n
     return actor_name_cache[actor]\n
 \n
-def getMessageIdForWorkflowState(title, workflow_id):\n
-  return \'%s [state in %s]\' % (title, workflow_id)\n
+\n
 \n
 # Get history\n
 # XXX Compatibility\n
@@ -128,8 +129,7 @@ for workflow_item in workflow_item_list:\n
       elif key == \'actor\':\n
         value = getActorName(value)\n
       elif same_type(value, \'\') and key in (\'state\' ):\n
-        value = getMessageIdForWorkflowState(value, workflow_id) \n
-        value = context.Localizer.erp5_ui.gettext(value)\n
+        value = getTranslationStringWithContext(context,value, key, workflow_id)\n
       elif same_type(value, \'\') and key in ( \'action\'):\n
         value = context.Localizer.erp5_ui.gettext(value)\n
     if value is marker:\n
@@ -207,6 +207,8 @@ return result\n
                             <string>Products.ERP5Type.Document</string>
                             <string>newTempBase</string>
                             <string>newTempMappedValue</string>
+                            <string>Products.ERP5Type.Utils</string>
+                            <string>getTranslationStringWithContext</string>
                             <string>marker</string>
                             <string>result</string>
                             <string>i</string>
@@ -221,7 +223,6 @@ return result\n
                             <string>dict</string>
                             <string>actor_name_cache</string>
                             <string>getActorName</string>
-                            <string>getMessageIdForWorkflowState</string>
                             <string>history_name</string>
                             <string>workflow_item_list</string>
                             <string>_getitem_</string>
diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.xml
index 2bb39fa602..fdb2d9dde6 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.xml
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.xml
@@ -54,6 +54,7 @@
         <item>
             <key> <string>_body</string> </key>
             <value> <string>from Products.ERP5Type.Document import newTempBase\n
+from Products.ERP5Type.Utils import getTranslationStringWithContext\n
 \n
 supported_languages = context.Localizer.get_supported_languages()\n
 translated_keys = {} # This dict prevents entering the same key twice\n
@@ -82,11 +83,10 @@ for wf in context.portal_workflow.objectValues():\n
         # translate state title as well\n
         if state.title != \'\' :\n
           state_var_title = \'%s_title\' % state_var\n
-          msg_id = \'%s [state in %s]\' % (state.title, wf.id)\n
+          msg_id = msg_id = \'%s [state in %s]\' % (state.title, wf.id)\n
           translated_message = context.Localizer.erp5_ui.gettext(msg_id, default=\'\').encode(\'utf-8\')\n
           if translated_message == \'\':\n
             translated_message = context.Localizer.erp5_ui.gettext(state.title.decode(\'utf-8\'), lang=lang).encode(\'utf-8\')\n
-          #translated_message = context.Localizer.erp5_ui.gettext(state.title.decode(\'utf-8\'), lang=lang).encode(\'utf-8\')\n
           key = (lang, state_var_title, state_id, state.title)\n
           if not translated_keys.has_key(key):\n
             translated_keys[key] = None # mark as translated\n
@@ -163,6 +163,8 @@ return printed\n
                             <string>_print</string>
                             <string>Products.ERP5Type.Document</string>
                             <string>newTempBase</string>
+                            <string>Products.ERP5Type.Utils</string>
+                            <string>getTranslationStringWithContext</string>
                             <string>_getattr_</string>
                             <string>context</string>
                             <string>supported_languages</string>
diff --git a/product/ERP5/bootstrap/erp5_core/bt/revision b/product/ERP5/bootstrap/erp5_core/bt/revision
index d1d06ad36a..a2998a8b4a 100644
--- a/product/ERP5/bootstrap/erp5_core/bt/revision
+++ b/product/ERP5/bootstrap/erp5_core/bt/revision
@@ -1 +1 @@
-1111
\ No newline at end of file
+1120
\ No newline at end of file
-- 
2.30.9