From 35c0a5bf35229a8ef236e59d812cbb51b34a91ab Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Thu, 12 Apr 2007 21:24:09 +0000 Subject: [PATCH] * add an optional --mylang parameter to restrict checks on a given language. * lame documentation --- maintenance/language/checkExtensioni18n.php | 42 ++++++++++++++------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/maintenance/language/checkExtensioni18n.php b/maintenance/language/checkExtensioni18n.php index dd5ed521bb..9f57498645 100644 --- a/maintenance/language/checkExtensioni18n.php +++ b/maintenance/language/checkExtensioni18n.php @@ -40,7 +40,7 @@ define( 'EXT_I18N_DB', 'i18n.db' ); $wgDisplayLevel = 2; $wgChecks = array( 'untranslated', 'obsolete', 'variables', 'empty', 'whitespace', 'xhtml', 'chars' ); -$optionsWithArgs = array( 'extdir' ); +$optionsWithArgs = array( 'extdir', 'mylang' ); require_once( dirname(__FILE__).'/../commandLine.inc' ); require_once( 'languages.inc' ); @@ -130,8 +130,12 @@ class extensionLanguages extends languages { } } - -function checkExtensionLanguage( $filename, $arrayname ) { +/** + * @param $filename Filename containing the extension i18n + * @param $arrayname The name of the array in the filename + * @param $filter Optional, restrict check to a given language code (default; null) + */ +function checkExtensionLanguage( $filename, $arrayname, $filter = null ) { global $wgGeneralMessages, $wgRequiredMessagesNumber; $extLanguages = new extensionLanguages($filename, $arrayname); @@ -146,15 +150,20 @@ function checkExtensionLanguage( $filename, $arrayname ) { return false; } - print "Found ". count($langs) . " languages : " . implode(' ', $langs) ."\n"; - foreach( $langs as $lang ) { - if( $lang == 'en' ) { - #print "Skipped english language\n"; - continue; - } + if( $filter ) { + checkLanguage( $extLanguages, $filter ); + } else { + print "Found ". count($langs) . " languages : " . implode(' ', $langs) ."\n"; + foreach( $langs as $lang ) { + if( $lang == 'en' ) { + #print "Skipped english language\n"; + continue; + } - checkLanguage( $extLanguages, $lang ); + checkLanguage( $extLanguages, $lang ); + } } + } function checkExtensionRepository( $extdir, $db ) { @@ -188,7 +197,8 @@ function checkExtensionRepository( $extdir, $db ) { $i18n_file = $extdir . '/' . $i18n_file ; - checkExtensionLanguage( $i18n_file, $arrayname ); + global $myLang; + checkExtensionLanguage( $i18n_file, $arrayname, $myLang ); print "\n"; } @@ -200,7 +210,10 @@ function usage() { print << - php checkExtensioni18n.php --extdir + php checkExtensioni18n.php --extdir + +Common option: + --mylang : only check the given language. END; @@ -208,6 +221,8 @@ die; } // Play with options and arguments +$myLang = $options['mylang']; + if( isset( $options['extdir'] ) ) { $extdb = $options['extdir'] . '/' . EXT_I18N_DB ; @@ -235,7 +250,8 @@ if( isset( $options['extdir'] ) ) { usage(); } - checkExtensionLanguage( $filename, $arrayname ); + global $myLang; + checkExtensionLanguage( $filename, $arrayname, $myLang ); } else { usage(); } -- 2.20.1