e84aa29dbe90cb177ecf5264b9d47f56a28d4ecf
[lhc/web/wiklou.git] / maintenance / language / validate.php
1 <?php
2 /**
3 * @file
4 * @ingroup MaintenanceLanguage
5 */
6
7 if ( !isset( $argv[1] ) ) {
8 print "Usage: php {$argv[0]} <filename>\n";
9 exit( 1 );
10 }
11 array_shift( $argv );
12
13 define( 'MEDIAWIKI', 1 );
14 define( 'NOT_REALLY_MEDIAWIKI', 1 );
15
16 $IP = dirname( __FILE__ ) . '/../..';
17
18 require_once( "$IP/includes/Defines.php" );
19 require_once( "$IP/languages/Language.php" );
20
21 $files = array();
22 foreach ( $argv as $arg ) {
23 $files = array_merge( $files, glob( $arg ) );
24 }
25
26 foreach ( $files as $filename ) {
27 print "$filename...";
28 $vars = getVars( $filename );
29 $keys = array_keys( $vars );
30 $diff = array_diff( $keys, Language::$mLocalisationKeys );
31 if ( $diff ) {
32 print "\nWarning: unrecognised variable(s): " . implode( ', ', $diff ) ."\n";
33 } else {
34 print " ok\n";
35 }
36 }
37
38 function getVars( $filename ) {
39 require( $filename );
40 $vars = get_defined_vars();
41 unset( $vars['filename'] );
42 return $vars;
43 }
44