From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png

Release status:Extension status stable

ImplementationTemplate:Extension#type Database, Locale
DescriptionTemplate:Extension#description Add multi-languages capacities to a wiki
Author(s)Template:Extension#username Marc Despland
Latest versionTemplate:Extension#version 1.0.1 (2007-11-11)
MediaWikiTemplate:Extension#mediawiki 1.6.10+
LicenseTemplate:Extension#license No license specified
Download MultiLanguageManager on GitHub
original documentation
ExampleTemplate:Extension#example http://www.art122-5.net/
Added rightsTemplate:Extension#rights


Translate the MultiLanguageManager extension if it is available at translatewiki.net

Check usage and version matrix.

What can this extension do?[edit]

With this extension, you can add multi-languages capacities to a wiki. You can define a list of available languages. you can set the language of an article and the list of available translations for this article.


The extension was designed to be as simple to use as possible.

Edit language settings for an article[edit]

You have to use the new tab "language" to display the property settings of the current article.

  • You can choose the article language.
  • You can indicate which article translates the current one


There is nothing more easy than the browsing. For example in the Art122-5 site, you have to only click on the flag to switch between the available languages (french-english). A popup window (CSS) is displayed to choose the page if more than one translation is available.


If your MediaWiki version is greater than 1.8, the language of the user interface is adapted to the article language for the guests. For the logged users, they can choose the UI language in their settings, we don't have to change their choice


The installation needs three successive stages, we very highly advise you to proceed to an installation on a test server before modifying your production server. A backup is always a good idea before making modifications.

Copy the extension files[edit]

First, download the extension : MultiLanguageManager 1.0.1.zip

Unzip it in your extension folder :



To use this extension, you have to create two database tables:

