79989bd24fc8bc83d09a36ab88f98ce5054a8eda
[lhc/web/wiklou.git] / maintenance / checktrans2.php
1 <?php
2
3 die("This script is not being maintained.");
4
5 # Checks translation of all language files
6
7 function wfLocalUrl() { return "";}
8 function wfLocalUrle() { return "";}
9
10 function check($arrayname, $lang, $text)
11 {
12 $arraynameprinted = 0;
13
14 global $count, $total;
15
16 $msgarray = $arrayname . ucfirst( $lang );
17 $msgarrayen = $arrayname . "En";
18
19 eval( $text );
20 if ( !is_array( $$msgarrayen ) ) {
21 print "\nArray '$msgarrayen' not present\n";
22 return;
23 } elseif ( !is_array( $$msgarray ) ) {
24 print "\nArray '$msgarray' not present\n";
25 return;
26 }
27
28 foreach ( $$msgarrayen as $code => $msg ) {
29 ++$total;
30
31 if ( ! array_key_exists( $code, $$msgarray ) ) {
32 if (!$arraynameprinted) {
33 print("\nIn array '$msgarray':\n");
34 $arraynameprinted = 1;
35 }
36
37 if ( is_numeric( $code ) ) {
38 print "$code ($msg)\n";
39 } else {
40 print "{$code}\n";
41 }
42 ++$count;
43 }
44 }
45 }
46
47 function getLanguage( $lang )
48 {
49 $fileName = "../languages/Language" . ucfirst( $lang ) . ".php";
50 $file = fopen( $fileName, "r" );
51 $text = fread( $file, filesize( $fileName ) );
52 $clipPos = strpos( $text, "class Language" );
53 $text = substr( $text, 0, $clipPos );
54 $text = preg_replace( "/^<\?(php|)/", "", $text );
55 $text = preg_replace( "/^include.*$/m", "", $text );
56
57 return $text;
58 }
59
60 function checkLanguage( $lang, $enText )
61 {
62 $text = $enText . getLanguage( $lang );
63 check("wgLanguageNames", $lang, $text);
64 check("wgNamespaceNames", $lang, $text);
65 check("wgDefaultUserOptions", $lang, $text);
66 check("wgQuickbarSettings", $lang, $text);
67 check("wgSkinNames", $lang, $text);
68 check("wgMathNames", $lang, $text);
69 check("wgUserToggles", $lang, $text);
70 check("wgWeekdayNames", $lang, $text);
71 check("wgMonthNames", $lang, $text);
72 check("wgMonthAbbreviations", $lang, $text);
73 check("wgValidSpecialPages", $lang, $text);
74 check("wgSysopSpecialPages", $lang, $text);
75 check("wgDeveloperSpecialPages", $lang, $text);
76 check("wgAllMessages", $lang, $text);
77 check("wgMagicWords", $lang, $text);
78 }
79
80 if ( $argc > 1 ) {
81 array_shift( $argv );
82 $glob = implode( " ", $argv );
83 } else {
84 $glob = "../languages/Language?*.php";
85 }
86
87 umask( 000 );
88 set_time_limit( 0 );
89 $count = $total = 0;
90 $enText = getLanguage( "" );
91 $filenames = glob( $glob );
92 $width = 80;
93 foreach ( $filenames as $filename ) {
94 if ( preg_match( "/languages\/Language(.*)\.php/", $filename, $m ) ) {
95 $lang = strtolower( $m[1] );
96 if ( $lang != "utf8" ) {
97 print "\n" . str_repeat( "-", $width );
98 print "\n$lang\n";
99 print str_repeat( "-", $width ) . "\n";
100 checkLanguage( $lang, $enText );
101 }
102 }
103 }
104
105 print "\n" . str_repeat( "-", $width ) . "\n";
106 print "{$count} messages of {$total} not translated.\n";
107