Release status: unmaintained
|Implementation||Ajax, API, User interface|
|Description||Lightweight extension to live-translate articles using the Google Translate service|
|Author(s)||Jeroen De Dauwtalk|
|Latest version||1.3.0 (2013-07-02)|
|PHP||5.2 or later|
|License||GNU General Public License 3.0 or later|
|Translate the Live Translate extension if it is available at translatewiki.net|
|Check usage and version matrix.|
The Live Translate extension allows users to do live translation of wiki pages using either Google Translate or Microsoft Translator. 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 the Google/Microsoft translation service.
- Live translation of page contents using either Google's or Microsoft's translation services.
- "Auto-translation" so that, if a user translates a page into a certain language, or has their language preference set to a language other than the wiki's, subsequent pages will automatically get translated to that other language.
- Ability to define translations of special words in-wiki or in a remote file in either a special wiki format or TMX. These are then left alone by Google Translate.
- Support for multiple translation memories which can be added and managed via a GUI.
- Download and place the file(s) in a directory called
- Add the following code at the bottom of your LocalSettings.php:
- Run the update script which will automatically create the necessary database tables that this extension needs.
- Configure as required.
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
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.
You have to specify which languages users will be able to translate to. This is done by adding language codes to
By default it contains only your wiki's main language (as specified by
$wgLanguageCode in LocalSettings.php). You add languages to it as follows:
$egLiveTranslateLanguages = 'nl'; $egLiveTranslateLanguages = 'de';
If there are no languages available other than the current language of the page, then the translation control will not show up.
You can make use of either the Google Translate or Micorosft Translation services. You can specify the service with the following setting:
# Translation service to use. $egLiveTranslateService = LTS_MS;
Available values are
LTS_MS. The default is
Google API keyEdit
# Google API key $egGoogleApiKey = 'INSERT-YOUR-KEY-HERE';
Microsoft Client ID and secretEdit
To be able to use the Microsoft Translation service, you need to get a Microsoft Client ID and "secret"; you will need to get a Bing account first, if you don't already have one. Once you get those values, add lines like the following to your LocalSettings.php file, after the inclusion of the extension.
# Microsoft client info $egLiveTranslateMSClientId = 'CLIENT-ID-HERE'; $egLiveTranslateMSClientSecret = 'CLIENT-SECRET-HERE';
In order to edit the list of translation memories, you need the 'managetms' permission. By default only sysops have this permission.
$wgGroupPermissions['sysop']['managetms'] = true;
By default, Live Translate will automatically translate pages into a specific language, if the user has set that language in their user preferences, or if they have previously translated a page into that language. You can avoid that by adding the following to LocalSettings.php, after the inclusion of the extension:
$egLTAutoTranslate = false;
Avoiding auto-translation may be useful if you have a high-traffic wiki, and you want to make sure that your number of translated bytes per month does not exceed the allowed quota for your account.
The translation controlEdit
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.
Managing translation dictionariesEdit
You can define multiple translation memories, which can be either local (in a wiki page) or remote (anything in a file), and can be in any of the supported translation memory formats. You can add new memories and manage existing ones via Special:LiveTranslate. By default this page can only by accessed by administrators, but this can be changed, see the configuration section. Saving the translation memories will result into them either getting imported or updated (if they already exist).
Explanation of the interface fields:
- Location: For local memories, this should be the name of the page. For remote memories, it should be the full path to the file.
- Type: The format of the translation memory. See "defining a translation dictionary".
- Local: Are the translations part of a wiki page or not?
- remove: Check this to remove the translation memory from Live Translate. The memory itself (file or wiki page) will continue to exist, but will stop being used in translations done via the Live Translate control.
Protecting local translation memories can be done using the native MediaWiki page protection functionality.
Defining a translation dictionaryEdit
Live Translate supports two translation memory formats.
Live Translate formatEdit
This format was created specially for this extension and easy use on wikis. It's a simple CSV (comma-separated values) style format, in which 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 format 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".
Translation Memory eXchangeEdit
This is a commonly-used standard for translation memories. See the Wikipedia article.
Automated translation services produce text which can contain errors of grammar. The translation can be incomplete, or can contain mis-translations, through mis-identification of the correct context of a translated word. This extension is best suited to translating texts to the reader's language (for which it was designed) or to produce a first draft of a translation which is then revised by a human translator before being published. It is not suited to be used to produce text for publication or onward distribution.
- Update for new Microsoft translation API.
- Added auto-translation feature.
- Added action-managetms message.
- Fixed script loading issue occurring when ResourceLoader debugging is off.
- Fixed Internet Explorer compatibility issue.
- Added caching layer utilizing memory and LocalStorage when available to speed up local translations.
- Added API module to query translation memories.
- Added i18n alias file.
- Added TMX admin user rights group.
- Fixed Internet Explorer compatibility issue.
- Fixed bug in Microsoft transltion script for MW < 1.17.
- Made Microsoft transltion script more robust by adding timeouts.
- Added support for the Microsoft Translation service.
- Added support for comments in the LiveTranslate TMX format.
- Added option (on by default) to store insignificant translations.
- Tweaked the LTF parser to allow specifying a word that should never be translated.
- Fixed bug in the API.
- Added missing right declaration.
- Added settings to specify per-namespace if the translation control should be shown or not.
- Use of FormatJson::encode instead of josn_encode for compatibility with PHP5 < 5.2.
- Modified the LT API to work with batches, so translation doesn't break for big translation memories.
- Fixed regex escaping issue that caused translations to stop when encountering certain characters in special words.
- Added support for multiple translation memories.
- Added Special:LiveTranslate to manage the translation memories that should be used.
- Added support for remote translation memories.
- Added support for the Translation Memory eXchange (TMX) format.
- Added Google branding, which is required when using the Google Translate API.
- Improved translation memory insertion into the database.
- Added better tracking of translation memory sizes and language counts.
- Added compatibility with IE8.
- Fixed issue with trim-prevention, causing |-signs to semi-randomly get inserted into translated text.
- Only show the translation control when an API key is provided.
- Fixed installation compatibility issue with MW 1.16.
- Fixed display of translation control to only happen on existing pages.
- Fixed issues with inserting notranslatre tags into the page source.
- 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.
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.
These features would be nice to add at some point:
- Utilize HTML5 localStorage when available to store the TMX data relevant to the user. For TMXs with a few thousands translations, this would eliminate several big HTTP requests that need to happen before each translation, thus providing a significant speedup. Invalidation can be done by requesting a simple hash or timestamp of the last TMX update via some new API module.
Live Translate was written by Jeroen De Dauw as a WikiWorks consultant for Texas Instruments. Additional work was done by Nischay Nahata and Yaron Koren, again as WikiWorks consultants for Texas Instruments.