r47029 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47028‎ | r47029 | r47030 >
Date:09:37, 9 February 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Simple proof-of-principle script to generate a CDB file from the currently loaded extensions
Modified paths:
  • /trunk/phase3/maintenance/language/makeMessageDB.php (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/makeMessageDB.php
@@ -0,0 +1,45 @@
 2+<?php
 3+
 4+/**
 5+ * Proof of principle script
 6+ */
 7+
 8+require( dirname( __FILE__ ) . '/../commandLine.inc' );
 9+
 10+$obj = new MakeMessagesDB;
 11+$obj->run();
 12+
 13+class MakeMessagesDB {
 14+
 15+ function run() {
 16+ global $wgExtensionMessagesFiles, $wgMessageCache, $IP;
 17+
 18+ $nameHash = md5( implode( "\n", array_keys( $wgExtensionMessagesFiles ) ) );
 19+ $dir = "$IP/cache/ext-msgs";
 20+ wfMkdirParents( $dir );
 21+ $db = dba_open( "$dir/$nameHash.cdb", 'n', 'cdb' );
 22+ if ( !$db ) {
 23+ echo "Cannot open DB file\n";
 24+ exit( 1 );
 25+ }
 26+
 27+ # Load extension messages
 28+ foreach ( $wgExtensionMessagesFiles as $file ) {
 29+ $messages = $magicWords = array();
 30+ require( $file );
 31+ foreach ( $messages as $lang => $unused ) {
 32+ $wgMessageCache->processMessagesArray( $messages, $lang );
 33+ }
 34+ }
 35+
 36+ # Write them to the file
 37+ foreach ( $wgMessageCache->mExtensionMessages as $lang => $messages ) {
 38+ foreach ( $messages as $key => $text ) {
 39+ dba_insert( "$lang:$key", $text, $db );
 40+ }
 41+ }
 42+
 43+ dba_close( $db );
 44+ }
 45+}
 46+
Property changes on: trunk/phase3/maintenance/language/makeMessageDB.php
___________________________________________________________________
Name: svn:eol-style
147 + native

Status & tagging log