Commit 349258e5 authored by Jérome Perrin's avatar Jérome Perrin

Fix translations with ${portal_type} variables

See merge request nexedi/erp5!1236
parents a52c7d5d 27238127
portal = context.getPortalObject()
translateString = portal.Base_translateString
logged_in_user_value = portal.portal_membership.getAuthenticatedMember().getUserValue()
now = DateTime()
......@@ -69,11 +70,11 @@ for method_id in {
return support_request.Base_redirect(
keep_items={
'portal_status_message': portal.Base_translateString(
'New ${portal_type} created.',
mapping={
'portal_type': portal.Base_translateString('Support Request'),
},
'portal_status_message': translateString(
'New Support Request created.',
default=translateString(
"New ${portal_type} created.",
mapping={"portal_type": translateString("Support Request")}),
),
},
)
......@@ -36,7 +36,8 @@ if related_order_uid_list:
keep_items=dict(reset=1,
uid=related_order_uid_list))
return context.Base_redirect(form_id,
keep_items=dict(portal_status_message=
translateString('No ${portal_type} related.',
mapping=dict(portal_type=translateString(order_type)))))
return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=translateString(
'No %s Related' % order_type,
default=translateString('No ${portal_type} related.',
mapping={'portal_type': translateString(order_type)}))))
......@@ -37,7 +37,8 @@ if related_invoice_uid_list:
keep_items=dict(reset=1,
uid=related_invoice_uid_list))
return context.Base_redirect(form_id,
keep_items=dict(portal_status_message=
translateString('No ${portal_type} related.',
mapping=dict(portal_type=translateString(invoice_type)))))
return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=translateString(
'No %s Related' % invoice_type,
default=translateString('No ${portal_type} related.',
mapping={'portal_type': translateString(invoice_type)}))))
......@@ -7870,6 +7870,9 @@ msgstr "Nouvelle page par défaut pour la section ${web_section}."
msgid "New event created."
msgstr "Nouvel évènement créé."
msgid "New Support Request created."
msgstr "Nouvelle demande d'assistance créée."
msgid "New post created in background."
msgstr "Nouveau message créé en arrière-plan."
......
# pylint:disable=redefined-builtin
# this script uses file= argument
portal = context.getPortalObject()
translateString = portal.Base_translateString
logged_in_user_value = portal.portal_membership.getAuthenticatedMember().getUserValue()
now = DateTime()
......@@ -34,11 +35,11 @@ if description is not None or file is not None:
return support_request.Base_redirect('officejs_support_request_view',
keep_items={
'portal_status_message': portal.Base_translateString(
'New ${portal_type} created.',
mapping={
'portal_type': 'Support Request',
},
'portal_status_message': translateString(
'New Support Request created.',
default=translateString(
"New ${portal_type} created.",
mapping={"portal_type": translateString("Support Request")}),
),
},
)
......@@ -25,22 +25,24 @@ related_object_list = context.getRelatedValueList(
portal_type=portal_type)
if not related_object_list:
message = portal.Base_translateString('No ${portal_type} related.',
mapping={'portal_type': portal_type})
return context.Base_redirect(keep_items=dict(portal_status_message=message))
return context.Base_redirect(form_id, keep_items=dict(
portal_status_message=portal.Base_translateString(
'No %s Related' % portal_type,
default=portal.Base_translateString('No ${portal_type} related.',
mapping={'portal_type': portal.Base_translateString(portal_type)}))))
elif len(related_object_list) == 1:
related_object = related_object_list[0]
message = portal.Base_translateString(
'${this_portal_type} related to ${that_portal_type}: ${that_title}.',
return related_object.Base_redirect(keep_items=dict(
reset=1,
portal_status_message=portal.Base_translateString(
# first, try to get a full translated message with portal types
"%s related to %s." % (related_object.getPortalType(), context.getPortalType()),
# if not found, fallback to generic translation
default=portal.Base_translateString('${this_portal_type} related to ${that_portal_type} : ${that_title}.',
mapping={"this_portal_type": related_object.getTranslatedPortalType(),
"that_portal_type": context.getTranslatedPortalType(),
"that_title": context.getTitleOrId()})
return related_object.Base_redirect(
keep_items=dict(reset=1,
portal_status_message=message))
"that_title": context.getTitleOrId()}))))
else:
# XXX: Use POST rather than GET because of GET URL length limitation?
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>portal_type</string> </value>
<value> <string>portal_type, form_id=\'\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -4,19 +4,24 @@ transformation_value_list = context.getRelatedValueList(checked_permission='View
portal_type=('Transformation',
'Transformation Transformed Resource'))
if len(transformation_value_list) == 0:
return context.Base_redirect('view',
return context.Base_redirect(form_id,
keep_items=dict(portal_status_message=translateString('No Transformation related.')))
elif len(transformation_value_list) == 1:
related_object = transformation_value_list[0]
if related_object.getPortalType() == 'Transformation Transformed Resource':
related_object = related_object.getParentValue()
return related_object.Base_redirect(
'view',
keep_items=dict(reset=1,
portal_status_message=translateString('${this_portal_type} related to ${that_portal_type} : ${that_title}.',
return related_object.Base_redirect(keep_items=dict(
reset=1,
portal_status_message=portal.Base_translateString(
# first, try to get a full translated message with portal types
"%s related to %s." % (related_object.getPortalType(), context.getPortalType()),
# if not found, fallback to generic translation
default=translateString('${this_portal_type} related to ${that_portal_type} : ${that_title}.',
mapping={"this_portal_type": related_object.getTranslatedPortalType(),
"that_portal_type": context.getTranslatedPortalType(),
"that_title": context.getTitleOrId()})))
"that_title": context.getTitleOrId()}))))
else:
transformation_uid_list = []
for value in transformation_value_list:
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>form_id=\'\'</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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