Search code examples
djangointernationalizationdjango-templatesdjango-i18n

Django i18n's makemessages doesn't find .djhtml and .djt templates


I'm using i18n on Django to make my website multilingual.

I've recently changed my templates' extensions from html to djhtml, so that Emacs will do syntax highlighting, but after this change, python manage.py makemessages doesn't find the djhtml files (or doesn't consider them as templates) and doesn't create the entries on my django.po file for the translations in them. It even comments out translations that I previously had on html files.

If I make an exact copy of the djhtml file in the same folder, but with a html extension, then it works normally.

The same thing happens with djt as well.

How to I configure i18n to consider djhtml and djt files as templates as well?


Solution

  • I found the answer looking through Django's code.

    You can use the -e or --extension to select which file extensions it's supposed to check.

    From their own code, this flag determines:

    The file extension(s) to examine (default: "html,txt,py", or "js" if the domain is "djangojs"). Separate multiple extensions with commas, or use -e multiple times.

    So you can use it like so to detect djhtml and djt:

    python manage.py makemessages -e 'html,txt,py,djt,djhtml'