--- a/devtools/devctl.py Fri Sep 18 19:47:07 2009 +0200
+++ b/devtools/devctl.py Fri Sep 18 19:48:58 2009 +0200
@@ -160,7 +160,9 @@
add_msg(w, 'add a %s' % tschema,
'inlined:%s.%s.%s' % (etype, rschema, role))
add_msg(w, 'remove this %s' % tschema,
- 'inlined:%s:%s:%s' % (etype, rschema, role))
+ 'inlined:%s.%s.%s' % (etype, rschema, role))
+ add_msg(w, 'This %s' % tschema,
+ 'inlined:%s.%s.%s' % (etype, rschema, role))
if appearsin_addmenu.etype_get(eschema, rschema, role, tschema) and \
(libconfig is None or not
libappearsin_addmenu.etype_get(eschema, rschema, role, tschema)):
--- a/web/data/cubicweb.edition.js Fri Sep 18 19:47:07 2009 +0200
+++ b/web/data/cubicweb.edition.js Fri Sep 18 19:48:58 2009 +0200
@@ -243,9 +243,9 @@
* @param ttype : the target (inlined) entity type
* @param rtype : the relation type between both entities
*/
-function addInlineCreationForm(peid, ttype, rtype, role, insertBefore) {
+function addInlineCreationForm(peid, ttype, rtype, role, i18nctx, insertBefore) {
insertBefore = insertBefore || getNode('add' + rtype + ':' + peid + 'link').parentNode;
- var d = asyncRemoteExec('inline_creation_form', peid, ttype, rtype, role);
+ var d = asyncRemoteExec('inline_creation_form', peid, ttype, rtype, role, i18nctx);
d.addCallback(function (response) {
var dom = getDomFromResponse(response);
preprocessAjaxLoad(null, dom);
--- a/web/views/basecontrollers.py Fri Sep 18 19:47:07 2009 +0200
+++ b/web/views/basecontrollers.py Fri Sep 18 19:48:58 2009 +0200
@@ -376,12 +376,12 @@
@check_pageid
@xhtmlize
- def js_inline_creation_form(self, peid, ttype, rtype, role):
+ def js_inline_creation_form(self, peid, ttype, rtype, role, i18nctx):
view = self.vreg['views'].select('inline-creation', self.req,
etype=ttype, peid=peid, rtype=rtype,
role=role)
return self._call_view(view, etype=ttype, peid=peid,
- rtype=rtype, role=role)
+ rtype=rtype, role=role, i18nctx=i18nctx)
@jsonize
def js_validate_form(self, action, names, values):
--- a/web/views/editforms.py Fri Sep 18 19:47:07 2009 +0200
+++ b/web/views/editforms.py Fri Sep 18 19:48:58 2009 +0200
@@ -454,7 +454,7 @@
for i in xrange(len(rset)):
self.wview(self.id, rset, row=i, **kwargs)
- def cell_call(self, row, col, peid, rtype, role='subject', **kwargs):
+ def cell_call(self, row, col, peid, rtype, role, i18nctx, **kwargs):
"""
:param peid: the parent entity's eid hosting the inline form
:param rtype: the relation bridging `etype` and `peid`
@@ -463,23 +463,25 @@
entity = self.entity(row, col)
divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % (peid, rtype,
entity.eid)
- self.render_form(entity, peid, rtype, role, divonclick=divonclick)
+ self.render_form(entity, peid, rtype, role, i18nctx,
+ divonclick=divonclick)
- def render_form(self, entity, peid, rtype, role, **kwargs):
+ def render_form(self, entity, peid, rtype, role, i18nctx, **kwargs):
"""fetch and render the form"""
form = self.vreg['forms'].select('edition', self.req, entity=entity,
form_renderer_id='inline',
mainform=False, copy_nav_params=False)
self.add_hiddens(form, entity, peid, rtype, role)
divid = '%s-%s-%s' % (peid, rtype, entity.eid)
- title = self.schema.rschema(rtype).display_name(self.req, role)
- removejs = self.removejs % (peid, rtype,entity.eid)
+ title = self.req.pgettext(i18nctx, 'This %s' % entity.e_schema)
+ removejs = self.removejs % (peid, rtype, entity.eid)
countkey = '%s_count' % rtype
try:
self.req.data[countkey] += 1
except:
self.req.data[countkey] = 1
self.w(form.form_render(divid=divid, title=title, removejs=removejs,
+ i18nctx=i18nctx,
counter=self.req.data[countkey], **kwargs))
def add_hiddens(self, form, entity, peid, rtype, role):
@@ -511,7 +513,7 @@
& specified_etype_implements('Any'))
removejs = "removeInlineForm('%s', '%s', '%s')"
- def call(self, etype, peid, rtype, role='subject', **kwargs):
+ def call(self, etype, peid, rtype, role, i18nctx, **kwargs):
"""
:param etype: the entity type being created in the inline form
:param peid: the parent entity's eid hosting the inline form
@@ -525,4 +527,4 @@
return
self.initialize_varmaker()
entity.eid = self.varmaker.next()
- self.render_form(entity, peid, rtype, role)
+ self.render_form(entity, peid, rtype, role, i18nctx)
--- a/web/views/formrenderers.py Fri Sep 18 19:47:07 2009 +0200
+++ b/web/views/formrenderers.py Fri Sep 18 19:48:58 2009 +0200
@@ -489,6 +489,7 @@
def inline_relation_form(self, w, form, rschema, targettype, role):
entity = form.edited_entity
__ = self.req.pgettext
+ i18nctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role)
w(u'<div id="inline%sslot">' % rschema)
existant = entity.has_eid() and entity.related(rschema)
if existant:
@@ -504,7 +505,7 @@
if form.should_display_inline_creation_form(rschema, existant, card):
w(form.view('inline-creation', None, etype=targettype,
peid=entity.eid, ptype=entity.e_schema,
- rtype=rschema, role=role))
+ rtype=rschema, role=role, i18nctx=i18nctx))
existant = True
# we can create more than one related entity, we thus display a link
# to add new related entities
@@ -512,13 +513,12 @@
divid = "addNew%s%s%s:%s" % (targettype, rschema, role, entity.eid)
w(u'<div class="inlinedform" id="%s" cubicweb:limit="true">'
% divid)
- js = "addInlineCreationForm('%s', '%s', '%s', '%s')" % (
- entity.eid, targettype, rschema, role)
- if card in '1?':
+ js = "addInlineCreationForm('%s', '%s', '%s', '%s', '%s')" % (
+ entity.eid, targettype, rschema, role, i18nctx)
+ if form.should_hide_add_new_relation_link(rschema, card):
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, __(ctx, 'add a %s' % targettype)))
+ % (rschema, entity.eid, js, __(i18nctx, 'add a %s' % targettype)))
w(u'</div>')
w(u'<div class="trame_grise"> </div>')
w(u'</div>')
@@ -542,7 +542,9 @@
w(u'<div id="notice-%s" class="notice">%s</div>' % (
values['divid'], self.req._('click on the box to cancel the deletion')))
w(u'<div class="iformBody">')
- values['removemsg'] = self.req.__('remove this %s' % form.edited_entity.e_schema)
+ eschema = form.edited_entity.e_schema
+ ctx = values.pop('i18nctx')
+ values['removemsg'] = self.req.pgettext(ctx, 'remove this %s' % eschema)
w(u'<div class="iformTitle"><span>%(title)s</span> '
'#<span class="icounter">%(counter)s</span> '
'[<a href="javascript: %(removejs)s;noop();">%(removemsg)s</a>]</div>'