Django internationalization (i18n) lint checker? Tell me what hasn't been _()'ed or {% trans %}'ed
I have to internationalize (i18n) a django project. It's combined of many in house django apps. I开发者_Go百科t 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.
I couldn't find anything like this, so I had to make my own.
- A plugin for pylint that finds strings that aren't in _()/ugettext()
- A script to find non-translated/i18n'ed strings in django templates
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:
grep "[\"\'][A-Za-z]" */*py -R
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.
精彩评论