--- a/web/views/formrenderers.py Tue Sep 15 15:01:41 2009 +0200
+++ b/web/views/formrenderers.py Thu Sep 17 15:16:53 2009 +0200
@@ -92,7 +92,10 @@
def render_label(self, form, field):
if field.label is None:
return u''
- label = self.req._(field.label)
+ if isinstance(field.label, tuple): # i.e. needs contextual translation
+ label = self.req.pgettext(*field.label)
+ else:
+ label = self.req._(field.label)
attrs = {'for': form.context[field]['id']}
if field.required:
attrs['class'] = 'required'
@@ -412,12 +415,13 @@
super(EntityFormRenderer, self).render_buttons(w, form)
def relations_form(self, w, form):
- srels_by_cat = form.srelations_by_category('generic', 'add')
+ srels_by_cat = form.srelations_by_category('generic', 'add', strict=True)
if not srels_by_cat:
return u''
req = self.req
_ = req._
- label = u'%s :' % _('This %s' % form.edited_entity.e_schema).capitalize()
+ __ = _
+ label = u'%s :' % __('This %s' % form.edited_entity.e_schema).capitalize()
eid = form.edited_entity.eid
w(u'<fieldset class="subentity">')
w(u'<legend class="iformTitle">%s</legend>' % label)
@@ -489,7 +493,7 @@
def inline_relation_form(self, w, form, rschema, targettype, role):
entity = form.edited_entity
- __ = self.req.__
+ __ = self.req.pgettext
w(u'<div id="inline%sslot">' % rschema)
existant = entity.has_eid() and entity.related(rschema)
if existant:
@@ -506,6 +510,7 @@
w(form.view('inline-creation', None, etype=targettype,
peid=entity.eid, ptype=entity.e_schema,
rtype=rschema, role=role))
+ existant = True
# we can create more than one related entity, we thus display a link
# to add new related entities
if form.should_display_add_new_relation_link(rschema, existant, card):
@@ -516,8 +521,9 @@
entity.eid, targettype, rschema, role)
if card in '1?':
js = "toggleVisibility('%s'); %s" % (divid, js)
+ ctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role)
w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>'
- % (rschema, entity.eid, js, __('add a %s' % targettype)))
+ % (rschema, entity.eid, js, __(ctx, 'add a %s' % targettype)))
w(u'</div>')
w(u'<div class="trame_grise"> </div>')
w(u'</div>')