[Python-ideas] String interpolation for all literal strings
Jonathan Slenders
jonathan at slenders.be
Mon Aug 10 13:49:18 CEST 2015
2015-08-07 9:33 GMT+02:00 Nick Coghlan <ncoghlan at gmail.com>:
> If f-strings are always eagerly interpolated
> prior to translation, then I can foresee a lot of complaints from
> folks asking why this doesn't work right:
>
> print(_(f"This is a translated message with {a} and {b} interpolated"))
>
What if we decide to lazy-interpolate f-strings?
A creation of such an f-string, creates an f-string object. (Which has a
proper __repr__, so that it's transparent for those that don't care.)
Calling the __str__ method of the f-string triggers the interpolation.
This should give enough freedom to implement a working ugettext.
(But I still don't see any reason to go beyond supporting more than just is
simple variable name between the curly braces...)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150810/fff0a2de/attachment.html>
More information about the Python-ideas
mailing list