python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.3k stars 433 forks source link

How to translate (extract) messages not used in source code #807

Open return42 opened 2 years ago

return42 commented 2 years ago

In the SearXNG project we have names of categories, these categories are configurable and the list of categories is generated at runtime. Some of the categories are very common and we serve translations of them.

Since pybabel extract can extract only what is somewhere written down in the source code, we added some dummy gettext(<category>) to the source code.

https://github.com/searxng/searxng/blob/c3473480f4255a81d83ac48201e0702778398d23/searx/webapp.py#L181-L194

Now my question is: Is there a way to add a stock of msgid's to the PO files which are not written down anywhere in the code?

akx commented 2 years ago

A reasonably easy way might be to write a custom extractor to read messages from e.g. a text file.