r72269 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72268‎ | r72269 | r72270 >
Date:07:44, 3 September 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
New useful script for listing only the i18n files
Modified paths:
  • /trunk/extensions/Translate/scripts/list-mwext-i18n-files.php (added) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/list-mwext-i18n-files.php
@@ -0,0 +1,66 @@
 2+<?php
 3+/**
 4+ * Script which lists required i18n files for mediawiki extensions.
 5+ * Can be used to crate smaller and faster checkouts.
 6+ *
 7+ * @author Niklas Laxstrom
 8+ *
 9+ * @copyright Copyright © 2010, Niklas Laxström
 10+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 11+ * @file
 12+ */
 13+
 14+// Standard boilerplate to define $IP
 15+if ( getenv( 'MW_INSTALL_PATH' ) !== false ) {
 16+ $IP = getenv( 'MW_INSTALL_PATH' );
 17+} else {
 18+ $dir = dirname( __FILE__ ); $IP = "$dir/../../..";
 19+}
 20+require_once( "$IP/maintenance/Maintenance.php" );
 21+
 22+class MWExtFileList extends Maintenance {
 23+ public function __construct() {
 24+ parent::__construct();
 25+ $this->mDescription = 'Script which lists required i18n files for mediawiki extensions';
 26+ $this->addOption( 'path', 'List only files for given group path. Must match the path attribute of groups.', false, 'witharg' );
 27+ $this->addOption( 'target', 'List only files missing from target. Defaults to path.', false, 'witharg' );
 28+ }
 29+
 30+ public function execute() {
 31+ $this->files = array();
 32+ $groups = MessageGroups::singleton()->getGroups();
 33+ $target = $this->getOption( 'path' );
 34+ foreach ( $groups as $group ) {
 35+ if ( !$group instanceof ExtensionMessageGroup ) continue;
 36+ if ( $target && $group->getPath() !== $target ) continue;
 37+ $this->addPaths( $group->getMessageFile('en') );
 38+ $this->addPaths( $group->getAliasFile('en') );
 39+ $this->addPaths( $group->getMagicFile('en') );
 40+ }
 41+
 42+ $files = array_keys( $this->files );
 43+ $this->output( implode( "\n", $files ) . "\n" );
 44+ }
 45+
 46+ public function addPaths( $file ) {
 47+ if ( $file === '' ) return;
 48+
 49+ $target = $this->getOption( 'target', $this->getOption( 'path' ) );
 50+
 51+ $paths = array();
 52+ do {
 53+ if ( file_exists( "$target/$file" ) ) break;
 54+ $paths[] = $file;
 55+ $file = dirname( $file );
 56+ } while ( $file !== '.' && $file !== '' );
 57+
 58+ // Directories first
 59+ $paths = array_reverse( $paths );
 60+ foreach ( $paths as $path ) {
 61+ $this->files[$path] = true;
 62+ }
 63+ }
 64+}
 65+
 66+$maintClass = 'MWExtFileList';
 67+require_once( DO_MAINTENANCE );
Property changes on: trunk/extensions/Translate/scripts/list-mwext-i18n-files.php
___________________________________________________________________
Added: svn:eol-style
168 + native

Status & tagging log