CREATE TABLE wiki_page_language (
  page_id int(8) NOT NULL,
  lang varchar(3) NOT NULL,
  PRIMARY KEY  (page_id)
) ENGINE=InnoDB;  
CREATE TABLE wiki_page_translation (
  `source` int(8) NOT NULL,
  translate int(8) NOT NULL,
  UNIQUE KEY source_2 (`source`,translate),
  KEY `source` (`source`),
  KEY translate (translate)

You can create them manually, but you must be careful to respect the configuration of your wiki :

  • the DB prefix ($wgDBprefix), here: “wiki_”
  • the type of DB table ($wgDBtype), here: “TYPE=InnoDB”

You can also use the script MultiLanguageManager_createTable.php (extension/MultiLanguageManager/Tools). Copy it in your wiki root directory and charge it via your command line ("php MultiLanguageManager_createTable.php"). This will give you the MySQL script to be used. Copy&paste it into the MySQL command line. And remember to remove the script after use!

Add it to your template[edit]

To display the language selection, you have to modify your template (e.g., skins/MonoBook.php) to add the following code where you wish to see appearing the selection language element :

   $languageController=new MultiLanguageManager_controller();
   echo $languageController->displaySelectLanguage($myTitle); 

Examples for where to add those lines for Monobook and other templates, as well as additional steps can be found in a discussion-thread on Artnet122.5.net.

Hint: you should search for the template area of your default skin at skins/name_of_the_skin.php


with monobook skin, you should search for the first sidebar menu and add the above lines immediately before it:

   /* begin Multilanguage related  */
   $languageController=new MultiLanguageManager_controller();
   echo $languageController->displaySelectLanguage($myTitle);
   /* end Multilanguage related  */  

               $sidebar = $this->data['sidebar'];
               if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
               if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
               if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;

You also have to change your CSS files, cf Customize the CSS.

Changes to LocalSettings.php[edit]



You can configure the extension using the “MultiLanguageManager_setup.php” file , there are other elements that you can configure : CF Customization.

the available languages[edit]

It is the list of the languages applicable to the contents of this site. Pay attention, if you alter this parameter, you have to modify the [#Customisation|Template]] as well as the translations of the expressions used by this extension : MultiLanguageManager.i18n.php

The configuration is done using the $mgAvailableLanguage variable which contains the code of language and the code of its name in the file MultiLanguageManager_setup.php.

   'en' => 'multilanguagemanager_en',
   'fr' => 'multilanguagemanager_fr');

Additional languages can be found here:

The users rights[edit]

You can manage who has the rights to modify the linguistic parameters of the pages. You can set those users rights to match with an existing right using the $mgLanguagePermisionsKey variable . For example to set the linguistic rights to match the edition article rights:


But you could also choose an other rights : language :


Then think of set the rights according to the groups:

$wgGroupPermissions['*'][$mgLanguagePermisionsKey] = false;
$wgGroupPermissions['user'][$mgLanguagePermisionsKey] = true;
$wgGroupPermissions['sysop'][$mgLanguagePermisionsKey] = true;


MultiLanguage Manager has been designed to adapt to different skins. The graphic functions are isolated in the file MultiLanguageManager_template.php containing the class from the same name. It contains the various method used to create the view.

You must not modify it. If you alter this file, the change could touch all the skins. Indeed the module uses this class only if it can't find specific class for your skin. It is the generic class derived by all the module skin

Create a new skin[edit]

In the extensions/MultiLanguageManager/skins directory, duplicate the Default.php file and name the copy of the name of your skin (the same file name as the .php of the directory skins of the wiki).

By defect this class contains only the manufacturer, but you can overload all the methods of your choice. An example is given with the Art122-5.php file that modify the method of the popup to correspond to the style of the wiki.

Customize the CSS[edit]

You also have the possibility of personalizing the CSS. The name of the various classes can be modified by overloading the variables $class_ of the class ' MultiLanguageManager_template

  • class_icon = languageimage : The icon style (small flag)
  • class_image = languageimage : The big flag style
  • class_popup = popup : Style of the span containing the visible text starting the opening of the popup
  • class_cadre_popup = cadre_popup : Style of the div of the popup
  • class_direct_link = language : Style of a direct link to a page
  • class_headline = mw-headline : Style of the title (default)
  • class_language_info = displayLanguageInfo : Style of the text of information of the language page
  • class_result = languageResult : Style of a successful operation
  • class_error = languageError : Style of a failed operation

Unit testing[edit]

This extension is accompanied by two series of unit tests using phpunit. You can use it to ensure you that the extension is quite compatible with your configuration.

Even if my unit tests never caused damage on a database, I recommend very highly to do it on a test server.

To function you must have created a minimum of 5 pages on the wiki. You also should modify line 75 of the MultiLanguageManagerTest.php file by indicating the name of a user having the right to modify the linguistic parameters of the pages.

To use the two unit tests, recopy the files:

  • MultiLanguageManagerTest.php
  • MultiLanguageManager_SkinnTest.php

in the root of your Wiki and open them with a navigator. You will obtain in result, if all is well, something which look like that (look at the source of the page of result):

PHPUnit 3.0.6 by Sebastian Bergmann.


Time: 00:00

OK (39 tests)

or if an error occurs (look at the source of the page of result)

PHPUnit 3.0.6 by Sebastian Bergmann.


Time: 00:00

There was 1 failure:

1) testCreateDetailLanguagePage_scenario1_ndl(MultiLanguageManager_Test)
Failed asserting that <boolean:false> is identical to <boolean:true>.

Tests: 39, Failures: 1.

If you do not obtain the last lines, a critical error occurred. then consult the logs of your Web server.

Think of removing these files of test of your waiter when you don't need them any more

How to use it with others extensions[edit]

The MultiLanguageManager_controller class exposes some functions which can be used in other MediaWiki extensions to interact with this extension. Defer to the code of the class for the detail of its methods public.

A constant ART122-5 MULTILANGUEMANAGER makes it possible to determine if the extension is installed on the server.

Among the functions, we could quote getPageLanguage ($pageid) which turns over the code of language according to Id of article (that one could be obtained via the getArticleID function of the title class for example)



Articles can not be deleted with this extension because there is a Bug in MultiLanguageManager.php. Corrected with 1.0.1


The ArticleDelete hook requires a boolean function return value to successful execute the deletion and the mlCleanLanguageOnArticleDelete function does not return anything. To prevent the deletion problem just put return(true); at the end of the function and the article deletion will work fine again. Corrected with 1.0.1

As 1.0.1 is no longer available you will need a return(true) at the bottom of a number of these functions to get this working...