MediaWiki  REL1_22
countMessages.php
Go to the documentation of this file.
00001 <?php
00024 require_once __DIR__ . '/../Maintenance.php';
00025 
00032 class CountMessages extends Maintenance {
00033     public function __construct() {
00034         parent::__construct();
00035         $this->mDescription = "Count how many messages we have defined for each language";
00036     }
00037 
00038     public function execute() {
00039         global $IP;
00040         $dir = $this->getArg( 0, "$IP/languages/messages" );
00041         $total = 0;
00042         $nonZero = 0;
00043         foreach ( glob( "$dir/*.php" ) as $file ) {
00044             $baseName = basename( $file );
00045             if ( !preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $baseName, $m ) ) {
00046                 continue;
00047             }
00048 
00049             $numMessages = $this->getNumMessages( $file );
00050             // print "$code: $numMessages\n";
00051             $total += $numMessages;
00052             if ( $numMessages > 0 ) {
00053                 $nonZero ++;
00054             }
00055         }
00056         $this->output( "\nTotal: $total\n" );
00057         $this->output( "Languages: $nonZero\n" );
00058     }
00059 
00060     private function getNumMessages( $file ) {
00061         // Separate function to limit scope
00062         require $file;
00063         if ( isset( $messages ) ) {
00064             return count( $messages );
00065         } else {
00066             return 0;
00067         }
00068     }
00069 }
00070 
00071 $maintClass = "CountMessages";
00072 require_once RUN_MAINTENANCE_IF_MAIN;