r21204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21203‎ | r21204 | r21205 >
Date:21:24, 12 April 2007
Author:hashar
Status:old
Tags:
Comment:
* add an optional --mylang parameter to restrict checks on a given language.
* lame documentation
Modified paths:
  • /trunk/phase3/maintenance/language/checkExtensioni18n.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/checkExtensioni18n.php
@@ -40,7 +40,7 @@
4141 $wgDisplayLevel = 2;
4242 $wgChecks = array( 'untranslated', 'obsolete', 'variables', 'empty', 'whitespace', 'xhtml', 'chars' );
4343
44 -$optionsWithArgs = array( 'extdir' );
 44+$optionsWithArgs = array( 'extdir', 'mylang' );
4545
4646 require_once( dirname(__FILE__).'/../commandLine.inc' );
4747 require_once( 'languages.inc' );
@@ -130,8 +130,12 @@
131131 }
132132 }
133133
134 -
135 -function checkExtensionLanguage( $filename, $arrayname ) {
 134+/**
 135+ * @param $filename Filename containing the extension i18n
 136+ * @param $arrayname The name of the array in the filename
 137+ * @param $filter Optional, restrict check to a given language code (default; null)
 138+ */
 139+function checkExtensionLanguage( $filename, $arrayname, $filter = null ) {
136140 global $wgGeneralMessages, $wgRequiredMessagesNumber;
137141
138142 $extLanguages = new extensionLanguages($filename, $arrayname);
@@ -146,15 +150,20 @@
147151 return false;
148152 }
149153
150 - print "Found ". count($langs) . " languages : " . implode(' ', $langs) ."\n";
151 - foreach( $langs as $lang ) {
152 - if( $lang == 'en' ) {
153 - #print "Skipped english language\n";
154 - continue;
 154+ if( $filter ) {
 155+ checkLanguage( $extLanguages, $filter );
 156+ } else {
 157+ print "Found ". count($langs) . " languages : " . implode(' ', $langs) ."\n";
 158+ foreach( $langs as $lang ) {
 159+ if( $lang == 'en' ) {
 160+ #print "Skipped english language\n";
 161+ continue;
 162+ }
 163+
 164+ checkLanguage( $extLanguages, $lang );
155165 }
 166+ }
156167
157 - checkLanguage( $extLanguages, $lang );
158 - }
159168 }
160169
161170 function checkExtensionRepository( $extdir, $db ) {
@@ -188,7 +197,8 @@
189198
190199 $i18n_file = $extdir . '/' . $i18n_file ;
191200
192 - checkExtensionLanguage( $i18n_file, $arrayname );
 201+ global $myLang;
 202+ checkExtensionLanguage( $i18n_file, $arrayname, $myLang );
193203
194204 print "\n";
195205 }
@@ -200,14 +210,19 @@
201211 print <<<END
202212 Usage:
203213 php checkExtensioni18n.php <filename> <arrayname>
204 - php checkExtensioni18n.php --extdir <exstention repository>
 214+ php checkExtensioni18n.php --extdir <extension repository>
205215
 216+Common option:
 217+ --mylang <language code> : only check the given language.
206218
 219+
207220 END;
208221 die;
209222 }
210223
211224 // Play with options and arguments
 225+$myLang = $options['mylang'];
 226+
212227 if( isset( $options['extdir'] ) ) {
213228 $extdb = $options['extdir'] . '/' . EXT_I18N_DB ;
214229
@@ -235,7 +250,8 @@
236251 usage();
237252 }
238253
239 - checkExtensionLanguage( $filename, $arrayname );
 254+ global $myLang;
 255+ checkExtensionLanguage( $filename, $arrayname, $myLang );
240256 } else {
241257 usage();
242258 }