Django

Localizing with Django's built-in i18n support.

Nick Ustinov avatar
Written by Nick Ustinov
Updated over a week ago

You might also be interested in checking out our Python API SDK.

Lokalise can be used with Django apps.

Prerequisites

Uploading to Lokalise

Once your app is prepared for localization, it should contain the source language (here we assume it's English) in the locale directory, for example myapp/locale/en/LC_MESSAGES/default.po.

Upload the default.po file to Lokalise using the CLI tool:

$ cd myapp
$ ./manage.py makemessages -l en
$ lokalise2 \
  --token <token> \
  --project-id <project_id> \
  file upload \
  --file "locale/en/LC_MESSAGES/default.po" \
  --lang-iso en

Additional upload options can be found in the CLI docs.

Downloading from Lokalise

When the translations are done, you'll need to download the language files from Lokalise:

$ lokalise2 \
  --token <token> \
  --project-id <project_id> \
  file download \
  --format po \
  --filter-langs en \
  --original-filenames=true \
  --directory-prefix "" \
  --unzip-to "locale/en/LC_MESSAGES/"

Run a similar command for all other project languages.

Additional download options can be found in the CLI docs.

Did this answer your question?