i18n: document not to use old-style (%) string formatting
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user