Also translate Edge descriptions in ArgparseEdgeType

This commit is contained in:
Florian Festi 2020-04-13 18:45:17 +02:00
parent 18a1766f8c
commit c4ca1b4dfa
2 changed files with 5 additions and 5 deletions

View File

@ -192,11 +192,11 @@ class ArgparseEdgeType:
", ".join(edges)) ", ".join(edges))
return pattern return pattern
def html(self, name, default): def html(self, name, default, translate):
options = "\n".join( options = "\n".join(
("""<option value="%s"%s>%s %s</option>""" % ("""<option value="%s"%s>%s</option>""" %
(e, ' selected="selected"' if e == default else "", (e, ' selected="selected"' if e == default else "",
e, self.names.get(e, "")) for e in self.edges)) translate("%s %s" % (e, self.names.get(e, "")))) for e in self.edges))
return """<select name="%s" size="1">\n%s</select>\n""" % (name, options) return """<select name="%s" size="1">\n%s</select>\n""" % (name, options)
def inx(self, name, viewname, arg): def inx(self, name, viewname, arg):
@ -213,7 +213,7 @@ class BoolArg:
return False return False
return True return True
def html(self, name, default): def html(self, name, default, _):
if isinstance(default, (str)): if isinstance(default, (str)):
default = self(default) default = self(default)
return """<input name="%s" type="hidden" value="0"> return """<input name="%s" type="hidden" value="0">

View File

@ -161,7 +161,7 @@ class BServer:
(_(viewname), "" if not a.help else _(a.help)) (_(viewname), "" if not a.help else _(a.help))
if (isinstance(a, argparse._StoreAction) and if (isinstance(a, argparse._StoreAction) and
hasattr(a.type, "html")): hasattr(a.type, "html")):
input = a.type.html(name, default or a.default) input = a.type.html(name, default or a.default, _)
elif a.dest == "layout": elif a.dest == "layout":
val = (default or a.default).split("\n") val = (default or a.default).split("\n")
input = """<textarea name="%s" cols="%s" rows="%s">%s</textarea>""" % \ input = """<textarea name="%s" cols="%s" rows="%s">%s</textarea>""" % \