appy.gen: do not generate _action_ok and action_ko i18n messages anymore; added param Group.label, similar to Type.label; allowed to specify in param Group.wide any table width.
This commit is contained in:
parent
5be03c2ed4
commit
9258b76bdf
7 changed files with 40 additions and 41 deletions
|
@ -87,14 +87,7 @@ class FieldDescriptor:
|
|||
self.generator.labels.append(poMsg)
|
||||
|
||||
def walkAction(self):
|
||||
'''Generates the i18n-related labels.'''
|
||||
for suffix in ('ok', 'ko'):
|
||||
label = '%s_%s_action_%s' % (self.classDescr.name, self.fieldName,
|
||||
suffix)
|
||||
msg = PoMessage(label, '',
|
||||
getattr(PoMessage, 'ACTION_%s' % suffix.upper()))
|
||||
self.generator.labels.append(msg)
|
||||
self.classDescr.labelsToPropagate.append(msg)
|
||||
'''Generates the i18n-related label.'''
|
||||
if self.appyType.confirm:
|
||||
label = '%s_%s_confirm' % (self.classDescr.name, self.fieldName)
|
||||
msg = PoMessage(label, '', PoMessage.CONFIRM)
|
||||
|
@ -178,7 +171,7 @@ class FieldDescriptor:
|
|||
self.classDescr.labelsToPropagate.append(poMsg)
|
||||
# Create i18n messages linked to groups
|
||||
group = self.appyType.group
|
||||
if group:
|
||||
if group and not group.label:
|
||||
group.generateLabels(messages, self.classDescr, set())
|
||||
# Manage things which are specific to String types
|
||||
if self.appyType.type == 'String': self.walkString()
|
||||
|
|
|
@ -101,6 +101,8 @@ class Generator(AbstractGenerator):
|
|||
msg('no_ref', '', msg.REF_NO),
|
||||
msg('add_ref', '', msg.REF_ADD),
|
||||
msg('ref_actions', '', msg.REF_ACTIONS),
|
||||
msg('action_ok', '', msg.ACTION_OK),
|
||||
msg('action_ko', '', msg.ACTION_KO),
|
||||
msg('move_up', '', msg.REF_MOVE_UP),
|
||||
msg('move_down', '', msg.REF_MOVE_DOWN),
|
||||
msg('query_create', '', msg.QUERY_CREATE),
|
||||
|
|
|
@ -908,11 +908,8 @@ class BaseMixin:
|
|||
if not msg:
|
||||
# Use the default i18n messages
|
||||
suffix = 'ko'
|
||||
if successfull:
|
||||
suffix = 'ok'
|
||||
appyType = self.getAppyType(rq['fieldName'])
|
||||
label = '%s_action_%s' % (appyType.labelId, suffix)
|
||||
msg = self.translate(label)
|
||||
if successfull: suffix = 'ok'
|
||||
msg = self.translate('action_%s' % suffix)
|
||||
if (resultType == 'computation') or not successfull:
|
||||
self.say(msg)
|
||||
return self.goto(self.getUrl(rq['HTTP_REFERER']))
|
||||
|
@ -1191,15 +1188,14 @@ class BaseMixin:
|
|||
return res
|
||||
|
||||
def translate(self, label, mapping={}, domain=None, default=None,
|
||||
language=None, format='html', field=None, className=None):
|
||||
language=None, format='html', field=None):
|
||||
'''Translates a given p_label into p_domain with p_mapping.
|
||||
|
||||
If p_field is given, p_label does not correspond to a full label
|
||||
name, but to a label type linked to p_field: "label", "descr"
|
||||
or "help". Indeed, in this case, a specific i18n mapping may be
|
||||
available on the field, so we must merge this mapping into
|
||||
p_mapping. If p_className is not given, we consider p_self being an
|
||||
instance of the class where p_field is defined.'''
|
||||
p_mapping.'''
|
||||
cfg = self.getProductConfig()
|
||||
if not domain: domain = cfg.PROJECTNAME
|
||||
if domain != cfg.PROJECTNAME:
|
||||
|
@ -1215,22 +1211,15 @@ class BaseMixin:
|
|||
else:
|
||||
# Get the label name, and the field-specific mapping if any.
|
||||
if field:
|
||||
# Maybe we do not have the field itself, but only its name
|
||||
if isinstance(field, basestring):
|
||||
appyField = self.getAppyType(field, className=className)
|
||||
else:
|
||||
appyField = field
|
||||
if appyField:
|
||||
fieldMapping = appyField.mapping[label]
|
||||
# p_field is the dict version of a appy type or group
|
||||
if field['type'] != 'group':
|
||||
fieldMapping = field['mapping'][label]
|
||||
if fieldMapping:
|
||||
if callable(fieldMapping):
|
||||
appyField = self.getAppyType(field['name'])
|
||||
fieldMapping=appyField.callMethod(self,fieldMapping)
|
||||
mapping.update(fieldMapping)
|
||||
# Get the label
|
||||
label = getattr(appyField, label+'Id')
|
||||
else:
|
||||
# It must be a group.
|
||||
label = '%s_group_%s_%s' % (self.meta_type, field, label)
|
||||
label = field['%sId' % label]
|
||||
# We will get the translation from a Translation object.
|
||||
# In what language must we get the translation?
|
||||
if not language: language = self.getUserLanguage()
|
||||
|
|
|
@ -120,7 +120,7 @@
|
|||
maxReached python:(multiplicity[1] != None) and (len(objs) >= multiplicity[1]);
|
||||
showPlusIcon python:not appyType['isBack'] and appyType['add'] and not maxReached and member.has_permission(addPermission, folder) and canWrite;
|
||||
atMostOneRef python: (multiplicity[1] == 1) and (len(objs)<=1);
|
||||
label python: contextObj.translate('label', field=appyType['name']);
|
||||
label python: contextObj.translate('label', field=appyType);
|
||||
addConfirmMsg python: appyType['addConfirm'] and tool.translate('%s_addConfirm' % appyType['labelId']) or '';
|
||||
navBaseCall python: 'askRefField(\'%s\',\'%s\',\'%s\',\'%s\',**v**)' % (ajaxHookId, contextObj.absolute_url(), fieldName, innerRef)">
|
||||
|
||||
|
@ -167,7 +167,7 @@
|
|||
|
||||
<tal:comment replace="nothing">Object description</tal:comment>
|
||||
<p class="discreet" tal:condition="python: not innerRef and appyType['hasDescr']"
|
||||
tal:content="python: contextObj.translate('descr', field=appyType['name'])"></p>
|
||||
tal:content="python: contextObj.translate('descr', field=appyType)"></p>
|
||||
|
||||
<tal:comment replace="nothing">Appy (top) navigation</tal:comment>
|
||||
<metal:nav use-macro="here/skyn/navigate/macros/appyNavigate"/>
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
</tal:asSection>
|
||||
<tal:asTabs condition="python: widget['style'] == 'tabs'">
|
||||
<table cellpadding="0" cellspacing="0"
|
||||
tal:attributes="width python: test(widget['wide'], '100%', '');
|
||||
tal:attributes="width widget/wide;
|
||||
class widget/css_class">
|
||||
<tal:comment replace="nothing">First row: the tabs.</tal:comment>
|
||||
<tr valign="middle"><td style="border-bottom: 1px solid #ff8040">
|
||||
|
@ -130,7 +130,7 @@
|
|||
</tal:comment>
|
||||
<table metal:define-macro="groupContent"
|
||||
tal:define="cellgap widget/cellgap"
|
||||
tal:attributes="width python: test(widget['wide'], '100%', '');
|
||||
tal:attributes="width widget/wide;
|
||||
align widget/align;
|
||||
class widget/css_class;
|
||||
cellspacing widget/cellspacing;
|
||||
|
@ -175,14 +175,14 @@
|
|||
</table>
|
||||
|
||||
<tal:comment replace="nothing">Displays a field label.</tal:comment>
|
||||
<tal:label metal:define-macro="label" condition="widget/hasLabel"><label tal:attributes="for widget/name" tal:condition="python: not ((widget['type'] == 'Action') or ((widget['type'] == 'Ref') and (widget['add'])))" tal:content="structure python: contextObj.translate('label', field=widget['name'])"></label></tal:label>
|
||||
<tal:label metal:define-macro="label" condition="widget/hasLabel"><label tal:attributes="for widget/name" tal:condition="python: not ((widget['type'] == 'Action') or ((widget['type'] == 'Ref') and (widget['add'])))" tal:content="structure python: contextObj.translate('label', field=widget)"></label></tal:label>
|
||||
|
||||
<tal:comment replace="nothing">Displays a field description.</tal:comment>
|
||||
<tal:description metal:define-macro="description" condition="widget/hasDescr"><span class="discreet" tal:content="structure python: contextObj.translate('descr', field=widget['name'])"></span>
|
||||
<tal:description metal:define-macro="description" condition="widget/hasDescr"><span class="discreet" tal:content="structure python: contextObj.translate('descr', field=widget)"></span>
|
||||
</tal:description>
|
||||
|
||||
<tal:comment replace="nothing">Displays a field help.</tal:comment>
|
||||
<tal:help metal:define-macro="help"><acronym tal:attributes="title python: contextObj.translate('help', field=widget['name'])"><img tal:attributes="src string: $portal_url/skyn/help.png"/></acronym></tal:help>
|
||||
<tal:help metal:define-macro="help"><acronym tal:attributes="title python: contextObj.translate('help', field=widget)"><img tal:attributes="src string: $portal_url/skyn/help.png"/></acronym></tal:help>
|
||||
|
||||
<tal:comment replace="nothing">Displays validation-error-related info about a field.</tal:comment>
|
||||
<tal:validation metal:define-macro="validation"><acronym tal:condition="inError" tal:attributes="title python: errors[name]"><img tal:attributes="src string: $portal_url/skyn/warning.png"/></acronym><img tal:condition="not: inError" tal:attributes="src string: $portal_url/skyn/warning_no.gif"/></tal:validation>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue