Best-practice for formatted string literals and localization?
Hartmut Goebel
h.goebel at crazy-compilers.com
Mon Nov 30 13:30:26 EST 2020
Hi,
formatted string literals are great, but can't be used together with
localization:
_(f"These are {count} stones")
will crash babel ("NameError: name 'count' is not defined". And even it
it would succeed, the *evaluated* string would be passed to "_(…)",
resulting in a not-translated string.
Is there a better solution than
_("These are {count} stones").format(count=count)
("Better" = without passing args or kwargs to `format()`)
--
Regards
Hartmut Goebel
| Hartmut Goebel |h.goebel at crazy-compilers.com |
|www.crazy-compilers.com | compilers which you thought are impossible |
More information about the Python-list
mailing list