Translation

How to translate the user interface into a desired language, or how to edit current translations?

Translating the interface is handled with Django’s internalization features, see django translation docs for more information.

Create a new language to translate to

Follow these instructions when you want to add a new language to translate to.

Add a new translation language

Before beginning translating the user interface into a new language, you need to add the new language into the LANGUAGES setting in signbank/settings/base.py.

# A list of all available languages. The list is a list of two-tuples in the
# format (language code, language name) - for example, ('ja', 'Japanese').
LANGUAGES = (
    ('fi', _('Finnish')),
    ('en', _('English')),
)

You can find the correct ISO 639-1 codes here: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

Make database migrations for django-modeltranslation

Django-modeltranslation is used to dynamically add translatable fields into models. See django-modeltranslation docs here: http://django-modeltranslation.readthedocs.io/en/latest/index.html

After you have added a new language to the LANGUAGES setting, run the following in the commandline in your development or production environment

In development environment:

$ python bin/development.py makemigrations
$ python bin/development.py migrate

In production environment:

$ python bin/production.py makemigrations
$ python bin/production.py migrate

Create or update translations

Create the translation file (.po)

You’ll want to do this in your development environment.

# -i venv ignores the python virtual environment folder.
$ python bin/develop.py makemessages -i venv

For more information see: https://docs.djangoproject.com/en/stable/ref/django-admin/#makemessages

This command creates/updates the django.po files for all the LANGUAGES. These files will be created in locale/<ISO 639-1 CODE>/LC_MESSAGES/django.po

Write the translations

To write the translations, open the django.po file. For each msgid "texthere" there is a msgstr "" where you should place the translation of the text inside the quotes of msgstr.

For example the locale/fi/LC_MESSAGES/django.po for Finnish translations:

msgid ""
"You are not allowed to edit this comment, because you are not the author of "
"the comment."
msgstr "Et voi muokata tätä kommenttia, koska et ole kommentin kirjoittaja."

Once you have written the translations, make sure you put the new file on the server (overwrite the old one).

To activate the translations in the application, you have to run the following command which compiles the translation file :

In development:

$ python bin/develop.py compilemessages

In production:

$ python bin/production.py compilemessages
# Make the server reload FinSL-signbank to update the translations.
$ touch signbank/wsgi.py

For more information see: https://docs.djangoproject.com/en/stable/ref/django-admin/#compilemessages

Translate Flat pages

Open the edit page for the Flat page you want to edit. For each Flat page you should be able to translate the title and the content of the page. Each language should have their own field for their version of the page, e.g. Title [fi] and Content [fi].