Django Template Translation (i18n) for Window


  1. Download gettext
  2. Install the binary executable and make sure select “Add application directory to your environmental path” option.
  3. Run the following instruction through
    makemessages -l en


  4. If you are using PyCharm, pressing ALT + CTRL + R will show you the task popup
  5. If everything is fine you will see the following:
    Process finished with exit code 0


  6. You will find a  django.po file in static/locale/en/LC_MESSAGES
  7. The .po file is for editing, for actual usage we need to compile it by calling following through


  8. After that, a file is generated in the same directory.

Template Translation

  1. Include the following in the beginning of the html file:
    {% load i18n %}


  2. Use the following Django template tag indicate the string being translated:
    {%trans "word_to_be_trans" %}

    Note that the String inside the html file will be the default, if no valid translation is found.

  3. After adding the above tag, run the following and Django will walk through all html files to generate a message file (django.po).
    makemessages -l zh_hans


  4. Open the message file generated, you will find the followings and edit it:
    #: .\templates\base.html:81
    msgid "word_to_be_trans"
    msgstr "被翻譯的字"


  5. After finishing edit the message file, run the following to compile:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s