4 Internationalization
Starthur edited this page 2022-02-16 14:29:45 +01:00

Internationalization

Internationalization configuration in settings.py :

# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

LANGUAGE_COOKIE_NAME = 'django_language'

USE_I18N = True

LANGUAGES = (
    ('en', _("English")),
    ('de', _('German')),
    ('fr', _('French')),
    ('ru', _('Russian')),
)

LANGUAGES list of languages supported.

Requirements

sudo apt install gettext

Locale directory

All lang files where traductions are stored are located into locale/ and ressources/locale.

For translations, edit file locale/[lang]/django.po :


#: accounts/templates/accounts/edit.html:44
msgid "Connected accounts"
msgstr ""

#: accounts/templates/accounts/edit.html:51
msgid "Disconnect Discord"
msgstr ""

For all messages, we have a list of path to files containing this message and line number.

Edit msgstr with the translated string.

Make messages

To create all .po files, run this command :

django-admin makemessages -l [LANG_CODE]

LANG_CODE for exemple can be set to 'ru', 'fr', 'en'...

Compile messages

To compile messages run this command :

manage.py compilemessages

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.