Making Strings Translatable

To make your strings translatable edit them as follows:

  • in Django templates: {% trans "Some string" %}
  • in Python files: _("some string")
  • in JavaScript files: gettext("some string")

Creation of Translation Files


It is important to run following commands from nodewatcher subdirectory of the repository!

Add your wanted language(s) in under LANGUAGES and make sure your Django applications you want translated have a directory called locale (if not, you should create one).

When all string are marked for translation and settings are prepared run command:

../ makemessages -l <language code>
../ makemessages -l <language code> -d djangojs


You should replace <language code> with the language code you are creating translation files for.

Example for Slovenian language:

../ makemessages -l sl
../ makemessages -l sl -d djangojs

This will create file django.po under locale/sl/LC_MESSAGES/


All other Directories are automatically created.


Open file django.po with text editor or with special translation tool (Poedit for example) and translate strings. Original string is named msgid "Some string" and under it there is msgstr which contains an empty string where you should write your translation.

Compiling Translation Files

After you are done translating run the command:

../ compilemessages

and a new file will be created.

Translated strings should now be available in nodewatcher.


You should really read documentation on translation in Django, but here are some troubleshooting notes:

  • you need gettext installed (see instructions for Windows)
  • sometimes it is necessary to restart development HTTP server to get new compiled translations to work
  • yes, you have to compile .po files into .mo files after you edit .po files
  • verify changes to .po files and make sure that not whole files are changed just because your gettext changed / into \, manually clean/revert such changes