• Documentation
  • Integrations
  • Django

Django

django has built-in support for internationalization (i18n). This makes it easy to localize your website using PO files and the Transifex Client. You can also use Transifex Live, our JavaScript based technology. Transifex Live is well suited for websites that have content stored in the database and lets translators work in-context, increasing the overall translation quality.

Below, you'll find instructions for localizing your website using either method – django's i18n support or Transifex Live, There's also some cool stuff the developer community is doing with django and Transifex.

Localizing with django's built-in i18n support

Before getting started, you'll want to follow the django documentation and internationalize your website. Once you've done this, there will be at least one source file under a path that looks like myapp/locale/en/LC_MESSAGES/default.po, assuming English is your source language.

The source file will be the foundation for setting up the Transifex Client, which lets you send and receive files over Transifex's REST API. In order to set up your Transifex Client configuration, you first need a project in Transifex and the Transifex Client installed.

After finishing all the steps above, follow the set of commands below to set up your repository configuration in a file called .tx/config. In this example, we named our project in Transifex mytxproject.

$ git clone http://git.example.com/git/myapp.git
$ cd myapp
$ tx init
$ tx set --auto-local -r mytxproject.defaultpo 'locale/<lang>/LC_MESSAGES/default.po' \
--source-lang en --type PO --source-file locale/en/LC_MESSAGES/default.po

You should commit the .tx/config file to your repository so the next time you want to push new source content, you can simply use the following commands

$ cd myapp
$ ./manage.py makemessages -l en
$ tx push -s

The tx commands should always be executed from the directory in your repository where the .tx/ folder is located.

To download translations once their are complete in Transifex, use:

$ cd myapp
$ tx pull -t -a

Transifex Live

You can also use Transifex Live to translate your django-based sites. To learn more, check out the Transifex Live documentation.

Community integrations

django-transifex is an app that integrates your django app directly with the Transifex API without needing the Transifex Client. It does this through a management command that can be used to push and pull files from your repository. You can learn more by installing it then running ./manage.py tx --help.