MediaWiki  1.23.2
countMessages.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/../Maintenance.php';
25 
32 class CountMessages extends Maintenance {
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "Count how many messages we have defined for each language";
36  }
37 
38  public function execute() {
39  global $IP;
40  $dir = $this->getArg( 0, "$IP/languages/messages" );
41  $total = 0;
42  $nonZero = 0;
43  foreach ( glob( "$dir/*.php" ) as $file ) {
44  $baseName = basename( $file );
45  if ( !preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $baseName, $m ) ) {
46  continue;
47  }
48 
49  $numMessages = $this->getNumMessages( $file );
50  // print "$code: $numMessages\n";
51  $total += $numMessages;
52  if ( $numMessages > 0 ) {
53  $nonZero++;
54  }
55  }
56  $this->output( "\nTotal: $total\n" );
57  $this->output( "Languages: $nonZero\n" );
58  }
59 
60  private function getNumMessages( $file ) {
61  // Separate function to limit scope
62  require $file;
63  if ( isset( $messages ) ) {
64  return count( $messages );
65  } else {
66  return 0;
67  }
68  }
69 }
70 
71 $maintClass = "CountMessages";
72 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
$maintClass
$maintClass
Definition: countMessages.php:71
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$messages
$messages
Definition: LogTests.i18n.php:8
CountMessages\__construct
__construct()
Default constructor.
Definition: countMessages.php:33
$total
$total
Definition: Utf8Test.php:92
CountMessages\execute
execute()
Do the actual work.
Definition: countMessages.php:38
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
CountMessages
Maintenance script that counts how many messages we have defined for each language.
Definition: countMessages.php:32
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
$dir
if(count( $args)==0) $dir
Definition: importImages.php:49
CountMessages\getNumMessages
getNumMessages( $file)
Definition: countMessages.php:60
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
Maintenance\getArg
getArg( $argId=0, $default=null)
Get an argument.
Definition: Maintenance.php:246
$IP
$IP
Definition: WebStart.php:88