Index: trunk/phase3/maintenance/language/checkDupeMessages.php |
— | — | @@ -0,0 +1,89 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * @todo document |
| 5 | + * @file |
| 6 | + * @ingroup MaintenanceLanguage |
| 7 | + */ |
| 8 | + |
| 9 | +require_once( dirname(__FILE__).'/../commandLine.inc' ); |
| 10 | +$messagesDir = dirname(__FILE__).'/../../languages/messages/'; |
| 11 | +$runTest = false; |
| 12 | +$run = false; |
| 13 | +$runMode = 'text'; |
| 14 | + |
| 15 | +// Check parameters |
| 16 | +if ( isset( $options['lang'] ) && isset( $options['clang'] )) { |
| 17 | + if (!isset( $options['mode'] )) { |
| 18 | + $runMode = 'text'; |
| 19 | + } else { |
| 20 | + if (!strcmp($options['mode'],'wiki')) { |
| 21 | + $runMode = 'wiki'; |
| 22 | + } else if (!strcmp($options['mode'],'raw')) { |
| 23 | + $runMode = 'raw'; |
| 24 | + } else { |
| 25 | + } |
| 26 | + } |
| 27 | + $runTest = true; |
| 28 | +} else { |
| 29 | + echo <<<END |
| 30 | +Run this script to print out the duplicates against a message array. |
| 31 | +Parameters: |
| 32 | + * lang: Language code to be checked. |
| 33 | + * clang: Language code to be compared. |
| 34 | +Options: |
| 35 | + * mode: Output format, can be either: |
| 36 | + * text: Text output on the console (default) |
| 37 | + * wiki: Wiki format, with * at beginning of each line |
| 38 | + * raw: Raw output for duplicates |
| 39 | +END; |
| 40 | +} |
| 41 | + |
| 42 | +// Check file exists |
| 43 | +if ( $runTest ) { |
| 44 | + $langCode = ucfirst(strtolower(preg_replace('/-/','_',$options['lang']))); |
| 45 | + $langCodeC = ucfirst(strtolower(preg_replace('/-/','_',$options['clang']))); |
| 46 | + $messagesFile = $messagesDir.'Messages'.$langCode.'.php'; |
| 47 | + $messagesFileC = $messagesDir.'Messages'.$langCodeC.'.php'; |
| 48 | + print("$messagesFile\n$messagesFileC\n"); |
| 49 | + if (file_exists($messagesFile) && file_exists($messagesFileC)) { |
| 50 | + $run = true; |
| 51 | + } |
| 52 | + else { |
| 53 | + echo "Languages file(s) could not found.\nMake sure both files are exists.\n"; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +// Run to check the dupes |
| 58 | +if ( $run ) { |
| 59 | + if (!strcmp($runMode,'wiki')) { |
| 60 | + $runMode = 'wiki'; |
| 61 | + } else if (!strcmp($runMode,'raw')) { |
| 62 | + $runMode = 'raw'; |
| 63 | + } |
| 64 | + include( $messagesFile ); |
| 65 | + $wgMessages[$langCode] = $messages; |
| 66 | + include( $messagesFileC ); |
| 67 | + $wgMessages[$langCodeC] = $messages; |
| 68 | + $count = 0; |
| 69 | + |
| 70 | + foreach ($wgMessages[$langCodeC] as $key => $value) { |
| 71 | + foreach ($wgMessages[$langCode] as $ckey => $cvalue) { |
| 72 | + if (!strcmp($key,$ckey)) { |
| 73 | + if (!strcmp($value,$cvalue)) { |
| 74 | + if (!strcmp($runMode,'raw')) { |
| 75 | + print("$key\n"); |
| 76 | + } else if (!strcmp($runMode,'wiki')) { |
| 77 | + $uKey = ucfirst($key); |
| 78 | + print("* MediaWiki:$uKey/$langCode\n"); |
| 79 | + } else { |
| 80 | + print("* $key\n"); |
| 81 | + } |
| 82 | + $count++; |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + if (!strcmp($runMode,'text')) { |
| 88 | + echo "\nThere are $count duplicates messages in ".$options['lang'].", against to ".$options['clang']."\n"; |
| 89 | + } |
| 90 | +} |
Property changes on: trunk/phase3/maintenance/language/checkDupeMessages.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 91 | + native |