I'm trying to use python-babel
to extract translations from tornado templates.
I have tried some solutions, and none of them is perfect.
Use python
as extractor:
# babel.cfg
[python: **/server/templates/**.html]
It works most of time, but won't work if there are some translations inside script
blocks:
<script> var a = {{ _("won't be extracted") }} </script>
Just let tornado use jinja2 template engine, it works but not pretty.
Use tornado-babel
, it is just an outdated library without python3 support.
Any suggestion?
Finally, I just use jinja2 template engine. Highly recommend tornado's team to use jinja2 template engine! Do not waste time any more.