Extension:Polyglot

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

For more comprehensive support for multilingual content, Polyglot can be combined with the Multilang and 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 Polyglot can not readily be used to localized templates. Instead, use the Multilang extension for template messages.

Installing
Copy the Polyglot directory into the extensions folder of your MediaWiki installation. Then add the following line to your LocalSettings.php file (near the end):

require_once( "$IP/extensions/Polyglot/Polyglot.php" );

Configuration
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 th NULL (the default), all languages known to MediaWiki (by $wgLanguageNames) 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: 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: wether talk pages should be imune to magic redirection by Polyglot. true per default.
 * $wfPolyglotFollowRedirects: wether Polyglot should follow redirects it find 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 locaized 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

 * allowing users to define page localization links manually, using the standard interlanguage link syntax and mechanism. Which links are treated as interlanguage links is determiend 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 refering 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.