Commit 853b91df authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Translation: Add portal_type translation customization on transition title

parent b06d1a22
......@@ -1044,7 +1044,8 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'href': '%s' % view_action['url'],
'name': view_action['id'],
'icon': view_action['icon'],
'title': Base_translateString(view_action['title'])
'title': Base_translateString(view_action['title']) \
if erp5_action_key != "workflow" else view_action['title'],
})
# Try to embed the form in the result
if (view == view_action['id']):
......
......@@ -382,6 +382,20 @@ def getTranslatedWorkflowStateWithPortalType(localizer, workflow_id, lang,
if translated_message:
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
def getTranslationStringWithContext(self, msg_id, context, context_id):
......
......@@ -165,7 +165,7 @@ ModuleSecurityInfo('Products.ERP5Type.Utils').declarePublic(
'sortValueList', 'convertToUpperCase', 'UpperCase',
'convertToMixedCase', 'cartesianProduct', 'sleep', 'getCommonTimeZoneList',
'int2letter', 'getMessageIdWithContext', 'getTranslationStringWithContext',
'getTranslatedWorkflowStateWithPortalType',
'getTranslatedWorkflowStateWithPortalType', 'getWorkflowTransitionTranslatedTitle',
'Email_parseAddressHeader', 'guessEncodingFromText',
'isValidTALESExpression')
......
......@@ -32,7 +32,7 @@ from Products.CMFCore.utils import _getAuthenticatedUser
from DocumentTemplate.DT_Util import TemplateDict
from DateTime import DateTime
from Products.ERP5Type.Cache import CachingMethod
from Products.ERP5Type.Utils import convertToMixedCase
from Products.ERP5Type.Utils import convertToMixedCase, getWorkflowTransitionTranslatedTitle
import sys
from Acquisition import aq_base
from copy import deepcopy
......@@ -239,9 +239,17 @@ def DCWorkflowDefinition_listObjectActions(self, info):
fmt_data = TemplateDict()
fmt_data._push(info)
fmt_data._push({'transition_id': tid})
localizer = ob.getPortalObject().Localizer
selected_language = localizer.get_selected_language()
transition_title = getWorkflowTransitionTranslatedTitle(
localizer, self.id, selected_language, ob.getPortalType(),
tdef.actbox_name % fmt_data,
)[0]
res.append((tid, {
'id': tid,
'name': tdef.actbox_name % fmt_data,
'name': transition_title,
'url': tdef.actbox_url % fmt_data,
'icon': tdef.actbox_icon % fmt_data,
'permissions': (), # Predetermined.
......
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