Browse Source

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

master
SomberNight 3 years ago
parent
commit
b0e2e89395
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/i18n.py

5
electrum/i18n.py

@ -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)

Loading…
Cancel
Save