Commit ed918105 authored by Yusei Tahara's avatar Yusei Tahara

Use translateString instead of N_.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23233 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 93a07b8c
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
from Products.ERP5Type.Constraint import Constraint from Products.ERP5Type.Constraint import Constraint
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
N_ = lambda msg: msg # just to extract messages translateString = lambda msg: msg # just to extract messages
_MARKER = [] _MARKER = []
class AccountTypeConstraint(Constraint): class AccountTypeConstraint(Constraint):
...@@ -53,8 +53,9 @@ class AccountTypeConstraint(Constraint): ...@@ -53,8 +53,9 @@ class AccountTypeConstraint(Constraint):
_message_id_list = ['message_inconsistent_account_type'] _message_id_list = ['message_inconsistent_account_type']
message_inconsistent_account_type = N_('Account is member'\ message_inconsistent_account_type = translateString(
' of ${category}, this should have account_type'\ 'Account is member'
' of ${category}, this should have account_type'
' in ${account_type_list}') ' in ${account_type_list}')
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
...@@ -62,8 +63,9 @@ class AccountTypeConstraint(Constraint): ...@@ -62,8 +63,9 @@ class AccountTypeConstraint(Constraint):
""" """
errors = [] errors = []
if getattr(obj, 'getAccountType', _MARKER) is _MARKER: if getattr(obj, 'getAccountType', _MARKER) is _MARKER:
errors.append(self._generateError(obj, errors.append(self._generateError(
N_("Account doesn't have account_type category"))) obj,
translateString("Account doesn't have account_type category")))
else: else:
account_type_map = getattr(self, '_account_type_map', ()) account_type_map = getattr(self, '_account_type_map', ())
if not account_type_map: if not account_type_map:
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
from Products.ERP5Type.Constraint import Constraint from Products.ERP5Type.Constraint import Constraint
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import Message
N_ = lambda msg: msg # just to extract messages translateString = lambda msg: msg # just to extract messages
class AccountingTransactionBalance(Constraint): class AccountingTransactionBalance(Constraint):
"""Check that accounting transaction total debit and total credit are equals. """Check that accounting transaction total debit and total credit are equals.
...@@ -37,9 +37,9 @@ class AccountingTransactionBalance(Constraint): ...@@ -37,9 +37,9 @@ class AccountingTransactionBalance(Constraint):
_message_id_list = [ 'message_transaction_not_balanced_for_source', _message_id_list = [ 'message_transaction_not_balanced_for_source',
'message_transaction_not_balanced_for_destination' ] 'message_transaction_not_balanced_for_destination' ]
message_transaction_not_balanced_for_source = N_( message_transaction_not_balanced_for_source = translateString(
'Transaction is not Balanced') 'Transaction is not Balanced')
message_transaction_not_balanced_for_destination = N_( message_transaction_not_balanced_for_destination = translateString(
'Transaction is not Balanced') 'Transaction is not Balanced')
def checkConsistency(self, obj, fixit=0): def checkConsistency(self, obj, fixit=0):
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
############################################################################## ##############################################################################
from Products.ERP5Type.Constraint import Constraint from Products.ERP5Type.Constraint import Constraint
N_ = lambda msg, **kw: msg # just to extract messages translateString = lambda msg, **kw: msg # just to extract messages
_MARKER = [] _MARKER = []
...@@ -45,12 +45,12 @@ class DocumentReferenceConstraint(Constraint): ...@@ -45,12 +45,12 @@ class DocumentReferenceConstraint(Constraint):
'message_another_document_exists', 'message_another_document_exists',
'message_multiple_documents_exists' ] 'message_multiple_documents_exists' ]
message_property_not_defined = N_( message_property_not_defined = translateString(
'Property ${property_id} was not defined') 'Property ${property_id} was not defined')
message_another_document_exists = N_( message_another_document_exists = translateString(
'Another document ${document_reference} - ' 'Another document ${document_reference} - '
'${document_language} - ${document_version} already exists') '${document_language} - ${document_version} already exists')
message_multiple_documents_exists = N_( message_multiple_documents_exists = translateString(
'Multiple (${document_count}) documents ${document_reference} - ' 'Multiple (${document_count}) documents ${document_reference} - '
'${document_language} - ${document_version} already exists') '${document_language} - ${document_version} already exists')
......
...@@ -16,6 +16,7 @@ from DateTime import DateTime ...@@ -16,6 +16,7 @@ from DateTime import DateTime
from ZTUtils import make_query from ZTUtils import make_query
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from zLOG import LOG, PROBLEM from zLOG import LOG, PROBLEM
from Products.ERP5Type.Message import translateString
class InventoryBrain(ZSQLBrain): class InventoryBrain(ZSQLBrain):
""" """
...@@ -260,7 +261,6 @@ class InventoryListBrain(ZSQLBrain): ...@@ -260,7 +261,6 @@ class InventoryListBrain(ZSQLBrain):
# Returns an explanation of the movement # Returns an explanation of the movement
o = self.getObject() o = self.getObject()
if o is not None: if o is not None:
N_ = lambda msg, **kw: o.Localizer.translate('ui', msg, **kw)
# Get the delivery/order # Get the delivery/order
if not getattr(o, 'isDelivery', 0): if not getattr(o, 'isDelivery', 0):
delivery = o.getExplanationValue() delivery = o.getExplanationValue()
...@@ -275,16 +275,16 @@ class InventoryListBrain(ZSQLBrain): ...@@ -275,16 +275,16 @@ class InventoryListBrain(ZSQLBrain):
} }
causality = delivery.getCausalityValue() causality = delivery.getCausalityValue()
if causality is not None: if causality is not None:
mapping['causality_portal_type'] = \ mapping['causality_portal_type'] = causality.getTranslatedPortalType()
causality.getTranslatedPortalType()
mapping['causality_title'] = causality.getTitleOrId() mapping['causality_title'] = causality.getTitleOrId()
return N_("${delivery_portal_type} ${delivery_title} "\ return translateString(
"${delivery_portal_type} ${delivery_title} "
"(${causality_portal_type} ${causality_title})", "(${causality_portal_type} ${causality_title})",
mapping = mapping ) mapping=mapping)
else : else :
return N_("${delivery_portal_type} ${delivery_title}", return translateString("${delivery_portal_type} ${delivery_title}",
mapping = mapping ) mapping=mapping)
return N_('Unknown') return translateString('Unknown')
class TrackingListBrain(InventoryListBrain): class TrackingListBrain(InventoryListBrain):
""" """
......
...@@ -35,10 +35,10 @@ from Products.ERP5 import _dtmldir ...@@ -35,10 +35,10 @@ from Products.ERP5 import _dtmldir
from zLOG import LOG from zLOG import LOG
import time, random, md5 import time, random, md5
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import translateString
from Acquisition import aq_base from Acquisition import aq_base
from BTrees.OOBTree import OOBTree from BTrees.OOBTree import OOBTree
N_ = lambda msgid, **kw: Message('ui', msgid, **kw)
class PasswordTool(BaseTool): class PasswordTool(BaseTool):
""" """
...@@ -73,8 +73,8 @@ class PasswordTool(BaseTool): ...@@ -73,8 +73,8 @@ class PasswordTool(BaseTool):
# check user exists # check user exists
user_list = self.portal_catalog.unrestrictedSearchResults(portal_type="Person", reference=user_login) user_list = self.portal_catalog.unrestrictedSearchResults(portal_type="Person", reference=user_login)
if len(user_list) == 0: if len(user_list) == 0:
msg = N_("User ${user} doesn't exist.", msg = translateString("User ${user} doesn't exist.",
mapping={'user': user_login}) mapping={'user':user_login})
if REQUEST is not None: if REQUEST is not None:
ret_url = '%s/login_form?portal_status_message=%s' % \ ret_url = '%s/login_form?portal_status_message=%s' % \
(self.getPortalObject().absolute_url(),msg) (self.getPortalObject().absolute_url(),msg)
...@@ -101,7 +101,7 @@ class PasswordTool(BaseTool): ...@@ -101,7 +101,7 @@ class PasswordTool(BaseTool):
"Thank you" %(self.getPortalObject().getTitle(), url, expiration_date) "Thank you" %(self.getPortalObject().getTitle(), url, expiration_date)
self.portal_notifications.sendMessage(sender=None, recipient=[user,], subject=subject, message=message) self.portal_notifications.sendMessage(sender=None, recipient=[user,], subject=subject, message=message)
if REQUEST is not None: if REQUEST is not None:
msg = N_("An email has been sent to you.") msg = translateString("An email has been sent to you.")
ret_url = '%s/login_form?portal_status_message=%s' % \ ret_url = '%s/login_form?portal_status_message=%s' % \
(self.getPortalObject().absolute_url(),msg) (self.getPortalObject().absolute_url(),msg)
return REQUEST.RESPONSE.redirect( ret_url ) return REQUEST.RESPONSE.redirect( ret_url )
...@@ -140,7 +140,7 @@ class PasswordTool(BaseTool): ...@@ -140,7 +140,7 @@ class PasswordTool(BaseTool):
# check date # check date
current_date = DateTime() current_date = DateTime()
if current_date > expiration_date: if current_date > expiration_date:
msg = N_("Date has expire.",) msg = translateString("Date has expire.")
ret_url = '%s/login_form?portal_status_message=%s' % \ ret_url = '%s/login_form?portal_status_message=%s' % \
(self.getPortalObject().absolute_url(), msg) (self.getPortalObject().absolute_url(), msg)
return REQUEST.RESPONSE.redirect( ret_url ) return REQUEST.RESPONSE.redirect( ret_url )
...@@ -172,11 +172,11 @@ class PasswordTool(BaseTool): ...@@ -172,11 +172,11 @@ class PasswordTool(BaseTool):
if register_user_login is None: if register_user_login is None:
msg = "" msg = ""
elif register_user_login != user_login: elif register_user_login != user_login:
msg = N_("Bad login provided.",) msg = translateString("Bad login provided.")
elif current_date > expiration_date: elif current_date > expiration_date:
msg = N_("Date has expire.",) msg = translateString("Date has expire.")
elif password != password_confirmation: elif password != password_confirmation:
msg = N_("Password are not identical.",) msg = translateString("Password are not identical.")
if msg is not None: if msg is not None:
if REQUEST is not None: if REQUEST is not None:
ret_url = '%s/login_form?portal_status_message=%s' % \ ret_url = '%s/login_form?portal_status_message=%s' % \
...@@ -192,7 +192,7 @@ class PasswordTool(BaseTool): ...@@ -192,7 +192,7 @@ class PasswordTool(BaseTool):
person._setPassword(password) person._setPassword(password)
person.reindexObject() person.reindexObject()
if REQUEST is not None: if REQUEST is not None:
msg = N_("Password changed.",) msg = translateString("Password changed.")
ret_url = '%s/login_form?portal_status_message=%s' % \ ret_url = '%s/login_form?portal_status_message=%s' % \
(self.getPortalObject().absolute_url(), msg) (self.getPortalObject().absolute_url(), msg)
return REQUEST.RESPONSE.redirect( ret_url ) return REQUEST.RESPONSE.redirect( ret_url )
......
...@@ -51,10 +51,9 @@ try: ...@@ -51,10 +51,9 @@ try:
from base64 import b64encode, b64decode from base64 import b64encode, b64decode
except ImportError: except ImportError:
from base64 import encodestring as b64encode, decodestring as b64decode from base64 import encodestring as b64encode, decodestring as b64decode
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import translateString
from zLOG import LOG, INFO from zLOG import LOG, INFO
N_ = lambda msgid, **kw: Message('ui', msgid, **kw)
WIN = os.name == 'nt' WIN = os.name == 'nt'
...@@ -162,8 +161,8 @@ class TemplateTool (BaseTool): ...@@ -162,8 +161,8 @@ class TemplateTool (BaseTool):
path = pathname2url(path) path = pathname2url(path)
business_template.export(path=path, local=1) business_template.export(path=path, local=1)
if REQUEST is not None: if REQUEST is not None:
psm = N_('Saved+in+${path}+.', psm = translateString('Saved+in+${path}+.',
mapping={'path': pathname2url(path)}) mapping={'path':pathname2url(path)})
ret_url = '%s/%s?portal_status_message=%s' % \ ret_url = '%s/%s?portal_status_message=%s' % \
(business_template.absolute_url(), (business_template.absolute_url(),
REQUEST.get('form_id', 'view'), psm) REQUEST.get('form_id', 'view'), psm)
...@@ -283,7 +282,7 @@ class TemplateTool (BaseTool): ...@@ -283,7 +282,7 @@ class TemplateTool (BaseTool):
if REQUEST is not None: if REQUEST is not None:
ret_url = bt.absolute_url() + '/view' ret_url = bt.absolute_url() + '/view'
psm = N_("Business+Template+Downloaded+Successfully") psm = translateString("Business+Template+Downloaded+Successfully")
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s" REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
% (ret_url, psm)) % (ret_url, psm))
...@@ -398,7 +397,7 @@ class TemplateTool (BaseTool): ...@@ -398,7 +397,7 @@ class TemplateTool (BaseTool):
if (import_file is None) or (len(import_file.read()) == 0): if (import_file is None) or (len(import_file.read()) == 0):
if REQUEST is not None: if REQUEST is not None:
psm = N_('No+file+or+an+empty+file+was+specified') psm = translateString('No+file+or+an+empty+file+was+specified')
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s" REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
% (self.absolute_url(), psm)) % (self.absolute_url(), psm))
return return
...@@ -423,7 +422,7 @@ class TemplateTool (BaseTool): ...@@ -423,7 +422,7 @@ class TemplateTool (BaseTool):
if (batch_mode == 0) and \ if (batch_mode == 0) and \
(REQUEST is not None): (REQUEST is not None):
ret_url = bt.absolute_url() + '/view' ret_url = bt.absolute_url() + '/view'
psm = N_("Business+Templates+Imported+Successfully") psm = translateString("Business+Templates+Imported+Successfully")
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s" REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
% (ret_url, psm)) % (ret_url, psm))
elif (batch_mode == 1): elif (batch_mode == 1):
...@@ -542,7 +541,7 @@ class TemplateTool (BaseTool): ...@@ -542,7 +541,7 @@ class TemplateTool (BaseTool):
if REQUEST is not None: if REQUEST is not None:
ret_url = self.absolute_url() + '/' + REQUEST.get('dialog_id', 'view') ret_url = self.absolute_url() + '/' + REQUEST.get('dialog_id', 'view')
psm = N_("Business+Templates+Updated+Successfully") psm = translateString("Business+Templates+Updated+Successfully")
REQUEST.RESPONSE.redirect("%s?cancel_url=%s&portal_status_message=%s&dialog_category=object_exchange&selection_name=business_template_selection" REQUEST.RESPONSE.redirect("%s?cancel_url=%s&portal_status_message=%s&dialog_category=object_exchange&selection_name=business_template_selection"
% (ret_url, REQUEST.form.get('cancel_url', ''), psm)) % (ret_url, REQUEST.form.get('cancel_url', ''), psm))
......
...@@ -47,7 +47,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw): ...@@ -47,7 +47,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw):
request = self.REQUEST request = self.REQUEST
portal = self.getPortalObject() portal = self.getPortalObject()
N_ = portal.Base_translateString Base_translateString = portal.Base_translateString
wf_tool = portal.portal_workflow wf_tool = portal.portal_workflow
selection_tool = portal.portal_selections selection_tool = portal.portal_selections
...@@ -85,7 +85,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw): ...@@ -85,7 +85,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw):
document_list.append(doc.asContext( document_list.append(doc.asContext(
uid='new_%s' % counter, uid='new_%s' % counter,
getListItemUrl=UrlGetter(doc, state_var), getListItemUrl=UrlGetter(doc, state_var),
workflow_title=N_(workflow.title_or_id()), workflow_title=Base_translateString(workflow.title_or_id()),
translated_workflow_state_title= translated_workflow_state_title=
translated_workflow_state_title, translated_workflow_state_title,
count=brain.count, count=brain.count,
...@@ -125,7 +125,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw): ...@@ -125,7 +125,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw):
document_list.append(doc.asContext( document_list.append(doc.asContext(
uid='new_%s' % counter, uid='new_%s' % counter,
getListItemUrl=UrlGetter(doc, state_var), getListItemUrl=UrlGetter(doc, state_var),
workflow_title=N_(workflow.title_or_id()), workflow_title=Base_translateString(workflow.title_or_id()),
translated_workflow_state_title= translated_workflow_state_title=
translated_workflow_state_title, translated_workflow_state_title,
count=document_count, count=document_count,
......
...@@ -31,7 +31,7 @@ from Products.Formulator.TALESField import TALESMethod ...@@ -31,7 +31,7 @@ from Products.Formulator.TALESField import TALESMethod
from Products.CMFCore.utils import _getViewFor from Products.CMFCore.utils import _getViewFor
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import translateString
from Products.ERP5Form.Form import ERP5Form from Products.ERP5Form.Form import ERP5Form
from Products.ERP5Form.ListBox import ListBoxListRenderer from Products.ERP5Form.ListBox import ListBoxListRenderer
...@@ -44,7 +44,6 @@ def getSearchDialog(self, REQUEST=None): ...@@ -44,7 +44,6 @@ def getSearchDialog(self, REQUEST=None):
category_tool = getToolByName(portal, 'portal_categories') category_tool = getToolByName(portal, 'portal_categories')
types_tool = getToolByName(portal, 'portal_types') types_tool = getToolByName(portal, 'portal_types')
workflow_tool = getToolByName(portal, 'portal_workflow') workflow_tool = getToolByName(portal, 'portal_workflow')
N_ = lambda msg, **kw: str(Message('erp5_ui', msg, **kw))
default_view = _getViewFor(self) default_view = _getViewFor(self)
listbox = default_view.listbox listbox = default_view.listbox
...@@ -101,12 +100,15 @@ def getSearchDialog(self, REQUEST=None): ...@@ -101,12 +100,15 @@ def getSearchDialog(self, REQUEST=None):
field.manage_edit_xmlrpc(dict( field.manage_edit_xmlrpc(dict(
form_id='Base_viewDialogFieldLibrary', form_id='Base_viewDialogFieldLibrary',
field_id='your_category')) field_id='your_category'))
field._surcharged_edit(dict(title=N_('${key} ${usage}', mapping=dict(key=N_(column_title), usage=N_('Usage'))), field._surcharged_edit(dict(
items=[(N_('Equals To'), ''), title=translateString('${key} ${usage}',
(N_('Greater Than'), 'min'), mapping=dict(key=translateString(column_title),
(N_('Lower Than'),'max'), usage=translateString('Usage'))),
(N_('Not Greater Then'), 'ngt'), items=[(translateString('Equals To'), ''),
(N_('Not Lower Than'), 'nlt'), (translateString('Greater Than'), 'min'),
(translateString('Lower Than'),'max'),
(translateString('Not Greater Then'), 'ngt'),
(translateString('Not Lower Than'), 'nlt'),
]), ]),
['title', 'items']) ['title', 'items'])
...@@ -136,12 +138,12 @@ def getSearchDialog(self, REQUEST=None): ...@@ -136,12 +138,12 @@ def getSearchDialog(self, REQUEST=None):
field.manage_edit_xmlrpc(dict( field.manage_edit_xmlrpc(dict(
form_id='Base_viewDialogFieldLibrary', form_id='Base_viewDialogFieldLibrary',
field_id='your_category')) field_id='your_category'))
field._surcharged_edit(dict(title=N_('${key} ${usage}', mapping=dict(key=N_(column_title), usage=N_('Usage'))), field._surcharged_edit(dict(title=translateString('${key} ${usage}', mapping=dict(key=translateString(column_title), usage=translateString('Usage'))),
items=[(N_('Equals To'), ''), items=[(translateString('Equals To'), ''),
(N_('Greater Than'), 'min'), (translateString('Greater Than'), 'min'),
(N_('Lower Than'),'max'), (translateString('Lower Than'),'max'),
(N_('Not Greater Then'), 'ngt'), (translateString('Not Greater Then'), 'ngt'),
(N_('Not Lower Than'), 'nlt'), (translateString('Not Lower Than'), 'nlt'),
]), ]),
['title', 'items']) ['title', 'items'])
...@@ -184,13 +186,13 @@ def getSearchDialog(self, REQUEST=None): ...@@ -184,13 +186,13 @@ def getSearchDialog(self, REQUEST=None):
field.manage_edit_xmlrpc(dict( field.manage_edit_xmlrpc(dict(
form_id='Base_viewDialogFieldLibrary', form_id='Base_viewDialogFieldLibrary',
field_id='your_category')) field_id='your_category'))
field._surcharged_edit(dict(title=N_('${key} ${usage}', mapping=dict(key=N_(column_title), usage=N_('Search Key'))), field._surcharged_edit(dict(title=translateString('${key} ${usage}', mapping=dict(key=translateString(column_title), usage=translateString('Search Key'))),
description='', description='',
items=[(N_('Default (${search_key})', items=[(translateString('Default (${search_key})',
mapping=dict(search_key= mapping=dict(search_key=
N_(default_search_key))), ''), translateString(default_search_key))), ''),
(N_('ExactMatch'), 'ExactMatch' ), (translateString('ExactMatch'), 'ExactMatch' ),
(N_('Keyword'), 'Keyword'), (translateString('Keyword'), 'Keyword'),
]), ]),
['title', 'items']) ['title', 'items'])
...@@ -286,11 +288,11 @@ def getSearchDialog(self, REQUEST=None): ...@@ -286,11 +288,11 @@ def getSearchDialog(self, REQUEST=None):
field.manage_edit_xmlrpc(dict( field.manage_edit_xmlrpc(dict(
form_id='Base_viewDialogFieldLibrary', form_id='Base_viewDialogFieldLibrary',
field_id='your_category_list')) field_id='your_category_list'))
items = [('', '')] + sorted([(N_(x.title), x.id) for x items = [('', '')] + sorted([(translateString(x.title), x.id) for x
in workflow.states.objectValues()], in workflow.states.objectValues()],
lambda a, b: cmp(a[0], b[0])) lambda a, b: cmp(a[0], b[0]))
field._surcharged_edit( field._surcharged_edit(
dict(title=N_(workflow.title), dict(title=translateString(workflow.title),
items=items, items=items,
size=len(items)), size=len(items)),
['title', 'items', 'size']) ['title', 'items', 'size'])
...@@ -311,8 +313,8 @@ def getSearchDialog(self, REQUEST=None): ...@@ -311,8 +313,8 @@ def getSearchDialog(self, REQUEST=None):
form_id='Base_viewDialogFieldLibrary', form_id='Base_viewDialogFieldLibrary',
field_id='your_category_list')) field_id='your_category_list'))
field._surcharged_edit( field._surcharged_edit(
dict(title=N_('Type'), dict(title=translateString('Type'),
items=[(N_(x), x) for x in allowed_content_types]), items=[(translateString(x), x) for x in allowed_content_types]),
['title', 'items']) ['title', 'items'])
field._surcharged_tales( field._surcharged_tales(
......
...@@ -32,10 +32,8 @@ from Products.Formulator.DummyField import fields ...@@ -32,10 +32,8 @@ from Products.Formulator.DummyField import fields
from Products.Formulator import Widget, Validator from Products.Formulator import Widget, Validator
from Products.Formulator.Errors import FormValidationError, ValidationError from Products.Formulator.Errors import FormValidationError, ValidationError
from Products.Formulator.Field import ZMIField from Products.Formulator.Field import ZMIField
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import translateString
def N_(message, **kw):
return Message('erp5_ui', message, **kw)
class MatrixBoxWidget(Widget.Widget): class MatrixBoxWidget(Widget.Widget):
""" """
...@@ -322,7 +320,7 @@ class MatrixBoxWidget(Widget.Widget): ...@@ -322,7 +320,7 @@ class MatrixBoxWidget(Widget.Widget):
my_field.render(value=display_value, my_field.render(value=display_value,
REQUEST=REQUEST, REQUEST=REQUEST,
key=key), key=key),
N_(field_errors[key].error_text)) translateString(field_errors[key].error_text))
else: else:
cell_body += '<span class="input">%s</span>' %\ cell_body += '<span class="input">%s</span>' %\
my_field.render( my_field.render(
......
...@@ -33,7 +33,7 @@ from Products.Formulator.Field import ZMIField ...@@ -33,7 +33,7 @@ from Products.Formulator.Field import ZMIField
from Products.ERP5Type.Utils import convertToUpperCase from Products.ERP5Type.Utils import convertToUpperCase
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.PythonScripts.Utility import allow_class from Products.PythonScripts.Utility import allow_class
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import translateString
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from types import StringType from types import StringType
from zLOG import LOG from zLOG import LOG
...@@ -42,9 +42,6 @@ from Globals import get_request ...@@ -42,9 +42,6 @@ from Globals import get_request
from AccessControl import Unauthorized from AccessControl import Unauthorized
from AccessControl import getSecurityManager 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. number of catalog result
MAX_SELECT = 30 MAX_SELECT = 30
NEW_CONTENT_PREFIX = '_newContent_' NEW_CONTENT_PREFIX = '_newContent_'
...@@ -559,10 +556,10 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -559,10 +556,10 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
# form is not validated # form is not validated
############################## ##############################
portal_type = relation_uid[len(NEW_CONTENT_PREFIX):] portal_type = relation_uid[len(NEW_CONTENT_PREFIX):]
translated_portal_type = N_(portal_type) translated_portal_type = translateString(portal_type)
# XXX Replace New by Add # XXX Replace New by Add
message = N_('New ${portal_type}', message = translateString('New ${portal_type}',
mapping={'portal_type': translated_portal_type}) mapping={'portal_type':translated_portal_type})
display_text = message display_text = message
else: else:
display_text = 'Object has been deleted' display_text = 'Object has been deleted'
...@@ -654,9 +651,9 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -654,9 +651,9 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
# form is not validated # form is not validated
############################## ##############################
portal_type = relation_uid[len(NEW_CONTENT_PREFIX):] portal_type = relation_uid[len(NEW_CONTENT_PREFIX):]
translated_portal_type = N_(portal_type) translated_portal_type = translateString(portal_type)
message = N_('New ${portal_type}', message = translateString('New ${portal_type}',
mapping={'portal_type': translated_portal_type}) mapping={'portal_type':translated_portal_type})
display_text = message display_text = message
else: else:
display_text = 'Object has been deleted' display_text = 'Object has been deleted'
...@@ -735,8 +732,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator): ...@@ -735,8 +732,8 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
pass pass
else: else:
if portal_type in module.getVisibleAllowedContentTypeList(): if portal_type in module.getVisibleAllowedContentTypeList():
translated_portal_type = N_(portal_type) translated_portal_type = translateString(portal_type)
message = N_('Add ${portal_type}', message = translateString('Add ${portal_type}',
mapping={'portal_type':translated_portal_type}) mapping={'portal_type':translated_portal_type})
menu_item_list.append((message, menu_item_list.append((message,
'%s%s' % (NEW_CONTENT_PREFIX, '%s%s' % (NEW_CONTENT_PREFIX,
......
...@@ -43,11 +43,9 @@ import md5 ...@@ -43,11 +43,9 @@ import md5
import string import string
from zLOG import LOG, INFO from zLOG import LOG, INFO
from Acquisition import aq_base from Acquisition import aq_base
from Products.ERP5Type.Message import Message from Products.ERP5Type.Message import translateString
import warnings import warnings
# a marker function for translation.
N_ = lambda msg, **kw: str(Message('erp5_ui', msg, **kw))
_MARKER = [] _MARKER = []
...@@ -1115,9 +1113,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ): ...@@ -1115,9 +1113,9 @@ class SelectionTool( BaseTool, UniqueObject, SimpleItem ):
if len(field_value) > 1 and isinstance(field_value, type([])): if len(field_value) > 1 and isinstance(field_value, type([])):
field_value = ' OR '.join(field_value) field_value = ' OR '.join(field_value)
REQUEST.form[field_key] = field_value REQUEST.form[field_key] = field_value
portal_status_message = N_("Please select one (or more) object.") portal_status_message = translateString("Please select one (or more) object.")
else: else:
portal_status_message = N_("Please select one object.") portal_status_message = translateString("Please select one object.")
# Save the current REQUEST form # Save the current REQUEST form
......
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