blob: f853b395d83582b13248fb1023aa2725410ce15d (
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
|
<?php
/**
* Proof of principle script
*/
require( dirname( __FILE__ ) . '/../commandLine.inc' );
$obj = new MakeMessagesDB;
$obj->run();
class MakeMessagesDB {
function run() {
global $wgExtensionMessagesFiles, $wgMessageCache, $IP;
$nameHash = md5( implode( "\n", array_keys( $wgExtensionMessagesFiles ) ) );
$dir = "$IP/cache/ext-msgs";
wfMkdirParents( $dir );
$db = dba_open( "$dir/$nameHash.cdb", 'n', 'cdb' );
if ( !$db ) {
echo "Cannot open DB file\n";
exit( 1 );
}
# Load extension messages
foreach ( $wgExtensionMessagesFiles as $file ) {
$messages = $magicWords = array();
require( $file );
foreach ( $messages as $lang => $unused ) {
$wgMessageCache->processMessagesArray( $messages, $lang );
}
}
# Write them to the file
foreach ( $wgMessageCache->mExtensionMessages as $lang => $messages ) {
foreach ( $messages as $key => $text ) {
dba_insert( "$lang:$key", $text, $db );
}
}
dba_close( $db );
}
}
|