Wednesday, December 30, 2015

i18n: an unusual scenario

Reeborg's World currently has a "default" English version, a French version, and a partially implemented Korean version. Even if one forgets about the fairly extensive documentation [en, fr, ko], creating a new language version can be a rather daunting task.

For most applications, creating a new language version requires to create a collection of strings as a template for translation and provide a translation for each string in that template. The standard approach for doing this is to use gettext [0].  Would-be translators then have to either install some software (poedit is the standard) or register as a translator on some web-based site (e.g. where they may have to prove their worth before being approved as a translator.   These extra steps (installing some software or jumping through some hoops to register on some site) can be a turn off. [1]

One of my motivations for dropping RUR-PLE in favour of a web-based version was to reduce the friction for the end user.  Initially, installing RUR-PLE meant 1) installing Python; 2) installing the corresponding version of wxPython; 3) downloading RUR-PLE itself as a zip file.   Eventually, some volunteers helped to create various installers for it ... but this was not something I could easily do myself and it still required end-users (say: teachers in a classroom) to install some "unusual" software which, I found out, was not (easily) possible to do in some school environment.

By contrast, using Reeborg's World simply requires to open the site in a browser [2].  By choice, no login is required as I want the end-user experience to be as painless as possible; everything is run client-side.  I would like to create an "as painless as possible" experience as well for would-be translators.

To understand what is required for a full translation (excluding the documentation!) of the user interface, I will use a simple example.  Imagine that we want the end-user to be able to run the following program (using Python):


This being a tool to teach Python, we have also to enable the end-user to type


and get some appropriate help.  Here's the result of doing so:

Since Reeborg's World also support Javascript, we could run


Finally, since it supports Blockly as well, the same program could be executed via:

where is the representation of a "token" in Reeborg's World, one of a dozen basic objects that can be interacted with by Reeborg. Here's how the same program would appear to a French user using Blockly

from which you can easily deduce how to write the corresponding program using either Python or Javascript.

Having this basic scenario in mind, here's what's needed to translate:

1. The main html page (currently world.html for the English version and monde.html for the French version - but this will likely change in the near future).  This can be done using a template and creating static pages by inserting the appropriate translation strings into the template.  (This is not how it is done currently ... but should soon be.)

2. Create a complete Python module for the target language (currently for the English version) containing the appropriate function definitions something like

def take(obj=None):
    """Takes an object.  If more than one type of objects is at 
       Reeborg's location, the type must be specified as an 
       argument, otherwise an exception will be raised.
    if obj is None:

3. Create a complete Javascript module (currently reeborg_en.js) for a similar definition

var take, ...;
reset_definitions = function () {
  take = _take_;

4. Create the appropriate translation strings so that Blockly programs can be translated into the target language (or, in some cases, ensure that a consistent English-version is used), something like

translation["take"] = "prend";
translation["token"] = "jeton";
translation_to_english["jeton"] = "token";

Like Blockly, I do not plan to make special allowance for plural forms of words.  While 1 and most of 4 above can be done using the standard gettext approach, 2 and 3 require a different approach.  I have asked for suggestions about this on HackerNews ... and, unsurprisingly, my query received no visible attention.[3]   So, I have come up with a plan to implement a custom and "unified" solution, applicable to all four steps above and somewhat inspired by the gettext approach. I want all of this to be done (client-side) via a custom page on my site, similar to the idea of translatewiki, but without requiring any login. The translators would have to save a file (end result) to their computer and email it to me ... which, hopefully, would not be seen as being too onerous for someone wanting support in their own language.  (I expect that most translations will be provided by educators wanting to use Reeborg's World.)  Of course, alternatively, they could clone the repo, make the required changes, and submit a pull request ... but that's not exactly painless!

If you have read this far, it likely means that you've had some experience with i18n strategies ... and perhaps have suggestions to offer which may help me avoid reinventing the wheel! ;-)

[0] Indeed this is what I (mostly) ended up using with RUR-PLE, whose interface is available in 7 languages).

[1] For the record, I wanted to correct a translation for Blockly where "to" was correctly translated into French as "à" except in one context where it should have been translated as "pour" ... but, upon loggin in, I was presented with a completely unrelated other translation task, with some hint that additional tasks were to come before I could be approved...  and with no guarantee that the correction I wanted to make would be accepted.  In the end, I just gave up and implemented the correction in the version I use on Reeborg's World.  I don't think that my reluctance at jumping through the hoops mentioned is particularly unusual ... especially to those that have done editing on Wikipedia :-/

[2] I am aware that some schools have filters that prevent browsing on some non-approved site. From what I understand, it is easier to get permission to add new allowed sites than it is to install some "unusual" software.  Furthermore, unlike RUR-PLE, Reeborg's World can be used from someone else's computer (e.g. from a Public Library) where it would definitely be impossible to install some software.

[3] I didn't bother with StackOverflow as this was the type of question often flagged as not being too vague or something similar.

No comments: