Extension:MultiLanguageManager

What can this extension do?
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.

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

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

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.

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

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.

Copy the extension files
First, download the extension : MultiLanguageManager 1.0.0.tgz (note that 1.0.1 is available above)

Unzip it in your extension folder : ./images ./images/deutsch.png ./images/deutsch_icon.png ./images/english.png ./images/english_icon.png ./images/francais.png ./images/francais_icon.png ./images/Thumbs.db ./MultiLanguageManager.i18n.php ./MultiLanguageManager.php ./MultiLanguageManager_body.php ./MultiLanguageManager_controller.php ./MultiLanguageManager_setup.php ./MultiLanguageManager_template.php ./skins ./skins/Art122_5.php ./skins/Default.php ./skins/Tests.php ./tools ./tools/MultiLanguageManagerTest.php ./tools/MultiLanguageManager_createTable.php ./tools/MultiLanguageManager_SkinnTest.php

Database
To use this extension, you have to create two database tables: 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
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 :

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

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

data['articleid']); '''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.

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

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 file MultiLanguageManager_setup.php.

Additional languages can be found here:
 * Corrected German translation
 * Swedish, Italian and Spanish translation

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

Then think of set the rights according to the groups:

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'''

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.

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

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 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: 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.
 * MultiLanguageManagerTest.php
 * MultiLanguageManager_SkinnTest.php

.......................................

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.

......................................F

Time: 00:00

There was 1 failure:

1) testCreateDetailLanguagePage_scenario1_ndl(MultiLanguageManager_Test) Failed asserting that  is identical to . F:\Projects\MediaWiki\MediaWiki\MultiLanguageManagerTest.php:1182 F:\Projects\MediaWiki\MediaWiki\MultiLanguageManagerTest.php:94 F:\Projects\MediaWiki\MediaWiki\MultiLanguageManagerTest.php:1190

FAILURES! 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
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)

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

Solution
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...