niwinz / django-jinja

Simple and nonobstructive jinja2 integration with Django.
http://niwinz.github.io/django-jinja/latest/
BSD 3-Clause "New" or "Revised" License
363 stars 102 forks source link

makemessages doesn't handle escaped quotes #191

Closed rangermeier closed 2 years ago

rangermeier commented 7 years ago

The included makemessages management command shows errors when translateable strings contain escaped characters.

E.g. a template like example.html

 <a href="#" title=" {{ _('Don\t click "Delete" if unsure.')}}">{{ _('Delete') }}</a>

Gives this warning when ./manage.py makemessage is run:

 ./templates/example.html.py:1: warning: unterminated string

This can be fixed by adding a negative lookbehind to the regex:

trans_real.constant_re = re.compile(r"""_\(((?:".*?(?<!\\)")|(?:'.*?(?<!\\)')).*\)""")
niwinz commented 7 years ago

Pushed fix to master, please, test it.

wizpig64 commented 2 years ago

closing this issue as it looks like the fix for it has since been changed more recently anyway.