Commit 27a32598 authored by Mame Coumba Sall's avatar Mame Coumba Sall

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
parent da1f6cfe
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
<value> <string>request = context.REQUEST\n <value> <string>request = context.REQUEST\n
from Products.ERP5Type.Document import newTempBase\n from Products.ERP5Type.Document import newTempBase\n
from Products.ERP5Type.Document import newTempMappedValue\n from Products.ERP5Type.Document import newTempMappedValue\n
from Products.ERP5Type.Utils import getTranslationStringWithContext\n
\n
\n \n
marker = []\n marker = []\n
result = []\n result = []\n
...@@ -78,8 +80,7 @@ def getActorName(actor):\n ...@@ -78,8 +80,7 @@ def getActorName(actor):\n
actor_name_cache[actor] = person.getTitle()\n actor_name_cache[actor] = person.getTitle()\n
return actor_name_cache[actor]\n return actor_name_cache[actor]\n
\n \n
def getMessageIdForWorkflowState(title, workflow_id):\n \n
return \'%s [state in %s]\' % (title, workflow_id)\n
\n \n
# Get history\n # Get history\n
# XXX Compatibility\n # XXX Compatibility\n
...@@ -128,8 +129,7 @@ for workflow_item in workflow_item_list:\n ...@@ -128,8 +129,7 @@ for workflow_item in workflow_item_list:\n
elif key == \'actor\':\n elif key == \'actor\':\n
value = getActorName(value)\n value = getActorName(value)\n
elif same_type(value, \'\') and key in (\'state\' ):\n elif same_type(value, \'\') and key in (\'state\' ):\n
value = getMessageIdForWorkflowState(value, workflow_id) \n value = getTranslationStringWithContext(context,value, key, workflow_id)\n
value = context.Localizer.erp5_ui.gettext(value)\n
elif same_type(value, \'\') and key in ( \'action\'):\n elif same_type(value, \'\') and key in ( \'action\'):\n
value = context.Localizer.erp5_ui.gettext(value)\n value = context.Localizer.erp5_ui.gettext(value)\n
if value is marker:\n if value is marker:\n
...@@ -207,6 +207,8 @@ return result\n ...@@ -207,6 +207,8 @@ return result\n
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempBase</string> <string>newTempBase</string>
<string>newTempMappedValue</string> <string>newTempMappedValue</string>
<string>Products.ERP5Type.Utils</string>
<string>getTranslationStringWithContext</string>
<string>marker</string> <string>marker</string>
<string>result</string> <string>result</string>
<string>i</string> <string>i</string>
...@@ -221,7 +223,6 @@ return result\n ...@@ -221,7 +223,6 @@ return result\n
<string>dict</string> <string>dict</string>
<string>actor_name_cache</string> <string>actor_name_cache</string>
<string>getActorName</string> <string>getActorName</string>
<string>getMessageIdForWorkflowState</string>
<string>history_name</string> <string>history_name</string>
<string>workflow_item_list</string> <string>workflow_item_list</string>
<string>_getitem_</string> <string>_getitem_</string>
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Document import newTempBase\n <value> <string>from Products.ERP5Type.Document import newTempBase\n
from Products.ERP5Type.Utils import getTranslationStringWithContext\n
\n \n
supported_languages = context.Localizer.get_supported_languages()\n supported_languages = context.Localizer.get_supported_languages()\n
translated_keys = {} # This dict prevents entering the same key twice\n translated_keys = {} # This dict prevents entering the same key twice\n
...@@ -82,11 +83,10 @@ for wf in context.portal_workflow.objectValues():\n ...@@ -82,11 +83,10 @@ for wf in context.portal_workflow.objectValues():\n
# translate state title as well\n # translate state title as well\n
if state.title != \'\' :\n if state.title != \'\' :\n
state_var_title = \'%s_title\' % state_var\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 translated_message = context.Localizer.erp5_ui.gettext(msg_id, default=\'\').encode(\'utf-8\')\n
if translated_message == \'\':\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
#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 key = (lang, state_var_title, state_id, state.title)\n
if not translated_keys.has_key(key):\n if not translated_keys.has_key(key):\n
translated_keys[key] = None # mark as translated\n translated_keys[key] = None # mark as translated\n
...@@ -163,6 +163,8 @@ return printed\n ...@@ -163,6 +163,8 @@ return printed\n
<string>_print</string> <string>_print</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempBase</string> <string>newTempBase</string>
<string>Products.ERP5Type.Utils</string>
<string>getTranslationStringWithContext</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>supported_languages</string> <string>supported_languages</string>
......
1111 1120
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment