00001 <?php 00002 00003 # Checks translation of all language files 00004 00005 function wfLocalUrl() { return "";} 00006 function wfLocalUrle() { return "";} 00007 00008 function check($arrayname, $lang, $text) 00009 { 00010 $arraynameprinted = 0; 00011 00012 global $count, $total; 00013 00014 $msgarray = $arrayname . ucfirst( $lang ); 00015 $msgarrayen = $arrayname . "En"; 00016 00017 eval( $text ); 00018 if ( !is_array( $$msgarrayen ) ) { 00019 print "\nArray '$msgarrayen' not present\n"; 00020 return; 00021 } elseif ( !is_array( $$msgarray ) ) { 00022 print "\nArray '$msgarray' not present\n"; 00023 return; 00024 } 00025 00026 foreach ( $$msgarrayen as $code => $msg ) { 00027 ++$total; 00028 00029 if ( ! array_key_exists( $code, $$msgarray ) ) { 00030 if (!$arraynameprinted) { 00031 print("\nIn array '$msgarray':\n"); 00032 $arraynameprinted = 1; 00033 } 00034 00035 if ( is_numeric( $code ) ) { 00036 print "$code ($msg)\n"; 00037 } else { 00038 print "{$code}\n"; 00039 } 00040 ++$count; 00041 } 00042 } 00043 } 00044 00045 function getLanguage( $lang ) 00046 { 00047 $fileName = "../languages/Language" . ucfirst( $lang ) . ".php"; 00048 $file = fopen( $fileName, "r" ); 00049 $text = fread( $file, filesize( $fileName ) ); 00050 $clipPos = strpos( $text, "class Language" ); 00051 $text = substr( $text, 0, $clipPos ); 00052 $text = preg_replace( "/^<\?(php|)/", "", $text ); 00053 $text = preg_replace( "/^include.*$/m", "", $text ); 00054 00055 return $text; 00056 } 00057 00058 function checkLanguage( $lang, $enText ) 00059 { 00060 $text = $enText . getLanguage( $lang ); 00061 check("wgLanguageNames", $lang, $text); 00062 check("wgNamespaceNames", $lang, $text); 00063 check("wgDefaultUserOptions", $lang, $text); 00064 check("wgQuickbarSettings", $lang, $text); 00065 check("wgSkinNames", $lang, $text); 00066 check("wgMathNames", $lang, $text); 00067 check("wgUserToggles", $lang, $text); 00068 check("wgWeekdayNames", $lang, $text); 00069 check("wgMonthNames", $lang, $text); 00070 check("wgMonthAbbreviations", $lang, $text); 00071 check("wgValidSpecialPages", $lang, $text); 00072 check("wgSysopSpecialPages", $lang, $text); 00073 check("wgDeveloperSpecialPages", $lang, $text); 00074 check("wgAllMessages", $lang, $text); 00075 check("wgMagicWords", $lang, $text); 00076 } 00077 00078 if ( $argc > 1 ) { 00079 array_shift( $argv ); 00080 $glob = implode( " ", $argv ); 00081 } else { 00082 $glob = "../languages/Language?*.php"; 00083 } 00084 00085 umask( 000 ); 00086 set_time_limit( 0 ); 00087 $count = $total = 0; 00088 $enText = getLanguage( "" ); 00089 $filenames = glob( $glob ); 00090 $width = 80; 00091 foreach ( $filenames as $filename ) { 00092 if ( preg_match( "/languages\/Language(.*)\.php/", $filename, $m ) ) { 00093 $lang = strtolower( $m[1] ); 00094 if ( $lang != "utf8" ) { 00095 print "\n" . str_repeat( "-", $width ); 00096 print "\n$lang\n"; 00097 print str_repeat( "-", $width ) . "\n"; 00098 checkLanguage( $lang, $enText ); 00099 } 00100 } 00101 } 00102 00103 print "\n" . str_repeat( "-", $width ) . "\n"; 00104 print "{$count} messages of {$total} not translated.\n"; 00105