Django 国际化 (i18n) lint 检查器?告诉我什么还没有被 _()'ed 或 {% trans %}'ed
我必须国际化(i18n)一个 django 项目。它结合了许多内部 django 应用程序。它已经部分国际化,即有些字符串是 _(),但有些是裸露的。有些模板使用 {% blocktrans %}
或 {% trans %}
,但有时英文文本直接在其中。我需要做很多手工工作才能改变这一切。那好吧。
有没有办法查看 python 代码中的哪些字符串以及 html 模板中的哪些文本尚未通过 _()/{% trans %} 传递?一个“i18n lint”检查器?一个命令将打印出该行 &还没有被 _()'ed 的字符串的文件名,或者不在 {% trans %} 中的字符串的文件名我可以接受它抛出误报(& 漏报),我只是想要一些方法来制作当然我没有错过任何东西。
I have to internationalize (i18n) a django project. It's combined of many in house django apps. It is partially i18n'ed already, i.e. some of the strings are _(), but some are bare. Some of the templates use {% blocktrans %}
or {% trans %}
, but sometimes the english text is in there direct. It will take a lot of manual work for me to change all this. Oh well.
Is there some way to see what strings in the python code and what text in the html templates hasn't been passed through _()/{% trans %}? A 'i18n lint' checker? A command that'll print out the line & filename of strings that haven't been _()'ed yet, or that aren't in {% trans %} I'm OK with it throwing up false positives (& false negatives), I just want some way to make sure I haven't missed anything.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找不到这样的东西,所以我必须自己做。
I couldn't find anything like this, so I had to make my own.
您可以
grep
遍历所有 Python 文件来获取字符串列表,并查看哪些缺少_()
。像这样的东西,但可能更复杂一点:不幸的是,我不知道如何查看模板文件,因为我看不到任何方法来区分
{% blocktrans %}
中的字符串或{% trans %}
环境以及没有的环境。You could
grep
through all the Python files to get yourself a list of strings and see which ones lack a_()
. Something like this but probably a little bit more sophisticated:Unfortunately, I have no idea on how to look through template files as I don't see any way to distinguish between strings in a
{% blocktrans %}
or{% trans %}
environment and those without.