3 * Merge $wgExtensionMessagesFiles from various extensions to produce a
4 * single array containing all message files.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
22 * @ingroup Maintenance
26 define( 'MW_NO_EXTENSION_MESSAGES', 1 );
28 require_once( dirname( __FILE__
) . '/Maintenance.php' );
29 $maintClass = 'MergeMessageFileList';
31 class MergeMessageFileList
extends Maintenance
{
33 function __construct() {
34 parent
::__construct();
35 $this->addOption( 'list-file', 'A file containing a list of extension setup files, one per line.', true, true );
36 $this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true );
37 $this->mDescription
= 'Merge $wgExtensionMessagesFiles from various extensions to produce a ' .
38 'single array containing all message files.';
41 public function execute() {
44 $lines = file( $this->getOption( 'list-file' ) );
45 if ( $lines === false ) {
46 $this->error( 'Unable to open list file.' );
48 $mmfl = array( 'setupFiles' => array_map( 'trim', $lines ) );
49 if ( $this->hasOption( 'output' ) ) {
50 $mmfl['output'] = $this->getOption( 'output' );
55 require_once( RUN_MAINTENANCE_IF_MAIN
);
57 foreach ( $mmfl['setupFiles'] as $fileName ) {
58 if ( strval( $fileName ) === '' ) {
61 $fileName = str_replace( '$IP', $IP, $fileName );
62 fwrite( STDERR
, "Loading data from $fileName\n" );
63 include_once( $fileName );
65 fwrite( STDERR
, "\n" );
68 "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" .
69 "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" .
70 '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n";
74 dirname( dirname( __FILE__
) ),
78 foreach ( $dirs as $dir ) {
80 "/'" . preg_quote( $dir, '/' ) . "([^']*)'/",
85 if ( isset( $mmfl['output'] ) ) {
86 file_put_contents( $mmfl['output'], $s );