core, frontends: fix invalid translatable strings.

Some f-strings where used in translatable text, this has been fixed by using explicit
`format()` call (using a script based on `tokenize`).

As tokenize messes with spaces, a reformating tool (`black`) has been applied to some
files afterwards.
This commit is contained in:
Goffi 2021-06-14 18:35:12 +02:00
commit 7adbf3ead8

View file

@ -162,9 +162,7 @@ class Get(base.CommandBase):
)
def add_parser_options(self):
self.parser.add_argument(
"id", help=_("invitation UUID")
)
self.parser.add_argument("id", help=_("invitation UUID"))
self.parser.add_argument(
"-j",
"--with-jid",
@ -184,7 +182,7 @@ class Get(base.CommandBase):
self.args.id,
)
except Exception as e:
self.disp(msg=_(f"can't get invitation data: {e}"), error=True)
self.disp(msg=_("can't get invitation data: {e}").format(e=e), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
if not self.args.with_jid:
@ -197,7 +195,7 @@ class Get(base.CommandBase):
profile,
)
except Exception as e:
self.disp(msg=_(f"can't start session: {e}"), error=True)
self.disp(msg=_("can't start session: {e}").format(e=e), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
try:
@ -207,7 +205,7 @@ class Get(base.CommandBase):
profile_key=profile,
)
except Exception as e:
self.disp(msg=_(f"can't retrieve jid: {e}"), error=True)
self.disp(msg=_("can't retrieve jid: {e}").format(e=e), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
await self.output_data(invitation_data, jid_)
@ -224,9 +222,7 @@ class Delete(base.CommandBase):
)
def add_parser_options(self):
self.parser.add_argument(
"id", help=_("invitation UUID")
)
self.parser.add_argument("id", help=_("invitation UUID"))
async def start(self):
try:
@ -234,7 +230,7 @@ class Delete(base.CommandBase):
self.args.id,
)
except Exception as e:
self.disp(msg=_(f"can't delete guest account: {e}"), error=True)
self.disp(msg=_("can't delete guest account: {e}").format(e=e), error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
self.host.quit()
@ -290,9 +286,7 @@ class Modify(base.CommandBase):
default="",
help="profile doing the invitation (default: don't associate profile",
)
self.parser.add_argument(
"id", help=_("invitation UUID")
)
self.parser.add_argument("id", help=_("invitation UUID"))
async def start(self):
extra = dict(self.args.extra)
@ -302,7 +296,9 @@ class Modify(base.CommandBase):
continue
if arg_name in extra:
self.parser.error(
_(f"you can't set {arg_name} in both optional argument and extra")
_(
"you can't set {arg_name} in both optional argument and extra"
).format(arg_name=arg_name)
)
extra[arg_name] = value
try:
@ -312,9 +308,7 @@ class Modify(base.CommandBase):
self.args.replace,
)
except Exception as e:
self.disp(
f"can't modify invitation: {e}", error=True
)
self.disp(f"can't modify invitation: {e}", error=True)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
else:
self.disp(_("invitations have been modified successfuly"))