Commit 54a2b323 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

Translation: Add portal_type translation customization on transition title

parent 4472929a
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
## Used in Products.ERP5Type.patches.DCWorkflow so this needs to go first... ## Used in Products.ERP5Type.patches.DCWorkflow so this needs to go first...
from six import string_types as basestring from six import string_types as basestring
from Products.ERP5Type.Utils import ensure_list from Products.ERP5Type.Utils import ensure_list, getWorkflowTransitionTranslatedTitle
from Acquisition import aq_parent, aq_inner from Acquisition import aq_parent, aq_inner
from Products.PageTemplates.Expressions import SecureModuleImporter from Products.PageTemplates.Expressions import SecureModuleImporter
from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage from Products.ERP5Type.ConsistencyMessage import ConsistencyMessage
...@@ -563,9 +563,16 @@ class Workflow(XMLObject): ...@@ -563,9 +563,16 @@ class Workflow(XMLObject):
fmt_data._push(info) fmt_data._push(info)
transition_reference = tdef.getReference() transition_reference = tdef.getReference()
fmt_data._push({'transition_id': transition_reference}) fmt_data._push({'transition_id': transition_reference})
localizer = ob.getPortalObject().Localizer
selected_language = localizer.get_selected_language()
transition_title = getWorkflowTransitionTranslatedTitle(
localizer, self.id, selected_language, ob.getPortalType(),
tdef.getActionName() % fmt_data,
)[0]
result.append({ result.append({
'id': transition_reference, 'id': transition_reference,
'name': tdef.getActionName() % fmt_data, 'name': transition_title,
'url': tdef.getAction() % fmt_data, 'url': tdef.getAction() % fmt_data,
'icon': tdef.getIcon() % fmt_data, 'icon': tdef.getIcon() % fmt_data,
'permissions': (), # Predetermined. 'permissions': (), # Predetermined.
......
...@@ -391,6 +391,20 @@ def getTranslatedWorkflowStateWithPortalType(localizer, workflow_id, lang, ...@@ -391,6 +391,20 @@ def getTranslatedWorkflowStateWithPortalType(localizer, workflow_id, lang,
if translated_message: if translated_message:
return translated_message, msg_id return translated_message, msg_id
def getWorkflowTransitionTranslatedTitle(localizer, workflow_id, lang,
portal_type, transition_title):
for msg_id, default in [
(getMessageIdWithContext(transition_title, 'transition', portal_type), ''),
(getMessageIdWithContext(transition_title, 'transition', workflow_id), ''),
(transition_title.decode('utf-8'), None),
]:
translated_message = localizer.erp5_ui.gettext(
msg_id,
default=default,
lang=lang
).encode('utf-8')
if translated_message:
return translated_message, msg_id
#Get translation of msg id #Get translation of msg id
def getTranslationStringWithContext(self, msg_id, context, context_id): def getTranslationStringWithContext(self, msg_id, context, context_id):
......
...@@ -187,7 +187,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic( ...@@ -187,7 +187,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
'sortValueList', 'convertToUpperCase', 'UpperCase', 'sortValueList', 'convertToUpperCase', 'UpperCase',
'convertToMixedCase', 'cartesianProduct', 'sleep', 'getCommonTimeZoneList', 'convertToMixedCase', 'cartesianProduct', 'sleep', 'getCommonTimeZoneList',
'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext', 'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext',
'getTranslatedWorkflowStateWithPortalType', 'getTranslatedWorkflowStateWithPortalType', 'getWorkflowTransitionTranslatedTitle',
'Email_parseAddressHeader', 'guessEncodingFromText', 'Email_parseAddressHeader', 'guessEncodingFromText',
'isValidTALESExpression', 'isValidTALESExpression',
'ensure_list', 'bytes2str', 'str2bytes', 'unicode2str', 'ensure_list', 'bytes2str', 'str2bytes', 'unicode2str',
......
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