5 * @ingroup MaintenanceLanguage
8 require_once( dirname( __FILE__
) . '/../commandLine.inc' );
9 $messagesDir = dirname( __FILE__
) . '/../../languages/messages/';
15 if ( isset( $options['lang'] ) && isset( $options['clang'] ) ) {
16 if ( !isset( $options['mode'] ) ) {
19 if ( !strcmp( $options['mode'], 'wiki' ) ) {
21 } else if ( !strcmp( $options['mode'], 'php' ) ) {
23 } else if ( !strcmp( $options['mode'], 'raw' ) ) {
31 Run this script to print out the duplicates against a message array.
33 * lang: Language code to be checked.
34 * clang: Language code to be compared.
36 * mode: Output format, can be either:
37 * text: Text output on the console (default)
38 * wiki: Wiki format, with * at beginning of each line
39 * php: Output text as PHP syntax in a array $dupeMessages
40 * raw: Raw output for duplicates
46 $langCode = $options['lang'];
47 $langCodeC = $options['clang'];
48 $langCodeF = ucfirst( strtolower( preg_replace( '/-/', '_', $langCode ) ) );
49 $langCodeFC = ucfirst( strtolower( preg_replace( '/-/', '_', $langCodeC ) ) );
50 $messagesFile = $messagesDir . 'Messages' . $langCodeF . '.php';
51 $messagesFileC = $messagesDir . 'Messages' . $langCodeFC . '.php';
52 if ( file_exists( $messagesFile ) && file_exists( $messagesFileC ) ) {
56 echo "Messages file(s) could not be found.\nMake sure both files are exists.\n";
60 // Run to check the dupes
62 if ( !strcmp( $runMode, 'wiki' ) ) {
64 } else if ( !strcmp( $runMode, 'raw' ) ) {
67 include( $messagesFile );
68 $messageExist = isset( $messages );
70 $wgMessages[$langCode] = $messages;
71 include( $messagesFileC );
72 $messageCExist = isset( $messages );
74 $wgMessages[$langCodeC] = $messages;
77 if ( ( $messageExist ) && ( $messageCExist ) ) {
79 if ( !strcmp( $runMode, 'php' ) ) {
81 print( '$dupeMessages = array(' . "\n" );
83 foreach ( $wgMessages[$langCodeC] as $key => $value ) {
84 foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) {
85 if ( !strcmp( $key, $ckey ) ) {
86 if ( ( !strcmp( $key, $ckey ) ) && ( !strcmp( $value, $cvalue ) ) ) {
87 if ( !strcmp( $runMode, 'raw' ) ) {
89 } else if ( !strcmp( $runMode, 'php' ) ) {
90 print( "'$key' => '',\n" );
91 } else if ( !strcmp( $runMode, 'wiki' ) ) {
92 $uKey = ucfirst( $key );
93 print( "* MediaWiki:$uKey/$langCode\n" );
102 if ( !strcmp( $runMode, 'php' ) ) {
105 if ( !strcmp( $runMode, 'text' ) ) {
107 echo "\nThere are $count duplicated message in $langCode, against to $langCodeC.\n";
109 echo "\nThere are $count duplicated messages in $langCode, against to $langCodeC.\n";
113 if ( !$messageExist )
114 echo "There are no messages defined in $langCode.\n";
115 if ( !$messageCExist )
116 echo "There are no messages defined in $langCodeC.\n";