We manage a number of open source Django apps here at Caktus. While many of us here are proficient in a number of programming languages, the same can’t be said for our ability to read or write in languages other than English. The Django community is global and we want our apps to support other languages. For that we’ve turned to Transifex which it the same tool Django itself uses for translations.
If you aren’t familiar with Transifex, it’s an open-source localization platform. There are paid plans for private projects but you can have a free plan if you are managing translations for an open source project. You can import your translation files, add new languages and review translation progress all with managed teams of translators. You can also make use of machine translation services such as Google Translate or Microsoft Translator.
Setting up a project is simple. Once you have an account, you choose to add a new project from the dashboard. You need to pick a name which you can simply match to your project name if it is available. You also need to pick a source language, for us that would be English, and a license. We release our code under the BSD license so we choose “Permissive open-source”.
Locally you will need to generate the message files, if you haven’t already, and configure your project. Transifex provides a pip installable command line client for pushing and pulling translations. You just need to initialize the client once installed.
pip install transifex-client # From your application/project root directory tx init
Following the Django documentation you need to create the message files
django-admin.py makemessages -l en
If you have JS files to translate then you need to generate those as well
django-admin.py makemessages -d djangojs -l en
Once you’ve configured the client you can map your translations
tx set --execute --auto-local -r django-something.djangopo -s en -f something/locale/en/LC_MESSAGES/django.po ‘something/locale/<lang>/LC_MESSAGES/django.po'
Here django-something would be replaced by the name used when creating the project on Transifex and something would be replaced by the source directory name. Additionally if you have JS files to translate you would map those as well
tx set --execute --auto-local -r django-something.djangojs -s en -f something/locale/en/LC_MESSAGES/djangojs.po 'something/locale/<lang>/LC_MESSAGES/djangojs.po'
Once these mappings have been set you can push the initial translations including the source
tx push -s -t
From here you can manage all of the translation progress including adding new languages through the Transifex interface. When you are ready for a new release you can pull the latest translations using the client
tx pull
Transifex is a great tool for open source developers to manage translations and integrating it into your project is quite easy. For additional resources on using Transifex and the CLI you can see their help site . You might also find “A Gringo’s Guide to Internationalization” from DjangoCon 2012 helpful.