Extension:ExtraLanguageLink

MediaWiki extensions manual
ExtraLanguageLink
Release status: unmaintained
Implementation Parser function
Description Allows extra links to be added to the "languages" sidebar section
Author(s) This, that and the othertalk
Latest version 1.0
MediaWiki >= 1.32.0
Database changes No
License Public domain
Download
  • $wgExtraLanguageLinkAllowedPrefixes
  • $wgExtraLanguageLinkAllowedTitles
Quarterly downloads 0
Translate the ExtraLanguageLink extension if it is available at translatewiki.net
Issues Open tasks · Report a bug

The ExtraLanguageLink extension allows you to add additional links to the "Languages" sidebar section on a given page, by way of a parser function/magic word embedded in the page's wikitext.

Installation

edit
  • Download and move the extracted ExtraLanguageLink 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/ExtraLanguageLink
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'ExtraLanguageLink' );
    
  • Configure as required
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

edit

The {{extralanguagelink}} magic word has the following syntax:

{{extralanguagelink:
 link target
 |link text
 |class=CSS class name(s)
 |style=CSS inline style
 |title=link title (hover) text
 |lang=language of link text
 |hreflang=language in which the target page is written
}}

Only the link target is required: all other parameters are optional. Localised names for the parameters may be available.

Technical stuff

edit

If extra language links are not allowed on the current page (see below), the parser function will fail silently – no error message will be shown. This is done so that a page containing {{extralanguagelink}} (e.g. the Main Page) can be transcluded onto any other page without spewing errors.

If a disallowed interwiki prefix is used (see below), or if an invalid title is supplied, an error message will be shown.

If setting up CSS styling on extra language links, be aware of the fact that the style attribute supplied to the parser function is applied to the ‎<a> tag (the link itself), while the class attribute is applied to the tag that contains the link (‎<li> in most skins, ‎<span> in Cologne Blue).

Configuration parameters

edit
$wgExtraLanguageLinkAllowedPrefixes

To restrict the use of this extension to certain interwiki prefixes, set $wgExtraLanguageLinkAllowedPrefixes to an array of allowed interwiki prefixes. Prefixes must be in lowercase only!

The empty string '' can be added to the array if you wish to allow extra language links to local pages.

The default value is false, meaning that {{extralanguagelink}} accepts all local and interwiki links.

For example,

$wgExtraLanguageLinkAllowedPrefixes = array( 'wikipedia', 'wiktionary', 'c2' );

would allow {{extralanguagelink:wikipedia:Jimmy Wales|Jimbo's page}} but not {{extralanguagelink:wikibooks:Book}} or {{extralanguagelink:Main Page}}.

$wgExtraLanguageLinkAllowedTitles

Set $wgExtraLanguageLinkAllowedTitles to an array of page titles on the wiki where the {{extralanguagelink}} parser function is allowed to be used. The default value is false, which allows its use on all pages.

Use spaces, not underscores, in this array.

For example:

$wgExtraLanguageLinkAllowedTitles = array( 'Main Page', 'Help:Contents' );

Scenarios

edit

Here are some scenarios in which this extension may be useful.

These are Wikimedia-specific examples, but this extension is general in nature, and these examples can be easily adapted to other sites. (Perhaps you might need to add some rows to your interwiki table first.)

1. Adding a "Complete list" link to the language links of a Wikipedia main page
In the wiki's configuration, set:
$wgExtraLanguageLinkAllowedPrefixes = array( 'm' );
$wgExtraLanguageLinkAllowedTitles = array( 'Main Page' );
On the Main Page, place:
{{extralanguagelink:m:List of Wikipedias|Complete list|style=font-weight: bold}}
2. Adding a "More languages" link to a Wikisource page
Some languages do not have their own version of Wikisource, so texts in those languages are hosted at Multilingual Wikisource. It might be good to add a link across to Multilingual Wikisource from the texts on language-specific domains.
In the wiki's configuration, set:
$wgExtraLanguageLinkAllowedPrefixes = array( 'oldwikisource' );
Create a template, say "Template:Mul-link", with the following content, or similar:
{{extralanguagelink:oldwikisource:{{{1}}}|More languages|style=font-weight: bold}}
Then transclude the template as needed:
{{mul-link|The Lord's Prayer}}