Index: trunk/phase3/maintenance/language/dumpMessages.php |
— | — | @@ -1,18 +1,44 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * @todo document |
5 | | - * @file |
| 4 | + * Dump an entire language, using the keys from English |
| 5 | + * so we get all the values, not just the customized ones |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation; either version 2 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License along |
| 18 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | + * http://www.gnu.org/copyleft/gpl.html |
| 21 | + * |
6 | 22 | * @ingroup MaintenanceLanguage |
| 23 | + * @todo Make this more useful, right now just dumps $wgContentLang |
7 | 24 | */ |
8 | 25 | |
9 | | -/** */ |
10 | | -require_once( dirname(__FILE__).'/../commandLine.inc' ); |
11 | | -$messages = array(); |
12 | | -$wgEnglishMessages = array_keys( Language::getMessagesFor( 'en' ) ); |
13 | | -foreach ( $wgEnglishMessages as $key ) { |
14 | | - $messages[$key] = wfMsg( $key ); |
| 26 | +require_once( dirname(__FILE__) . '/../Maintenance.php' ); |
| 27 | + |
| 28 | +class DumpMessages extends Maintenance { |
| 29 | + public function __construct() { |
| 30 | + parent::__construct(); |
| 31 | + $this->mDescription = "Dump an entire language, using the keys from English"; |
| 32 | + } |
| 33 | + |
| 34 | + public function execute() { |
| 35 | + $messages = array(); |
| 36 | + foreach ( array_keys( Language::getMessagesFor( 'en' ) ) as $key ) { |
| 37 | + $messages[$key] = wfMsg( $key ); |
| 38 | + } |
| 39 | + $this->output( "MediaWiki $wgVersion language file\n" ); |
| 40 | + $this->output( serialize( $messages ) ); |
| 41 | + } |
15 | 42 | } |
16 | | -print "MediaWiki $wgVersion language file\n"; |
17 | | -print serialize( $messages ); |
18 | 43 | |
19 | | - |
| 44 | +$maintClass = "DumpMessages"; |
| 45 | +require_once( DO_MAINTENANCE ); |
Index: trunk/phase3/maintenance/language/countMessages.php |
— | — | @@ -1,40 +1,65 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Count how many messages we have defined for each language. |
| 5 | + * |
| 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. |
| 10 | + * |
| 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. |
| 15 | + * |
| 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 |
| 20 | + * |
| 21 | + * @ingroup MaintenanceLanguage |
| 22 | + */ |
3 | 23 | |
4 | | -require_once( dirname(__FILE__).'/../commandLine.inc' ); |
| 24 | +require_once( dirname(__FILE__) . '/../Maintenance.php' ); |
5 | 25 | |
6 | | -global $IP; |
| 26 | +class CountMessages extends Maintenance { |
| 27 | + public function __construct() { |
| 28 | + parent::__construct(); |
| 29 | + $this->mDescription = "Count how many messages we have defined for each language"; |
| 30 | + } |
7 | 31 | |
8 | | -if ( !isset( $args[0] ) ) { |
9 | | - $dir = "$IP/languages/messages"; |
10 | | -} else { |
11 | | - $dir = $args[0]; |
12 | | -} |
13 | | - |
14 | | -$total = 0; |
15 | | -$nonZero = 0; |
16 | | -foreach ( glob( "$dir/*.php" ) as $file ) { |
17 | | - $baseName = basename( $file ); |
18 | | - if( !preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $baseName, $m ) ) { |
19 | | - continue; |
| 32 | + public function execute() { |
| 33 | + global $IP; |
| 34 | + $dir = $this->getArg( 0, "$IP/languages/messages" ); |
| 35 | + $total = 0; |
| 36 | + $nonZero = 0; |
| 37 | + foreach ( glob( "$dir/*.php" ) as $file ) { |
| 38 | + $baseName = basename( $file ); |
| 39 | + if( !preg_match( '/Messages([A-Z][a-z_]+)\.php$/', $baseName, $m ) ) { |
| 40 | + continue; |
| 41 | + } |
| 42 | + $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
| 43 | + $numMessages = $this->getNumMessages( $file ); |
| 44 | + //print "$code: $numMessages\n"; |
| 45 | + $total += $numMessages; |
| 46 | + if ( $numMessages > 0 ) { |
| 47 | + $nonZero ++; |
| 48 | + } |
| 49 | + } |
| 50 | + $this->output( "\nTotal: $total\n" ); |
| 51 | + $this->output( "Languages: $nonZero\n" ); |
20 | 52 | } |
21 | | - $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
22 | | - $numMessages = wfGetNumMessages( $file ); |
23 | | - //print "$code: $numMessages\n"; |
24 | | - $total += $numMessages; |
25 | | - if ( $numMessages > 0 ) { |
26 | | - $nonZero ++; |
27 | | - } |
28 | | -} |
29 | | -print "\nTotal: $total\n"; |
30 | | -print "Languages: $nonZero\n"; |
31 | 53 | |
32 | | -function wfGetNumMessages( $file ) { |
33 | | - // Separate function to limit scope |
34 | | - require( $file ); |
35 | | - if ( isset( $messages ) ) { |
36 | | - return count( $messages ); |
37 | | - } else { |
38 | | - return 0; |
| 54 | + private function getNumMessages( $file ) { |
| 55 | + // Separate function to limit scope |
| 56 | + require( $file ); |
| 57 | + if ( isset( $messages ) ) { |
| 58 | + return count( $messages ); |
| 59 | + } else { |
| 60 | + return 0; |
| 61 | + } |
39 | 62 | } |
40 | 63 | } |
41 | 64 | |
| 65 | +$maintClass = "CountMessages"; |
| 66 | +require_once( DO_MAINTENANCE ); |
Index: trunk/phase3/maintenance/language/date-formats.php |
— | — | @@ -1,50 +1,76 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * @file |
| 4 | + * Test various language time and date functions |
| 5 | + * |
| 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. |
| 10 | + * |
| 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. |
| 15 | + * |
| 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 |
| 20 | + * |
5 | 21 | * @ingroup MaintenanceLanguage |
6 | 22 | */ |
7 | 23 | |
8 | | -$ts = '20010115123456'; |
| 24 | +require_once( dirname(__FILE__) . '/../Maintenance.php' ); |
9 | 25 | |
10 | | - |
11 | | -$IP = dirname( __FILE__ ) . '/../..'; |
12 | | -require_once( dirname(__FILE__).'/../commandLine.inc' ); |
| 26 | +class DateFormats extends Maintenance { |
13 | 27 | |
14 | | -foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) { |
15 | | - $base = basename( $filename ); |
16 | | - $m = array(); |
17 | | - if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) { |
18 | | - continue; |
| 28 | + private $ts = '20010115123456'; |
| 29 | + |
| 30 | + public function __construct() { |
| 31 | + parent::__construct(); |
| 32 | + $this->mDescription = "Test various language time and date functions"; |
19 | 33 | } |
20 | | - $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
21 | | - print "$code "; |
22 | | - $lang = Language::factory( $code ); |
23 | | - $prefs = $lang->getDatePreferences(); |
24 | | - if ( !$prefs ) { |
25 | | - $prefs = array( 'default' ); |
26 | | - } |
27 | | - print "date: "; |
28 | | - foreach ( $prefs as $index => $pref ) { |
29 | | - if ( $index > 0 ) { |
30 | | - print ' | '; |
| 34 | + |
| 35 | + public function execute() { |
| 36 | + global $IP; |
| 37 | + foreach ( glob( "$IP/languages/messages/Messages*.php" ) as $filename ) { |
| 38 | + $base = basename( $filename ); |
| 39 | + $m = array(); |
| 40 | + if ( !preg_match( '/Messages(.*)\.php$/', $base, $m ) ) { |
| 41 | + continue; |
| 42 | + } |
| 43 | + $code = str_replace( '_', '-', strtolower( $m[1] ) ); |
| 44 | + $this->output( "$code " ); |
| 45 | + $lang = Language::factory( $code ); |
| 46 | + $prefs = $lang->getDatePreferences(); |
| 47 | + if ( !$prefs ) { |
| 48 | + $prefs = array( 'default' ); |
| 49 | + } |
| 50 | + $this->output( "date: " ); |
| 51 | + foreach ( $prefs as $index => $pref ) { |
| 52 | + if ( $index > 0 ) { |
| 53 | + $this->output( ' | ' ); |
| 54 | + } |
| 55 | + $this->output( $lang->date( $this->ts, false, $pref ) ); |
| 56 | + } |
| 57 | + $this->output( "\n$code time: " ); |
| 58 | + foreach ( $prefs as $index => $pref ) { |
| 59 | + if ( $index > 0 ) { |
| 60 | + $this->output( ' | ' ); |
| 61 | + } |
| 62 | + $this->output( $lang->time( $this->ts, false, $pref ) ); |
| 63 | + } |
| 64 | + $this->output( "\n$code both: " ); |
| 65 | + foreach ( $prefs as $index => $pref ) { |
| 66 | + if ( $index > 0 ) { |
| 67 | + $this->output( ' | ' ); |
| 68 | + } |
| 69 | + $this->output( $lang->timeanddate( $this->ts, false, $pref ) ); |
| 70 | + } |
| 71 | + $this->output( "\n\n" ); |
31 | 72 | } |
32 | | - print $lang->date( $ts, false, $pref ); |
33 | 73 | } |
34 | | - print "\n$code time: "; |
35 | | - foreach ( $prefs as $index => $pref ) { |
36 | | - if ( $index > 0 ) { |
37 | | - print ' | '; |
38 | | - } |
39 | | - print $lang->time( $ts, false, $pref ); |
40 | | - } |
41 | | - print "\n$code both: "; |
42 | | - foreach ( $prefs as $index => $pref ) { |
43 | | - if ( $index > 0 ) { |
44 | | - print ' | '; |
45 | | - } |
46 | | - print $lang->timeanddate( $ts, false, $pref ); |
47 | | - } |
48 | | - print "\n\n"; |
49 | 74 | } |
50 | 75 | |
51 | | - |
| 76 | +$maintClass = "DateFormats"; |
| 77 | +require_once( DO_MAINTENANCE ); |