python-babel / flask-babel

i18n and l10n support for Flask based on Babel and pytz
https://python-babel.github.io/flask-babel/
Other
432 stars 159 forks source link

Babel cannot find words in 3's f-Strings ? #210

Closed teddy-lu closed 1 year ago

teddy-lu commented 1 year ago

I have some words in 3's f-Strings sql code. such as

s = f"""
SELECT * FROM aa
balabala ...
case bala...
{_("abc")}
WHERE b=1
"""

after I excute the order $ pybabel extract -F babel.cfg -o messages.pot .

but I cannot find the words 'abc' from file messages.pot

TkTech commented 1 year ago

The underlying Babel library does not support f-strings. You will need to raise an issue with them and/or add support in https://github.com/python-babel/babel/blob/master/babel/messages/extract.py#L581 to extract function usage inside a f-string AST node.