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
4 changed files with 823 additions and 601 deletions

View file

@ -972,8 +972,12 @@ class Params(object):
if not self.checkSecurityLimit(node[1], security_limit):
msg = _(
f"{profile!r} is trying to set parameter {name!r} in category "
f"{category!r} without authorization!!!")
"{profile!r} is trying to set parameter {name!r} in category "
"{category!r} without authorization!!!").format(
profile=repr(profile),
name=repr(name),
category=repr(category)
)
log.warning(msg)
raise exceptions.PermissionError(msg)
@ -986,8 +990,11 @@ class Params(object):
int(value)
except ValueError:
log.warning(_(
f"Trying to set parameter {name!r} in category {category!r} with"
f"an non-integer value"
"Trying to set parameter {name} in category {category} with"
"an non-integer value"
).format(
name=repr(name),
category=repr(category)
))
return defer.succeed(None)
if node[1].hasAttribute("constraint"):

View file

@ -64,7 +64,7 @@ class ImportPlugin(object):
@param name(unicode): import handler name
"""
assert name == name.lower().strip()
log.info(_(f"initializing {name} import handler"))
log.info(_("initializing {name} import handler").format(name=name))
import_handler.name = name
import_handler.register = partial(self.register, import_handler)
import_handler.unregister = partial(self.unregister, import_handler)
@ -155,7 +155,7 @@ class ImportPlugin(object):
pass
except ValueError:
raise exceptions.DataError(
_(f"invalid json option: {option}")
_("invalid json option: {option}").format(option=option)
)
pubsub_service = jid.JID(pubsub_service) if pubsub_service else None
return self.doImport(

View file

@ -708,7 +708,8 @@ class XEP_0329(object):
)
else:
log.warning(
_(f"unexpected element, ignoring: {elt.toXml()}")
_("unexpected element, ignoring: {elt}")
.format(elt=elt.toXml())
)
continue
files.append(file_data)

View file

@ -76,7 +76,7 @@ class CommandProtocol(protocol.ProcessProtocol):
def processEnded(self, reason):
data = b''.join(self.data)
if (reason.value.exitCode == 0):
log.debug(_(f'{self.command_name!r} command succeed'))
log.debug(f'{self.command_name!r} command succeed')
# we don't use "replace" on purpose, we want an exception if decoding
# is not working properly
self._deferred.callback(data)