Transifex

  • Documentation
  • Integrations
  • Django CMS

Django CMS

django CMS has built-in support for internationalization (i18n). This makes it easy to localize your website using PO files and the Transifex Client.

Localizing with django's built-in i18n support

django CMS relies on the django framework's internationalization support. If you are unfamiliar with this, you might want to check out the django documentation. More specific information regarding django CMS can be found in the django CMS documentation.

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

The resulted .tx/config content should look like this:

[main]
host = https://www.transifex.com
[myproject.myapp]
file_filter = myapp/locale/<lang>/LC_MESSAGES/django.po
source_file = myapp/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO

We recommend that you should commit the .tx/config file to your repository so the next time you want to push new source content.

Next cd into the app_dir (cd myapp in our example) and create a locale folder (mkdir locale). If that folder is already available, skip that step. Then run: $ django-admin 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.

Add "-d djangojs" to generate translations for JavaScript assets.

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

$ cd myapp
$ tx pull -t -a

Make sure to always PULL translations first before PUSHING. Translations should happen on Transifex and not locally in the .po files for the addons registered on Transifex. If your project hs already translations, make sure to push them initially first to transifex using tx push -f -t --no-interactive.

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

$ cd myapp
$ tx pull -t -a

Updating source strings in Transifex from django CMS

Update your local repository by pulling the latest data from Transifex. From the root:

$ tx pull -s -a

Add -f to force. Create the latest messages from the source language (english). From the root:

$ cd app_dir
$ django-admin makemessages -l en

Push the translations back to Transifex. From the root:

$ tx push -s -l en

This will push the English source translation to Transifex.

Updating django CMS with the latest translations from Transifex

Update your local repository by pulling the latest data from Transifex. From the root:

$ tx pull -s -a

Create the machine readable translation by compiling them, from the root:

$ cd app_dir
$ django-admin compilemessages

Commit these translations to your GitHub repository.