r38762 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38761‎ | r38762 | r38763 >
Date:10:14, 7 August 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Fixes and improvements to scripts
Modified paths:
  • /trunk/extensions/Translate/scripts/alias-export.php (modified) (history)
  • /trunk/extensions/Translate/scripts/cli.inc (modified) (history)
  • /trunk/extensions/Translate/scripts/export.php (modified) (history)
  • /trunk/extensions/Translate/scripts/fuzzy.php (modified) (history)
  • /trunk/extensions/Translate/scripts/poimport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/cli.inc
@@ -40,4 +40,18 @@
4141 STDOUT( $message, $channel, true );
4242 }
4343
44 -register_shutdown_function('STDOUT', false);
\ No newline at end of file
 44+register_shutdown_function('STDOUT', false);
 45+
 46+
 47+class Cli {
 48+
 49+ public static function parseLanguageCodes( /* string */ $codes ) {
 50+ $langs = array_map( 'trim', explode( ',', $codes ) );
 51+ if ( $langs[0] === '*' ) {
 52+ $languages = Language::getLanguageNames();
 53+ ksort($languages);
 54+ $langs = array_keys($languages);
 55+ }
 56+ return $langs;
 57+ }
 58+}
\ No newline at end of file
Index: trunk/extensions/Translate/scripts/poimport.php
@@ -221,14 +221,14 @@
222222 global $wgTitle, $wgArticle;
223223 $wgTitle = Title::makeTitleSafe( $namespace, $title );
224224
225 - STDOUT( "Updating {$wgTitle->getPrefixedText()}... ", true );
 225+ STDOUT( "Updating {$wgTitle->getPrefixedText()}... ", $title );
226226 if ( !$wgTitle instanceof Title ) {
227 - STDOUT( "INVALID TITLE!", false );
 227+ STDOUT( "INVALID TITLE!", $title );
228228 return;
229229 }
230230
231231 if ( $this->dryrun ) {
232 - STDOUT( "DRY RUN!", false );
 232+ STDOUT( "DRY RUN!", $title );
233233 return;
234234 }
235235
@@ -237,9 +237,9 @@
238238 $success = $wgArticle->doEdit( $text, 'Updating translation from gettext import' );
239239
240240 if ( $success ) {
241 - STDOUT( "OK!", false );
 241+ STDOUT( "OK!", $title );
242242 } else {
243 - STDOUT( "Failed!", false );
 243+ STDOUT( "Failed!", $title );
244244 }
245245 }
246246 }
Index: trunk/extensions/Translate/scripts/export.php
@@ -20,7 +20,7 @@
2121
2222 Options:
2323 --target Target directory for exported files
24 - --lang Comma separated list of language codes
 24+ --lang Comma separated list of language codes or *
2525 --group Group id
2626 EOT
2727 );
@@ -48,9 +48,8 @@
4949 exit(1);
5050 }
5151
52 -$langs = array_map( 'trim', explode( ',', $options['lang'] ) );
 52+$langs = Cli::parseLanguageCodes( $options['langs'] );
5353
54 -
5554 $group = MessageGroups::getGroup( $options['group'] );
5655
5756 if ( !$group instanceof MessageGroup ) {
Index: trunk/extensions/Translate/scripts/fuzzy.php
@@ -64,7 +64,7 @@
6565
6666 $wgUser = User::newFromName( $wgTranslateFuzzyBotName );
6767
68 - if ( $wgUser->isAnon() ) {
 68+ if ( !$wgUser->isLoggedIn() ) {
6969 STDOUT( "Creating user $wgTranslateFuzzyBotName" );
7070 $wgUser->addToDatabase();
7171 }
Index: trunk/extensions/Translate/scripts/alias-export.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Script to export translations of one message group to file(s).
 4+ * Script to export special page aliases of extensions.
55 *
66 * @author Niklas Laxstrom
77 *
@@ -9,7 +9,7 @@
1010 * @file
1111 */
1212
13 -$optionsWithArgs = array( 'lang', 'target', 'group' );
 13+$optionsWithArgs = array( 'lang', 'target' );
1414 require( dirname(__FILE__) . '/cli.inc' );
1515
1616 function showUsage() {
@@ -20,8 +20,7 @@
2121
2222 Options:
2323 --target Target directory for exported files
24 - --lang Comma separated list of language codes
25 - --group Group id
 24+ --lang Comma separated list of language codes or *
2625 EOT
2726 );
2827 exit( 1 );
@@ -45,7 +44,7 @@
4645 exit(1);
4746 }
4847
49 -$langs = array_map( 'trim', explode( ',', $options['lang'] ) );
 48+$langs = Cli::parseLanguageCodes( $options['lang'] );
5049
5150
5251 if ( !file_exists(TRANSLATE_ALIASFILE) || !is_readable(TRANSLATE_ALIASFILE) ) {

Status & tagging log