Extension:GoogleTranslate

Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:GPL licensed extensions
MediaWiki extensions manual
GoogleTranslate
Release status: stableCategory:Stable extensions
Implementation Page action Category:Page action extensions
Description Add a button to translate the current page using Google Translate
Author(s) Sophivorustalk
Latest version 3.4
MediaWiki >= 1.39.0
Database changes No
License GNU General Public License 3.0 or later
Download Category:Extensions in Wikimedia version control
Example
  • $wgGoogleTranslateSaveTitle
  • $wgGoogleTranslateNearEdit
  • $wgGoogleTranslateSaveNotice
  • $wgGoogleTranslateSubpageLanguage
  • $wgGoogleTranslateSave
  • $wgGoogleTranslateNamespaces
  • $wgGoogleTranslateSaveTreshold
  • $wgGoogleTranslateSystemAccount
  • $wgGoogleTranslateSaveCategories
Quarterly downloads 5 (Ranked 111st)
Translate the GoogleTranslate extension if it is available at translatewiki.net
Category:All extensions

The GoogleTranslate extension adds a button to translate the current page using Google Translate. It can also be configured to save the generated translations into subpages.

Installation

  • Download and move the extracted GoogleTranslate folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleTranslate
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'GoogleTranslate' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

GoogleTranslate requires no configuration. However, the following options are available (shown with their default values):

// Namespaces where to show the Translate button
$wgGoogleTranslateNamespaces = [ NS_MAIN ];

// Location of the Translate button
$wgGoogleTranslateNearEdit = true;

By default, generated translations are not saved. To save them, first install and configure Extension:HTMLPurifier (or enable $wgRawHtml, if you understand the risk). Then set the following options to your liking:

// Change this to enable translation saving
$wgGoogleTranslateSave = false;

// Percentage of the page that needs to be translated before it gets saved (0.9 means 90%)
$wgGoogleTranslateSaveTreshold = 0.9;

// Change this to save the translated title in {{DISPLAYTITLE}}
// Enable $wgRestrictDisplayTitle to show the translated title
$wgGoogleTranslateSaveTitle = false;

// Change this to add translations to the same categories as the original page
$wgGoogleTranslateSaveCategories = false;

// Name of a template to prepend to every translation
$wgGoogleTranslateSaveNotice = "";

// Change this to set the language of the translations from the subpage name
// Note that $wgNamespacesWithSubpages needs to be enabled for this to work
// Alternatively, enable $wgPageLanguageUseDB to allow this extension
// to set the language of the translation pages directly
$wgGoogleTranslateSubpageLanguage = false;

// Name of the system account that will do the saving
$wgGoogleTranslateSystemAccount = "Translations bot";

Note that if a user only translates part of a page, then the saved translation will be incomplete. However, if another user then comes along and translates more of the page, then the less complete translation will be replaced for the more complete one.

Usage

Simply go to any page and click the Translate button. If you enabled translation saving, then the translation should be automatically saved to the appropriate subpage after a few seconds.

See also

Category:Google extensions
Category:All extensions Category:BeforePageDisplay extensions Category:Extensions in Wikimedia version control Category:Extensions without a compatibility policy Category:Extensions without an image Category:GPL licensed extensions Category:Google extensions Category:PageContentLanguage extensions Category:Page action extensions Category:ResourceLoaderGetConfigVars extensions Category:SkinTemplateNavigation::Universal extensions Category:Stable extensions