Extension:Live Translate

Live Translate is a simple extension that allows live translation of wiki pages using Google Translate. It also enables you to define a "dictionary" of certain words or phrases and their translations; any word or phrase in the original text found in the "dictionary" will be translated using that dictionary, instead of using Google Translate.

Feature overview

 * Live translation of page contents using Google Translate.
 * Ability to define translations of special words in-wiki that will then be left alone by Google Translate.

Installation
Once you have downloaded the code, place the LiveTranslate directory within your MediaWiki 'extensions' directory. Then add the following code to your LocalSettings.php file:

require_once( "$IP/extensions/LiveTranslate/LiveTranslate.php" );
 * 1) Live Translate

After this you need to run MediaWikis update script which can be found at /maintenance/update.php.

To be able to actually use Google Translate, you need to get an API key and add it to your LocalSettings.php file AFTER the inclusion of the extension.

Usage
Live Translate adds a "Translate" button to the top right-hand corner of wiki pages, together with a dropdown menu that allows you to select the target language. Hitting the "Translate" button will cause the text in the wiki page to be translated to the selected destination language within the browser (it will not modify the original source text in any way). The source language will be assumed to be the wiki's main language, unless the wiki page's name ends with a "/" and then a language code, e.g., "Main Page/de" - if that is the case, the wiki page's language will be assumed to be the one that corresponds to that language code.

After a user hits the "Translate" button, another button, "Show original", will appear, which if pressed will return the display to its original language.

Defining a translation dictionary
You can define a dictionary of "special words" for which you provide translations, and that will then be left alone by Google Translate. This dictionary is defined in a page within the wiki; by default the page is named "Live Translate Dictionary", but this name can be changed in LocalSettings.php. The contents of the page should be a list in CSV (comma-separated values) format, where the first row contains the set of relevant language codes, and the successive ones the translations. An example would be:

en, nl, de Hello world, Hallo wereld, Hallo welt Awesome, Geweldig, Große

The dictionary supports defining synonyms. You can add them using the | sign as delimiter. For example, if you want "fantastic" to be translated the same as "awesome", the above dictionary would change to:

en, nl, de Hello world, Hallo wereld, Hallo welt Awesome|fantastic, Geweldig, Große

This means that "fantastic" will be "handled" exactly the same as "Awesome" when translating from English to one of the other languages. When translating to English, the first word in the synonym list, in this case "Awesome", will be used. So translating the Dutch "Geweldig" to English will result in "Awesome".

Version 0.1
2010-12-xx


 * Added simple translation interface to the right top of articles.
 * Implemented translation via the Google Translate API.
 * Added dictionary for special words with synonyms support.

Internationalization
Live Translate is fully internationalized. Translation of Live Translate messages is done through translatewiki.net. The translation for this extension can be found here. To add language values or change existing ones, you should create an account on translatewiki.net, then request permission from the administrators to translate a certain language or languages on this page (this is a very simple process). Once you have permission for a given language, you can log in and add or edit whatever messages you want to in that language.

Authors
Live Translate has been written by Jeroen De Dauw as WikiWorks consultant for Texas Instruments.