Skip to content

i19n

Wikipedia has language editions, Wikidata has labels, aliases, descriptions, and some properties in multiple languages. This a great resource, to get the world’s knowledge in your language! But looking at the technical site, things become a little dim. Wikimedia sites have their interface translated in many languages, but beyond that, English rules supreme. Despite many requests, only few tools on Labs have a translatable (and translated) interface.

One exception is PetScan, which uses the i18n mechanism from its predecessor CatScan, namely a single wiki page on meta, which contains all interface translations. This works in principle, as the many translations there show, but it has several disadvantages, ranging from bespoke wikitext parsing, over load/rendering times on meta, to the fact that there is no easy way to answer the question “which of these keys have not been translated into Italian”? New software features require new interface strings, so the situation gets worse over time.

The answer I got when asking about good ways to translate interfaces is usually “just use TranslateWiki“, which IIRC is used for the official Wikimedia sites. This is a great project, with powerful applications, but I was looking for something more light-weight, both on the “add a translation” side, and the “how to use this in my tool” side.

ToolTranslateIf you know me or my blog, then by this point, you will already have guessed what happened next: I rolled my own (for more detailed information, see the manual page).

ToolTranslate is a tool that allows everyone (after the usual OAuth ceremony) to provide translations for interface texts, in almost 300 languages. I even made a video demonstrating how easy it is to add translations (ToolTranslate uses its own mechanism, so the demo edit shows up live in the interface). You can even also your own tool, without having to jump through bureaucratic hurdles, just with the press of a button!

On the tool-author side, you will have to change your HTML, from <div>My text</div> to <div tt=”mytext”></div>, and then add “My text” as a translation for the “mytext” key. Just use the language(s) you know, anyone can add translations in other languages later.I experienced this myself; after I uploaded the demo video, User:Geraki added Greek translations to the interface, before this blog post, or any other instructions, were available. Just, suddenly, as if by magic, Greek appeared as an interface option… You will also need to include a JavaScript file I provide, and add a single line of code (two, if you want to have a drop-down to switch languages live).

There is a simplistic demo page, mainly intended for tool authors, to see how it works in practice. Besides ToolTranslate itself, I also used it on my WikiLovesMonuments tool, to show that it is feasible to retrofit an existing tool. This took less than 10 minutes.

I do provide the necessary JavaScript code to convert HTML/JS-based tools. I will be working on a PHP class next, if there is demand. All translations are also provided as JSON files online, so you can, in turn, “roll your own” code if you want. And if you have existing translations for your tool and want to switch to ToolTranslate, let me know, and I can import your existing translations.

4 Comments

  1. Papuass wrote:

    It is not clear if I should add HTML tags for italic text, as it works in WLM tool. Maybe these should not be a part from translation after all?

    Wednesday, July 20, 2016 at 14:22 | Permalink
  2. Magnus wrote:

    Thought about this, but patching HTML together from lots of message bits is too cumbersome IMO, so unless the entire message is in italics, my advice is to put the HTML in as in the “primary language” (usually English).

    Thursday, July 21, 2016 at 09:21 | Permalink
  3. Nemo wrote:

    Did something go wrong? I see the “English” petscan with Hebrew strings. http://archive.is/kcJdl

    Saturday, August 6, 2016 at 09:08 | Permalink
  4. Magnus wrote:

    @nemo Someone (https://meta.wikimedia.org/wiki/Special:CentralAuth/%D7%A2%D7%A8%D7%9F) tried to add a Hebrew translation, but changed English instead. Seems (s)he fixed it already. See https://tools.wmflabs.org/tooltranslate/#tool=11&mode=rc

    Saturday, August 6, 2016 at 11:29 | Permalink