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).

[pastacode lang=”python” manual=”from%20django.utils.translation%20import%20ugettext_lazy%20as%20_%0A%0Arequest_statuses%20%3D%20%5B%0A%20%20%20_(‘Deleted’)%2C%0A%20%20%20_(‘Draft’)%2C%0A%20%20%20_(‘Incomplete’)%2C%0A%20%20%20_(‘New%20(Unsent)’)%2C%0A…%0A%5D” message=”” highlight=”” provider=”manual”/]

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:

[pastacode lang=”markdown” manual=”%23%3A%20templates%2Findex.html%3A3%0Amsgid%20%22YouRTI.in%20-%20Submit%20free%20online%20RTI%20requests%20conveniently%22%0Amsgstr%20%22%22%0A” message=”” highlight=”” provider=”manual”/]

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.