Use Database:aggregateValue() for HAVING and GROUP BY clauses, closes bug387
[lhc/web/wiklou.git] / maintenance / checktrans-enhanced.php
1 <?php
2 /**
3 * Check to see if all messages have been translated into
4 * the selected language. To run this script, you must have
5 * a working installation, and it checks the selected language
6 * of that installation.
7 *
8 * The enhanced version will check more arrays than just
9 * wgAllMessages
10 *
11 * @todo document
12 * @package MediaWiki
13 * @subpackage Maintenance
14 */
15
16 /** */
17 function check($arrayname) {
18 $arraynameprinted = 0;
19
20 global $count, $total, $wgLanguageCode;
21
22 $msgarray = $arrayname . ucfirst( $wgLanguageCode );
23 $msgarrayen = $arrayname . "En";
24
25 global $$msgarray;
26 global $$msgarrayen;
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 print "{$code}\n";
38 ++$count;
39 }
40 }
41 }
42
43 if ( ! is_readable( "../LocalSettings.php" ) ) {
44 print "A copy of your installation's LocalSettings.php\n" .
45 "must exist in the source directory.\n";
46 exit();
47 }
48
49 $DP = "../includes";
50 require_once( "../LocalSettings.php" );
51
52 if ( "en" == $wgLanguageCode ) {
53 print "Current selected language is English. Cannot check translations.\n";
54 exit();
55 }
56 $include = "Language" . ucfirst( $wgLanguageCode ) . ".php";
57 if ( ! is_readable( "{$IP}/{$include}" ) ) {
58 print "Translation file \"{$include}\" not found in installation directory.\n" .
59 "You must have the software installed to run this script.\n";
60 exit();
61 }
62
63 umask( 000 );
64 set_time_limit( 0 );
65
66 require_once( "{$IP}/Setup.php" );
67 $wgTitle = Title::newFromText( "Translation checking script" );
68 $wgCommandLineMode = true;
69
70 $count = $total = 0;
71
72
73 check("wgLanguageNames");
74 check("wgNamespaceNames");
75 check("wgDefaultUserOptions");
76 check("wgQuickbarSettings");
77 check("wgSkinNames");
78 check("wgMathNames");
79 check("wgUserToggles");
80 check("wgWeekdayNames");
81 check("wgMonthNames");
82 check("wgMonthAbbreviations");
83 check("wgValidSpecialPages");
84 check("wgSysopSpecialPages");
85 check("wgDeveloperSpecialPages");
86 check("wgAllMessages");
87
88 print "{$count} messages of {$total} not translated.\n";