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.

After doing this, you have installed the extension. To be able to use it in a meaningful way, you also need to take care of some configuration:

Configuration
Configuration of Live Translate is done by adding simple PHP statements to your LocalSettings.php file. These statements need to be placed AFTER the inclusion of Live Translate. The options are listed below and their default is set in the Live Translate settings file. You should NOT modify the settings file, but can have a look at it to get an idea of how to use the settings, in case the below descriptions do not suffice.

Google API key
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.

Available languages
You have to specify which languages users should be able to translate to. This is done by adding language codes to. By default it contains only your wikis main language (as specified by  in LocalSettings.php). You add languages as follows:

If there are no languages available other then the current language of the page, then the translation control will not show up.

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.