Skip to content

How to translate texts for Global Signbank

Wessel Stoop edited this page Nov 27, 2020 · 3 revisions

Text in the Signbank interface is stored in different places and needs to be translated in different ways:

  • Text in the code can be translated as outlined below.
  • Text in pages and for field values is stored in the database, and can be translated in the Django admin (and also reached through the edit buttons on pages, visible to administrators). We use the Django plugin modeltranslation to make sure fields appear for each interface language.

Adding translations

Signbanks translation files can be found in the Signbank repository, in

conf/locale/<LANGUAGE_IDENTIFIER>/LC_MESSAGE/django.po

The language identifier for Dutch is 'nl', making the full path on Applejack:

/var/www/signbank/live/repo/conf/locale/nl/LC_MESSAGES/django.po

The file can also be edited on Github: https://github.com/Signbank/signbank/edit/master/conf/locale/nl/LC_MESSAGES/django.po .

A few notes:

  • This file is automatically generated. Django goes through all scripts and templates, and looks for things that could be translated. Don't add new items manually!
  • Django not only generates the list of things to translate, it also suggests translations. These are marked by the comment #fuzzy. The translation will only be used if you take away this comment (that is, if you tell Django its automatically generated translation was correct).
  • If you regenerate the .po file after the code has changed, it will automagically link moved pieces of code to existing translations.

Making changes visible online

Changes to the .po file won't be visible automatically; it needs to be compiled. This can be done with the commands:

cd /var/www/signbank/live
source sb-env/bin/activate
cd repo/
python bin/develop.py compilemessages -l nl
touch /var/www/signbank/live/signbank.ini

The last one restarts the uwsgi process (no need to restart Apache).

Regenerating the .po file

cd /var/www/signbank/live
source sb-env/bin/activate
cd repo/
python bin/develop.py makemessages -l nl

Troubeshooting:

  • If this gives problems with some Django tests, try adding -e html .
  • This command lists all .po files it detects. If you get no output, your .po is not detected. Make sure there are no typos in the conf/locale/xx/LC_MESSAGES/ path