Mike Rooney

programming and philosophy

L10N: Integrating Translations Into Your Project

This post is the second half of my series on internationalization and localization; that is, making applications accessible to non-English speakers. I am going to assume now that you have followed the instructions in the first post , and have internationalized your source, put the translation template up on Launchpad, and hopefully have a translation or two.

Since my last post, many people donated their time to translate my project wxBanker, and I have 7 translations in Launchpad now! (If anyone wants to add more, please do so, and I’ll put you in the credits.) Now I’ll outline the steps for actually integrating these translations into your project.

  1. Download the translations. Visit the translations page for your project in Launchpad, and click the “Download translations” link on the right. From here ensure “Everything” is selected, and change the Format to “MO format”. This format is what the gettext framework we are using utilizes. Now click “Request Download”. They won’t typically be available immediately, but you should receive an e-mail in an hour or so with a link to the file.

  2. Once you receive the email from Launchpad, download the linked file. You should now have launchpad-export.tar.gz. Right click on it and “Extract Here”. Rename the resulting “launchpad-export” folder to something like “locales”, and put it in your project directory.

  3. Now all you have to do is tell gettext where the translations are. Previously we installed gettext via a line like gettext.install(“wxbanker”), and now all we need to do is pass in the directory as a second argument. So assuming you renamed the launchpad-export directory to “locales” and put it in the directory of your source code, you’ll change it to gettext.install(“wxbanker”, “locales”). This isn’t the most robust and flexible way to do this, and I would recommend checking out my localization.py link below for a better example, especially if you are going to be doing this for a python application.
Now, assuming you followed all the steps in the previous post and this one, your application should be completely localized and run in the native language of the person using it! If you want to see the translation yourself, check out my own version of localization.py, which allows you to pass in the language code corresponding to the subdirectory of the locales directory, such as “–lang=es” for Spanish.

In a day or two I will also add a post on how to actually install other locales in Ubuntu and run your application in it, so that you can ensure you are seeing exactly what someone from that locale sees.

Congratulations on a localized application! Any questions?