1
0

i18n: document not to use old-style (%) string formatting

This commit is contained in:
SomberNight
2023-01-10 14:06:29 +00:00
parent 63d801e363
commit b0e2e89395

View File

@@ -30,6 +30,11 @@ LOCALE_DIR = os.path.join(os.path.dirname(__file__), 'locale')
language = gettext.translation('electrum', LOCALE_DIR, fallback=True)
# note: do not use old-style (%) formatting inside translations,
# as syntactically incorrectly translated strings would raise exceptions (see #3237).
# e.g. consider _("Connected to %d nodes.") % n
# >>> "Connecté aux noeuds" % n
# TypeError: not all arguments converted during string formatting
# note: f-strings cannot be translated! see https://stackoverflow.com/q/49797658
# So this does not work: _(f"My name: {name}")
# instead use .format: _("My name: {}").format(name)