3 ms·
More important than f-strings are translatable strings. When you write print(f"The value is {x}"), it cannot be translated. Perhaps they could add a new prefi
by benibela 6y ago
More important than f-strings are translatable strings.
When you write print(f"The value is {x}"), it cannot be translated.
Perhaps they could add a new prefix, like t"The value is {x}", and then gather all such strings for translation?
- eesmith 6y agoSee the gettext module, at https://docs.python.org/3/library/gettext.html https://docs.python.org/3/library/gettext.html , where gettext() is usually aliased to "_()" so people can write _("int'l string") . There are also tools to extract such strings. You are correct - translatable strings require late-binding, including possible re-ordering. As the Django documentation points out: 'an English translation may be "Today is November 26.", while a Spanish translation may be "Hoy es 26 de noviembre." – with the month and the day placeholders swapped.' It adds that f-strings aren't currently supported... And I don't see how they could be supported.