> How about this: Have a script that runs over your code, looking for
> "translatable f-strings":
> 
> _(f'Hi {user}')
> 
> and replaces them with actually-translatable strings:
> 
> _('Hi %s') % (user,)
> _('Hi {user}').format(user=user)
> 
> Take your pick of which way you want to spell it. Either of these is
> easily able to be picked up by a standard translation package, is 100%
> legal Python code in today's interpreters, and doesn't require any
> bizarre markers and such saying that things need to be processed out
> of order (the parentheses specify the order for you).


I guess it wasn't clear before.. that's exactly what I was proposing :)

I'd suggest using parso to do it. It's a really great library to write such 
transformations.

/ Anders
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to