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

Extracting translator comments #186

Closed Porrumentzio closed 1 year ago

Porrumentzio commented 3 years ago

I want to add translator comments on .py files, using flask-babel module, and seems that the traditional Gettext extracted comment method\ does not work, as there are no such comments on .pot.

* This structure:

# A comment
_("String to translate")

The documentation on Babel says:

Note:
Whether translator comments can be extracted depends on the extraction method in use. The Python extractor provided by Babel does implement this feature, but others may not.

So is this the case for Flask-Babel? Is there any workaround or method to extract these comments? Am I doing something wrong?

Porrumentzio commented 3 years ago

This seems to be solved with the --add-comment='tag' option appended to the pybabel extract command. Anyway, comments starting with that tag are displayed to translators with the tag: irudia

And letting the tag empty adds programmer's comments that must not be shown to translators. Is this right? Wouldn't the tag be used for identify which comments to extract, but hidden on POT files?

Anyway, is there not an option to just get the comment the line before of the translatable string?

TkTech commented 1 year ago

Extraction is the domain of Babel, not flask-babel, which is just the glue.