Extension:MultiLanguageManager

What can this extension do?
With this extension, you can to 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

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 table : 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!

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 :

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

Configuration
You can configure the extension using the “MultiLaguageManager_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 internationalization file.

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:

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 succesful 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 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: 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)