Jump to content

Extension:Polyglot

From mediawiki.org
MediaWiki extensions manual
Polyglot
Release status: unmaintained
Implementation Page action , MyWiki , Locale
Description support for content in multiple languages in a single MediaWiki
Author(s) Duesentrieb
Maintainer(s) Kipmaster
MediaWiki 1.23+
Database changes No
License GNU General Public License 2.0 or later
Download
README
log

  • $wgPolyglotLanguages
  • $wfPolyglotExcemptNamespaces
  • $wfPolyglotExcemptTalkPages
  • $wfPolyglotFollowRedirects
Quarterly downloads 7 (Ranked 133rd)
Translate the Polyglot extension if it is available at translatewiki.net

The Polyglot extension provides automatic redirects based on user language. This allows for multilingual content to be handled more easily on a single wiki. Polyglot also changes the interlanguage links in the sidebar to automatically show available localized versions of each page on the same wiki.

For more comprehensive support for multilingual content, Polyglot can be combined with the LanguageSelector extensions.

Automatic redirects are performed based on a naming scheme: when visiting the page Foo with the user language set to de (German), Polyglot would redirect the user to Foo/de, if it exists. This automatic redirection can be bypassed by visiting Foo/, which will always show Foo proper. The base page (Foo in this example) is considered to be associated with the wiki's content language ($wgLanguageCode in LocalSettings.php).

Note that, in Wikitext links, [[Foo/|Foo (English)]] won’t work, use [[Foo|Foo (English)]] instead, i.e. omit the trailing slash. This is only for visiting pages, e.g. from the address bar.

Note that Polyglot can not readily be used to localize templates.

Installing

[edit]
  • Download and move the extracted Polyglot 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/Polyglot
  • Add the following code at the bottom of your LocalSettings.php file:
    require_once "$IP/extensions/Polyglot/Polyglot.php";
    
  • Configure as required
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration

[edit]

You can specify the following settings in your LocalSettings.php (after including the extension file):

$wgPolyglotLanguages
Languages to be considered when looking for matching subpages (localized versions). If set to NULL (the default), all languages known to MediaWiki (by $wgExtraLanguageNames) are considered. If the LanguageSelector extension is installed and $wgLanguageSelectorLanguages is set, that value will be used as a fallback. Setting $wgPolyglotLanguages to a shorter list may speed things up, especially on large wikis. For example, to let people choose between English (en), German (de) and French (fr), use $wgPolyglotLanguages = array('en', 'de', 'fr');
$wfPolyglotExcemptNamespaces [sic]
Namespaces that should not have magic redirection applied by Polyglot. Per default, this includes the Category, Image, Template, MediaWiki, Media, and Special namespaces. There should be no reason to remove any of those, but you can add more namespaces to be left alone.
$wfPolyglotExcemptTalkPages [sic]
Whether talk pages should be imune to magic redirection by Polyglot. True per default.
$wfPolyglotFollowRedirects
Whether Polyglot should follow redirects it finds as the target of a magic redirect. This is false per default; setting it to true causes an additional database lookup on every magic redirect, but it allows for localized page titles. For example, Main_Page/de could redirect to Hauptseite, so people with the user language set to "de" (German) would end up on a page called "Hauptseite" instead of the clunky "Main_Page/de". NOTE: currently, the magic interlanguage links don't take into consideration this type of redirect.

Todo

[edit]
  • Allow users to define page localization links manually, using the standard interlanguage link syntax and mechanism. Which links are treated as interlanguage links is determined by the interwiki table. An additional hook in Title.php would be needed to solved that, or dummy entries in the interwiki table.
  • When following redirects ( base -> local -> target ), make the "redirected from" bit show both, the base and the referring page. Would require a skin hack.
  • When following redirects, look at the redirecting pages subpages and siblings, and merge the result with the target page's language links.

See also

[edit]