Extension:Interlanguage

From mediawiki.org
MediaWiki extensions manual
Interlanguage
Release status: unmaintained
Description Grabs interlanguage links from another wiki
Author(s) Nikola Smolenski
Latest version 1.6.1 (2014-04-03)
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki
License GNU General Public License 2.0 or later
Download

  • $wgInterlanguageExtensionDB
  • $wgInterlanguageExtensionApiUrl
  • $wgInterlanguageExtensionInterwiki
  • $wgInterlanguageExtensionSort
  • $wgInterlanguageExtensionSortPrepend
Quarterly downloads 8 (Ranked 142nd)
Translate the Interlanguage extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The Interlanguage extension and its pair Interlanguage Central extension aim to ease the handling of interlanguage links. From A newer look at the interwiki link:

As the Wikimedia projects grow, more articles are written about the same subject in different languages. When one interlanguage link is added in one project it will eventually be added to the other as well. In the case where 20 languages have an article on the same subject, each article should link to 19 other languages, so there are 20*19=380 links to edit and maintain. In case of 100 languages, the number of interlanguage links will amount to nearly 10,000.

While the extension works and could be used, on Wikimedia projects more versatile Wikibase and Wikibase Client extensions will be used instead.

Usage[edit]

The Interlanguage extension avoids this problem by fetching interlanguage links from another wiki (further: central wiki) whenever a page is saved (or purged). Central wiki may be a separate wiki, or one of the existing wikis. On the central wiki, the Interlanguage Central extension should be installed.

On the central wiki, interlanguage links are maintained in a similar way they are on any MediaWiki wiki. On wikis with the Interlanguage Extension installed, interlanguage links could now be added by writing {{interlanguage:article name}}, which will fetch all the interlanguage links from the central wiki page "article name". If the article on the central wiki doesn't exist, a red link towards it will be made so that it could be easily created. When a new interlanguage link is added to the central wiki, the Interlanguage Central extension purges the articles on the projects and updates their interlanguage links. The language links should be added by using {{languagelink:langcode|Article Title}}, which will add the interlanguage link, and write its name in the page as well.

The extension doesn't interfere with usual working of interlanguage links. They may continue to be used in parallel to the extension.

Installation[edit]

Interlanguage extension[edit]

Download the source files into your extensions/ directory, then add the following to your LocalSettings.php :

require_once($IP.'/extensions/Interlanguage/Interlanguage.php');
$wgInterlanguageExtensionApiUrl = 'http://example.com/api.php';
$wgInterlanguageExtensionInterwiki = 'example:';
$wgInterlanguageExtensionSort = 'alphabetic';

The variable $wgInterlanguageExtensionDB is the name of the database of the central wiki. It will be passed to the load balancer in order to get access to the database. See LoadBalancer settings on how to configure the load balancer or, if you all your wikis share a single database, simply use the database's name.

$wgInterlanguageExtensionDB = "example";

Both this variable and $wgInterlanguageExtensionApiUrl are mandatory and the extension can't function without one or the other.

The variable $wgInterlanguageExtensionApiUrl tells the extension where to find the MediaWiki API of the central wiki. For example, if you would want to fetch interlanguage links from the English Wikipedia (which you may do for testing purposes), the URL should be 'http://en.wikipedia.org/w/api.php'.

The variable $wgInterlanguageExtensionInterwiki tells the extension what the interwiki prefix of the central wiki is, which will be used to create link towards it if needed. It must include the colon at the end of the prefix. For example, if you are fetching interlanguage links from the English Wikipedia, it should be set to 'wikipedia:'. This variable is mandatory and the extension can't properly function without it.

The variable $wgInterlanguageExtensionSort selects the sort method you want to use for the interwiki links. Currently, it recognises four sort methods:

This variable may be omitted, in which case the 'none' sort mode will be used.

The variable $wgInterlanguageExtensionSortPrepend modifies the sort method so that it sorts certain languages at the top of the list of languages, regardless of their general sort order. It should be set to an array that has values set to desired language codes, in desired order. For example, to put English and then Simple English at the top of the list of languages, set it to array( 'en', 'simple' ). This variable may be omitted, in which case the sort will be used unmodified.

Interlanguage Central extension[edit]

Download the source files into your extensions/ directory, then add the following to your LocalSettings.php :

require_once($IP.'/extensions/Interlanguage/InterlanguageCentral.php');
$wgJobRunRate = 0;

Variable $wgJobRunRate is a standard MediaWiki variable and not a part of this extension. However, it is strongly advised to set it to 0 and run maintenance/runJobs.php periodically, or else editors of the central wiki may find it very slow. This variable may be omitted.

The extension will read API links to projects from the Interwiki table; see that page on how to configure them.

History[edit]

Interlanguage extension[edit]

1.0[edit]

June 10 2008: Initial release.

1.1[edit]

November 14 2008: Increased robustness and usability, more options.

  • Uses MediaWiki's Http::get() instead of file_get_contents() — much better response if the central wiki is down.
  • No longer uses hash: {{interlanguage:Page title}} instead of {{#interlanguage:Page title}}.
  • If API request fails, keep existing interlanguage links.
  • If the central wiki doesn't have the requested page, display a red link to it.
  • New configuration parameter $wgInterlanguageExtensionInterwiki, for the interwiki prefix of the central wiki.
  • New configuration parameter $wgInterlanguageExtensionPrefix, enables using a namespace or a subpage on the central wiki.
  • New configuration parameter $wgInterlanguageExtensionSortPrepend, enables using a custom sort order.
  • Take care of API's lllimit parameter.
  • Updated language sorting to take care of new languages.
  • More code comments.

1.2[edit]

Various smaller changes in the SVN.

  • Support for memcached.
  • See diff of all the changes.

1.3[edit]

July 30 2010: Display link(s) to the page(s) on the central wiki with interlanguage links below the edit form.

  • Displays link(s) to the page(s) on the central wiki with interlanguage links below the edit form.
    • Displays the links when editing.
    • Saves the links upon article save (in page_props table) so that they could be displayed.
  • Now contained in one class.
  • Updated language sorting to take care of new languages.
  • More and nicer code comments.

1.4[edit]

February 20 2011:

  • Ability to read links directly from a foreign database instead of via the API.
  • New configuration parameter $wgInterlanguageExtensionDB, for the parameters of the foreign database.
  • Ability to use local namespace names in interlanguage title.
  • Variable $wgInterlanguageExtensionPrefix is no longer used.
  • Other smaller changes.

1.5[edit]

March 30 2011:

  • Uses the load balancer instead of simply connecting to the foreign database.
  • Variable $wgInterlanguageExtensionDB changed its form.
  • Large internal changes.
    • Split the extension into multiple files.
    • Main function split into multiple functions.
    • Higher security.
    • Changes to extension startup.
  • Ability to use local namespace names in interlanguage title.
  • Other smaller changes.

See diff of all the changes.

Interlanguage Central extension[edit]

1.0[edit]

July 25 2010: Initial release.

1.1[edit]

February 20 2011: Minor changes.

1.2[edit]

March 27 2011:

  • Reads API links from the Interwiki table.
  • Variable $wgInterlanguageCentralExtensionIndexUrl is no longer used.
  • Other smaller changes.

1.3[edit]

May 9 2011:

  • Added {{languagelink}} magic.

See also[edit]