2 # MediaWiki web-based config/installation
3 # Copyright (C) 2004 Ashar Voultoiz <thoane@altern.org> and others
4 # http://www.mediawiki.org/
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 # http://www.gnu.org/copyleft/gpl.html
22 * The goal is to get a list of messages not yet localised in a
23 * languageXX.php file using the language.php file as reference.
26 * php DiffLanguage.php
28 * Enter the language code following "Language" of the LanguageXX.php
29 * you want to check. If using linux you might need to follow case aka
32 * The script then print a list of wgAllMessagesXX keys that aren't
33 * localised, a percentage of messages correctly localised and the
34 * number of messages to be translated.
36 * @subpackage Maintenance
39 /** This script run from the commandline */
40 require_once( "commandLine.inc" );
42 $wgLanguageCode = strtoupper(substr($wgLanguageCode,0,1)).strtolower(substr($wgLanguageCode,1));
44 # read command line argument
45 if ( isset($args[0]) ) {
48 # or prompt a simple menu
53 print "Enter the language you want to check [$wgLanguageCode]:";
54 $input = readconsole();
56 # set the input to current language
58 $input = $wgLanguageCode;
61 # convert to 1st char upper, rest lower case
62 $input = strtoupper(substr($input,0,1)).strtolower(substr($input,1));
65 if( file_exists("$IP/languages/Language$input.php") ) {
69 print "ERROR: The file Language$input.php doesn't exist !\n";
77 Need to check case of the $lang : 1st char upper 2nd char lower
81 # include the language if it's not the already loaded one
82 if($lang != $wgLanguageCode) {
83 print "Including language file for $lang.\n";
84 include_once("Language{$lang}.php");
87 /* ugly hack to load the correct array, if you have a better way
88 to achieve the same goal, recode it ! */
89 $foo = "wgAllMessages$lang";
91 /* end of ugly hack */
94 # Get all references messages and check if they exist in the tested language
96 print "\nChecking $lang localisation file against reference (en):\n----\n";
97 foreach($wgAllMessagesEn as $index => $localized)
99 if(!(isset($testme[$index]))) {
106 echo "$lang language is complete at ".number_format((100 - $i/count($wgAllMessagesEn) * 100),2)."%\n";
107 echo "$i unlocalised messages of the ".count($wgAllMessagesEn)." messages available.\n";