summaryrefslogtreecommitdiff
path: root/maintenance/rebuildMessages.php
blob: d009098ddec25af655ab159bf444305bfb4f2eae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
 * @todo document
 * @package MediaWiki
 * @subpackage Maintenance
 */

/** */
$options = array( 'update' => null, 'rebuild' => null );
require_once( "commandLine.inc" );
include_once( "InitialiseMessages.inc" );

$wgTitle = Title::newFromText( "Rebuild messages script" );

if ( isset( $args[0] ) ) {
	# Retain script compatibility
	$response = array_shift( $args );
	if ( $response == "update" ) {
		$response = 1;
	} elseif ( $response == "rebuild" ) {
		$response = 2;
	}
} else {
	$response = 0;
}
if ( isset( $args[0] ) ) {
	$messages = loadLanguageFile( array_shift( $args ) );
} else {
	$messages = false;
}
if( isset( $options['update'] ) ) $response = 1;
if( isset( $options['rebuild'] ) ) $response = 2;

if ( $response == 0 ) {
	$dbr =& wfGetDB( DB_SLAVE );
	$row = $dbr->selectRow( "page", array("count(*) as c"), array("page_namespace" => NS_MEDIAWIKI) );
	print "Current namespace size: {$row->c}\n";

	print <<<END
Usage:   php rebuildMessages.php <action> [filename]

Action must be one of:
  --update   Update messages to include latest additions to MessagesXX.php
  --rebuild  Delete all messages and reinitialise namespace

If a message dump file is given, messages will be read from it to supplement
the defaults in MediaWiki's Language*.php. The file should contain a serialized
PHP associative array, as produced by dumpMessages.php.


END;
	exit(0);
}

switch ( $response ) {
	case 1:
		initialiseMessages( false, $messages );
		break;
	case 2:
		initialiseMessages( true, $messages );
		break;
}

exit();

?>