Jump to content

Extension:GoogleTranslate

From mediawiki.org
MediaWiki extensions manual
GoogleTranslate
Release status: stable
Implementation Page action
Description Add a button to translate the current page using Google Translate
Author(s) Sophivorustalk
Latest version 3.3
MediaWiki >= 1.39.0
Database changes No
License GNU General Public License 3.0 or later
Download
Example [1]
  • $wgGoogleTranslateSaveTitle
  • $wgGoogleTranslateNearEdit
  • $wgGoogleTranslateSaveNotice
  • $wgGoogleTranslateSubpageLanguage
  • $wgGoogleTranslateSave
  • $wgGoogleTranslateNamespaces
  • $wgGoogleTranslateSaveTreshold
  • $wgGoogleTranslateSystemAccount
  • $wgGoogleTranslateSaveCategories
Quarterly downloads 10 (Ranked 130th)
Translate the GoogleTranslate extension if it is available at translatewiki.net

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

[edit]
  • 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

[edit]

GoogleTranslate requires no configuration. However, the following options are available. They are shown along 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. 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

[edit]

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

[edit]