From 69287938005552b45abb3a102d151b062c55a945 Mon Sep 17 00:00:00 2001
From: iv <isabelle.vallet@nexedi.com>
Date: Fri, 7 Oct 2016 08:55:52 +0000
Subject: [PATCH] ERP5Workflow: put back compatibility code in
 ERP5Site_updateTranslationTable with old DCWorkflow, portal_workflow could
 contain the chain_dict for portal_type/workflow association

---
 .../ERP5Site_updateTranslationTable.py        | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.py
index 312e03a95d..a0014270a7 100644
--- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.py
+++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_updateTranslationTable.py
@@ -52,6 +52,43 @@ for portal_type in portal_type_list:
             translated_keys[key] = None # mark as translated
             object_list.append(dict(language=lang, message_context=state_var_title, portal_type=portal_type.id, original_message=state_id,
                                translated_message=translated_message))
+
+
+### Compatibility code for DC workflow ###
+
+for wf_id, portal_type_list in portal_workflow.getChainDict().items():
+  wf = getattr(portal_workflow, wf_id, None)
+  if wf is None:
+    continue
+  state_var = wf.variables.getStateVar()
+  if wf.states:
+    for state_id, state in wf.states.items():
+      for lang in supported_languages:
+        for portal_type in portal_type_list:
+          key = (lang, portal_type, state_var, state_id)
+          if not translated_keys.has_key(key):
+            translated_message = context.Localizer.erp5_ui.gettext(state_id, lang=lang).encode('utf-8')
+            translated_keys[key] = None # mark as translated
+            object_list.append(dict(language=lang, message_context=state_var, portal_type=portal_type, original_message=state_id,
+                               translated_message=translated_message))
+
+          # translate state title as well
+          if state.title != '' :
+            state_var_title = '%s_title' % state_var
+            msg_id = getMessageIdWithContext(state.title, 'state', wf.id)
+            translated_message = context.Localizer.erp5_ui.gettext(msg_id, default='', lang=lang).encode('utf-8')
+            if translated_message == '':
+              msg_id = state.title
+              translated_message = context.Localizer.erp5_ui.gettext(state.title.decode('utf-8'), lang=lang).encode('utf-8')
+            key = (lang, portal_type, state_var_title, state_id, msg_id)
+            if not translated_keys.has_key(key):
+              translated_keys[key] = None # mark as translated
+              object_list.append(dict(language=lang, message_context=state_var_title, portal_type=portal_type, original_message=state_id,
+                                 translated_message=translated_message))
+
+### End of compatibility code for DC workflow ###
+
+
 if object_list:
   catalog_translation_list(object_list)
 
-- 
2.30.9