From b0d9d922ae72d31ff6da8be25becfd6d5ee8752e Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Thu, 28 Aug 2008 08:39:10 +0000 Subject: [PATCH] Use N_ function for translation message so that message will be found automatically. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23207 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Form/MultiRelationField.py | 27 ++++++++++++-------------- product/ERP5Form/SelectionTool.py | 10 +++++----- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/product/ERP5Form/MultiRelationField.py b/product/ERP5Form/MultiRelationField.py index e230f26946..611c0706bf 100644 --- a/product/ERP5Form/MultiRelationField.py +++ b/product/ERP5Form/MultiRelationField.py @@ -42,6 +42,9 @@ from Globals import get_request from AccessControl import Unauthorized from AccessControl import getSecurityManager +# a marker function for translation. +N_ = lambda msg, **kw: str(Message('erp5_ui', msg, **kw)) + # Max. number of catalog result MAX_SELECT = 30 NEW_CONTENT_PREFIX = '_newContent_' @@ -556,12 +559,10 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): # form is not validated ############################## portal_type = relation_uid[len(NEW_CONTENT_PREFIX):] - translated_portal_type = Message(domain='erp5_ui', - message=portal_type) + translated_portal_type = N_(portal_type) # XXX Replace New by Add - message = Message( - domain='erp5_ui', message='New ${portal_type}', - mapping={'portal_type': translated_portal_type}) + message = N_('New ${portal_type}', + mapping={'portal_type': translated_portal_type}) display_text = message else: display_text = 'Object has been deleted' @@ -653,11 +654,9 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): # form is not validated ############################## portal_type = relation_uid[len(NEW_CONTENT_PREFIX):] - translated_portal_type = Message(domain='erp5_ui', - message=portal_type) - message = Message( - domain='erp5_ui', message='New ${portal_type}', - mapping={'portal_type': translated_portal_type}) + translated_portal_type = N_(portal_type) + message = N_('New ${portal_type}', + mapping={'portal_type': translated_portal_type}) display_text = message else: display_text = 'Object has been deleted' @@ -736,11 +735,9 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): pass else: if portal_type in module.getVisibleAllowedContentTypeList(): - translated_portal_type = Message(domain='erp5_ui', - message=portal_type) - message = Message( - domain='erp5_ui', message='Add ${portal_type}', - mapping={'portal_type': translated_portal_type}) + translated_portal_type = N_(portal_type) + message = N_('Add ${portal_type}', + mapping={'portal_type':translated_portal_type}) menu_item_list.append((message, '%s%s' % (NEW_CONTENT_PREFIX, portal_type))) diff --git a/product/ERP5Form/SelectionTool.py b/product/ERP5Form/SelectionTool.py index f516adac4f..71a35df40f 100644 --- a/product/ERP5Form/SelectionTool.py +++ b/product/ERP5Form/SelectionTool.py @@ -46,6 +46,9 @@ from Acquisition import aq_base from Products.ERP5Type.Message import Message import warnings +# a marker function for translation. +N_ = lambda msg, **kw: str(Message('erp5_ui', msg, **kw)) + _MARKER = [] class SelectionError( Exception ): @@ -1112,12 +1115,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): if len(field_value) > 1 and isinstance(field_value, type([])): field_value = ' OR '.join(field_value) REQUEST.form[field_key] = field_value - portal_status_message = Message( - domain='erp5_ui', - message="Please select one (or more) object.") + portal_status_message = N_("Please select one (or more) object.") else: - portal_status_message = Message(domain='erp5_ui', - message="Please select one object.") + portal_status_message = N_("Please select one object.") # Save the current REQUEST form -- 2.30.9