Extension:MultiLanguageManager
From MediaWiki.org
|
MultiLanguageManager Release status: stable |
|
|---|---|
| Implementation | Database, Locale |
| Description | Add multi-languages capacities to a wiki |
| Author(s) | Marc Despland |
| Version | 1.0.1 (2007-11-11) |
| MediaWiki | 1.6.10+ |
| Download | MultiLanguageManager_1.0.1.tgz original documentation ChangeLog |
| Added rights | language |
| Example | http://www.art122-5.net/ |
Contents |
[edit] 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.
[edit] Usage
The extension was designed to be as simple to use as possible.
[edit] 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
[edit] 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.
[edit] 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
[edit] 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.
[edit] 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
[edit] Database
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) ) 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 prefix “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 needing it!
[edit] 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 :
<?php $languageController=new MultiLanguageManager_controller(); $myTitle=Title::newFromId($this->data['articleid']); echo $languageController->displaySelectLanguage($myTitle); ?>
Need an example of where this can be added. Please edit this page to provide one and remove this message. Thanks!
You also have to change your CSS files, cf Customize the CSS.
[edit] Changes to LocalSettings.php
require_once("$IP/extensions/MultiLanguageManager/MultiLanguageManager.php");
[edit] Configuration
You can configure the extension using the “MultiLaguageManager_setup.php” file , there are other elements that you can configure : CF Customization.
[edit] 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.
$mgAvailableLanguage=array( 'en' => 'multilanguagemanager_en', 'fr' => 'multilanguagemanager_fr');
[edit] 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:
$mgLanguagePermisionsKey='edit';
But you could also choose an other rights : langage :
$mgLanguagePermisionsKey='langage';
Then think of set the rights according to the groups:
$wgGroupPermissions['*'][$mgLanguagePermisionsKey] = false; $wgGroupPermissions['user'][$mgLanguagePermisionsKey] = true; $wgGroupPermissions['sysop'][$mgLanguagePermisionsKey] = true;
[edit] 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
[edit] 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.
[edit] 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
[edit] 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. ......................................F Time: 00:00 There was 1 failure: 1) testCreateDetailLanguagePage_scenario1_ndl(MultiLanguageManager_Test) Failed asserting that <boolean:false> is identical to <boolean:true>. 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
[edit] 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)
[edit] Bugs
[edit] Problem
Articles can not be deleted with this extension because there is a Bug in MultiLanguageManager.php. Corrected with 1.0.1
[edit] 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

