Internationalization (i18n)

Updating the translation files

wger uses django’s translation infrastructure, but there are a couple of things that need to be considered. First, update your po files with the usual django command (run this in the wger subfolder, not the root one):

django-admin makemessages --locale en --extension py,html,tpl

Extract some translatable strings from the database such as exercise categories and muscle names:

python ../ extract-i18n

and add them to the end of locale/en/LC_MESSAGES/django.po. Once you have translated the file, compile it with:

django-admin compilemessages --all

Adding new languages

Besides adding the new translations to the locale folder, they have to be activated in the django settings file and in the application itself.


At the moment composed language codes such as pt-BR (Brazilian Portuguese) are not supported, the issue for this problem is #130

  • django: add an entry to LANGUAGES in wger/

  • wger: add the new language in the language admin page and set the visibility of exercises and ingredients. For the short name, use the language code such as ‘fr’, for the long name the native name, in this example ‘français’.

  • compile: to use the new language files, the translation files have to be compiled. Do this by changing to the wger folder (so you see a locale folder there) and invoking django-admin compilemessages. You will also need to restart the webserver.

  • flag icon: add an appropriate flag icon in SVG format in images/icons/flag-CODE.svg in the static folder of the core application.

  • fixtures: after having added the language in the admin module, the data has to be exported so the current language configuration can be reproduced. This is done with the script:

    • while in extras/scripts, export the whole database to a json file with:

      python ../../ dumpdata --indent 4 --natural-foreign > data.json
    • filter the database dump, this will generate a json file for each “important” module:

    • copy the generated files languages.json and language_config.json to the fixtures folder in core and config (you’ll probably want to delete the remaining json files):

      cp languages.json ../../wger/core/fixtures/
      cp language_config.json ../../wger/config/fixtures/
      rm *.json

Getting new languages

If you have a local installation and new languages arrive from upstream, you need to load the necessary data to the language tables in the database (note that you’ll need to reload/restart the webserver so the new po files are picked up):

python loaddata languages
python loaddata language_config

Please note that this will overwrite any changes you might have done from the language administration module.