00001 <?php
00002
# MediaWiki web-based config/installation
00003
# Copyright (C) 2004 Ashar Voultoiz <thoane@altern.org> and others
00004
# http://www.mediawiki.org/
00005
#
00006
# This program is free software; you can redistribute it and/or modify
00007
# it under the terms of the GNU General Public License as published by
00008
# the Free Software Foundation; either version 2 of the License, or
00009
# (at your option) any later version.
00010
#
00011
# This program is distributed in the hope that it will be useful,
00012
# but WITHOUT ANY WARRANTY; without even the implied warranty of
00013
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014
# GNU General Public License for more details.
00015
#
00016
# You should have received a copy of the GNU General Public License along
00017
# with this program; if not, write to the Free Software Foundation, Inc.,
00018
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019
# http://www.gnu.org/copyleft/gpl.html
00020
00021
00022
# This script is an alpha version.
00023
#
00024
# The goal is to get a list of messages not yet localised in a
00025
# languageXX.php file using the language.php file as reference.
00026
#
00027
# Usage:
00028
# php DiffLanguage.php
00029
#
00030
# Enter the language code following "Language" of the LanguageXX.php
00031
# you want to check. If using linux you might need to follow case aka
00032
# Zh and not zh.
00033
#
00034
# The script then print a list of wgAllMessagesXX keys that aren't
00035
# localised, a percentage of messages correctly localised and the
00036
# number of messages to be translated.
00037
00038 require_once(
"commandLine.inc" );
00039
00040 $wgLanguageCode = strtoupper(substr($wgLanguageCode,0,1)).strtolower(substr($wgLanguageCode,1));
00041
00042
# read command line argument
00043
if ( isset($args[0]) ) {
00044 $lang =
$args[0];
00045
00046
# or prompt a simple menu
00047
}
else {
00048 $loop =
true;
00049
do {
00050 @ob_end_flush();
00051 print
"Enter the language you want to check [$wgLanguageCode]:";
00052 $input =
readconsole();
00053
00054
# set the input to current language
00055
if(
$input ==
"") {
00056
$input =
$wgLanguageCode;
00057 }
00058
00059
# convert to 1st char upper, rest lower case
00060
$input = strtoupper(substr($input,0,1)).strtolower(substr($input,1));
00061
00062
# try to get the file
00063
if( file_exists(
"../languages/Language$input.php") ) {
00064 $loop =
false;
00065 $lang =
$input;
00066 }
else {
00067 print
"ERROR: The file Language$input.php doesn't exist !\n";
00068 }
00069
00070 }
while ($loop);
00071
00072 }
00073
00074
00075
00076
00077
00078
00079
# include the language if it's not the already loaded one
00080
if($lang !=
$wgLanguageCode) {
00081 print
"Including language file for $lang.\n";
00082 include(
"Language{$lang}.php");
00083 }
00084
00085
00086
00087 $foo =
"wgAllMessages$lang";
00088 $testme = &$$foo;
00089
00090
00091
00092
# Get all references messages and check if they exist in the tested language
00093 $i = 0;
00094 print
"\nChecking $lang localisation file against reference (en):\n----\n";
00095 foreach($wgAllMessagesEn as $index => $localized)
00096 {
00097
if(!(isset($testme[$index]))) {
00098
$i++;
00099
00100 echo
"$index\n";
00101 }
00102 }
00103 echo
"----\n";
00104 echo
"$lang language is complete at ".number_format((100 - $i/count($wgAllMessagesEn) * 100),2).
"%\n";
00105 echo
"$i unlocalised message of the ".count($wgAllMessagesEn).
" messages available.\n";