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