Updating the translation files¶
wger uses django’s translation infrastructure, but there are a couple of things that need to be considered. First you need to extract some translatable strings from the database such as exercise categories and muscle names:
python manage.py extract-i18n
Then, update your po files with the usual django command (run this in the wger sub folder, not the root one):
django-admin makemessages --all --extension py,html,tpl
and finally you can compile them with:
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
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
localefolder 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.svgin 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
extras/scripts, export the whole database to a json file with:
python ../../manage.py 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
language_config.jsonto 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 manage.py loaddata languages python manage.py loaddata language_config
Please note that this will overwrite any changes you might have done from the language administration module.