I don't see how this immediately helps the OP, who wants a *literal*
expression that automatically invokes the translation machinery as
well as the interpolation machinery.
Actually, no, I do not want the expression to be automatically translated at compile time. It should be translated at run-time. There are three situations.

1. No translation, just a regular f-string.
2. App translation. The f-string gets translated to the configured language.
3. On the fly translation. The string gets translated to the language passed as an argument as required.

In code, this would be.
1. f'Hi {user}'
2. f'{!g}Hi {user}'
3. f'{lang!g}Hi {user}'

Cases 2 and 3 need some additional code, just like with gettext.

I'm sorry if that wasn't clear from the start. All I want is the code to be simpler to write and maintain. I do not want to have complicated parsing for the compiler.

Another way forward could be a preprocessor. All this can be done with a fairly 
simple script using parso.
This is probably the idea.

Cheers,
Hans

_______________________________________________
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