Art. 122-5


[modifier] MultiLanguage Manager

The articles of a wiki are written in only one language, the configuration language set with the variable "wgLanguageCode". The logged users can choose to use an another language for the user interface. The problem comes when you want to propose a wiki with articles in different languages.

[modifier] Existing solutions

  • One solution is to install a different wiki for each languageso you can use the interwiki link to switch the language. This solution is really a good one for wiki like Wikipedia, but it's too heavy for a small one. You must maintain system as much than you want language. You can't be sure that a page in french that translate an english article was indicate from the english article as an available translation (for exemple).
  • There is the solution that uses the ParserFunctions extension. It's really easy to used, but as the first one you have to maintain the coherence of the system. And the title of each translation is in the default language of the wiki, and that 's not good for referencing.
  • The MultiLang Extension is used to display a part of the article in the language chose by the user in his settings. That's not really what we want.
  • The MultiLangue Extension does the same thing as the previous one excepted that it uses the language setting of the browser. That's not really what we want and that's not a good idea because the user loses the choice of the language.

[modifier] The MultiLanguage Manager

It's an extension : you don't have to change the MediWiki code (excepted some evolution of the templates). You can manage language as much than you want on one system (there's a default language). Your are free to choose each article title and when you indicate that an english article is the translation of a french one, you can be sure that the french article is indicated to be the translation of the english one. An article can have more than one (or none) translation for each language.

The MultiLanguage Manager could be customized for each supported skins.

This extension requires PHP 5, it has been tested with MediaWiki 1.6.10 and 1.10.0. If you're not sure that the extension works with your configuration, take a look at the unit testing section.

[modifier] How to use it

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

[modifier] Edit language settings for an article

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

[modifier] Consultation

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.

[modifier] Miscellaneous

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

[modifier] Installation

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.

[modifier] Copy the extension files

First, download the extension : MultiLanguageManager 1.0.1.tgz

Unzip it in your extension folder :


[modifier] Database

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

CREATE TABLE wiki_page_language (
  page_id int(8) NOT NULL,
  lang varchar(3) NOT NULL,
  PRIMARY KEY  (page_id)
) TYPE=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)
) TYPE=InnoDB;

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

  • the suffix “wiki_”
  • the type of table Mysql “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 navigator. He will give you SQL script to used and if the SQL user of the wiki can create tables, you can use it to create the necessary tables.

Warning, remove this script when you stop to need it !!

[modifier] Changes to LocalSettings.php


[modifier] Add it to your template

To display the language selection, you have to modify your template to add the following code where you wish to see appearing the selection language element :

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

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

[modifier] Configuration

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

[modifier] the available languages

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 internationalization file.

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

[modifier] The users rights

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 : langage :


then think of set the rights according to the groups:

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

[modifier] Customization

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

[modifier] Create a new skin

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.

[modifier] Customize the CSS

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 succesful operation
  • class_error = languageError : Style of a failed operation

[modifier] Unit testing

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 you council 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

[modifier] How to use it with others extensions

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)

[modifier] Licence

This extension is distributed under GPL v2 licence

 * Copyright (C) 2007  Marc Despland
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA

You are free :

  • modify
  • distribute
  • use

this extension, with a commercial aim or not.

Any time you have to respect the licence clauses, in particular:

  • Even if you modify it, this extension remains under GPL
  • You are not authorized to remove information relating to its author or the licence

[modifier] ChangeLog

  • 2007-06-13 : 1.0.0 Initial revision
  • 2007-11-11 : 1.0.1 Bugs correction
    • Work with and without url beautifying
    • Correct problem with special char in page name
    • Work with custom namespace
    • Correct a problem when delete page
    • correct the return value of hook functions
What links here
Un peu de musique ?

A propos