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