Search code examples
djangodjango-templatesdjango-multilingual

how to translate an app template


I want to use multiple language in my app and for that i have followed this doc

After the creation of django.po inside locale folder, I opened that, as this files contain '#' which told you that which line you can translate. But this file only contain admin part it does not have my app templates i.e., HTML files of my app.

So how I can translate those HTML files, OR what should I have to do so that django.po file can also contain my app templates.

I have followed only this doc.


Solution

  • You need to use the {% trans %} or {% blocktrans %} template tags in your html files before you run

    python manage.py makemessages -l <locale>
    

    If you have done that, and your HTML templates are inside your source tree, then makemessages should pick them up. If you haven't used those template tags, then you won't see any output from them in your .po file.