We re-launched YouRTI.in and introduced the Telugu version on the 23rd of August 2018. It was an official announcement of the partnership with the Hyderabad-based NGO Yugantar. We had a member of the Central Information Commission present to “launch” the site and talk about the importance of the Right to Information [known in other countries as the Freedom of Information] Act.

One of the great benefits of a framework like Django is that it comes with internationalization built in, so most of the hard work involved translating the text and marking static text strings for substitution when the user changes language.

For example, where earlier the front-end HTML code in a template was:

<title>YouRTI.in - Submit free online RTI requests conveniently</title>

The new code is:

<title>{% trans "YouRTI.in - Submit free online RTI requests conveniently" %}</title>

The back-end is also pretty simple. It requires importing a method from the translation module, either ugettext or ugettext_lazy. The difference is that while both fetch the language based on the user’s selection, the lazy version waits until it actually has to be rendered to the template, so it is dynamically updated. To use it, wrap any text strings that need to be translated with a call to ugettext (or more likely, ugettext_lazy).

from django.utils.translation import ugettext_lazy as _

request_statuses = [
   _('Deleted'),
   _('Draft'),
   _('Incomplete'),
   _('New (Unsent)'),
...
]

In order to extract the strings for translation execute the Django command makemessages. This creates a language file with the strings to be translated. It looks like this:

#: templates/index.html:3
msgid "YouRTI.in - Submit free online RTI requests conveniently"
msgstr ""

Edit this file with a .po extension and fill in the translations in the line marked msgstr. Once the translations are done, or even before that, run the command compilemessages. Whatever strings have been translated in the .po file will then be presented on screen when the user changes the language. There are a couple other steps like turning internalization on to begin with, setting up the locale directory and specifying the list of languages you want to support. It’s covered in the Django documentation.

The next language we will tackle at YouRTI.in will be Urdu. Since I did all the necessary code changes to enable Telugu, what remains is to make the Urdu the translations. However, with the right-to-left text orientation, I expect that some UI tweaking will also be necessary to render the page coherently.