MediaWiki  1.23.14
checkDupeMessages.php
Go to the documentation of this file.
1 <?php
24 require_once __DIR__ . '/../commandLine.inc';
25 $messagesDir = __DIR__ . '/../../languages/messages/';
26 $runTest = false;
27 $run = false;
28 $runMode = 'text';
29 
30 // Check parameters
31 if ( isset( $options['lang'] ) && isset( $options['clang'] ) ) {
32  if ( !isset( $options['mode'] ) ) {
33  $runMode = 'text';
34  } else {
35  if ( !strcmp( $options['mode'], 'wiki' ) ) {
36  $runMode = 'wiki';
37  } elseif ( !strcmp( $options['mode'], 'php' ) ) {
38  $runMode = 'php';
39  } elseif ( !strcmp( $options['mode'], 'raw' ) ) {
40  $runMode = 'raw';
41  } else {
42  }
43  }
44  $runTest = true;
45 } else {
46  echo <<<TEXT
47 Run this script to print out the duplicates against a message array.
48 Parameters:
49  * lang: Language code to be checked.
50  * clang: Language code to be compared.
51 Options:
52  * mode: Output format, can be either:
53  * text: Text output on the console (default)
54  * wiki: Wiki format, with * at beginning of each line
55  * php: Output text as PHP syntax in an array named \$dupeMessages
56  * raw: Raw output for duplicates
57 TEXT;
58 }
59 
60 // Check file exists
61 if ( $runTest ) {
62  $langCode = $options['lang'];
63  $langCodeC = $options['clang'];
64  $langCodeF = ucfirst( strtolower( preg_replace( '/-/', '_', $langCode ) ) );
65  $langCodeFC = ucfirst( strtolower( preg_replace( '/-/', '_', $langCodeC ) ) );
66  $messagesFile = $messagesDir . 'Messages' . $langCodeF . '.php';
67  $messagesFileC = $messagesDir . 'Messages' . $langCodeFC . '.php';
68  if ( file_exists( $messagesFile ) && file_exists( $messagesFileC ) ) {
69  $run = true;
70  } else {
71  echo "Messages file(s) could not be found.\nMake sure both files are exists.\n";
72  }
73 }
74 
75 // Run to check the dupes
76 if ( $run ) {
77  if ( !strcmp( $runMode, 'wiki' ) ) {
78  $runMode = 'wiki';
79  } elseif ( !strcmp( $runMode, 'raw' ) ) {
80  $runMode = 'raw';
81  }
82  include $messagesFile;
83  $messageExist = isset( $messages );
84  if ( $messageExist ) {
85  $wgMessages[$langCode] = $messages;
86  }
87  include $messagesFileC;
88  $messageCExist = isset( $messages );
89  if ( $messageCExist ) {
90  $wgMessages[$langCodeC] = $messages;
91  }
92  $count = 0;
93 
94  if ( ( $messageExist ) && ( $messageCExist ) ) {
95 
96  if ( !strcmp( $runMode, 'php' ) ) {
97  print "<?php\n";
98  print '$dupeMessages = array(' . "\n";
99  }
100  foreach ( $wgMessages[$langCodeC] as $key => $value ) {
101  foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) {
102  if ( !strcmp( $key, $ckey ) ) {
103  if ( ( !strcmp( $key, $ckey ) ) && ( !strcmp( $value, $cvalue ) ) ) {
104  if ( !strcmp( $runMode, 'raw' ) ) {
105  print "$key\n";
106  } elseif ( !strcmp( $runMode, 'php' ) ) {
107  print "'$key' => '',\n";
108  } elseif ( !strcmp( $runMode, 'wiki' ) ) {
109  $uKey = ucfirst( $key );
110  print "* MediaWiki:$uKey/$langCode\n";
111  } else {
112  print "* $key\n";
113  }
114  $count++;
115  }
116  }
117  }
118  }
119  if ( !strcmp( $runMode, 'php' ) ) {
120  print ");\n";
121  }
122  if ( !strcmp( $runMode, 'text' ) ) {
123  if ( $count == 1 ) {
124  echo "\nThere are $count duplicated message in $langCode, against to $langCodeC.\n";
125  } else {
126  echo "\nThere are $count duplicated messages in $langCode, against to $langCodeC.\n";
127  }
128  }
129  } else {
130  if ( !$messageExist ) {
131  echo "There are no messages defined in $langCode.\n";
132  }
133  if ( !$messageCExist ) {
134  echo "There are no messages defined in $langCodeC.\n";
135  }
136  }
137 }
compared
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of compared
Definition: contenthandler.txt:5
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PHP
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *css user provided css code *text plain text In PHP
Definition: contenthandler.txt:5
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
wiki
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
Definition: maintenance.txt:1
$messages
$messages
Definition: LogTests.i18n.php:8
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$messagesDir
$messagesDir
Definition: checkDupeMessages.php:25
$options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition: hooks.txt:1530
$value
$value
Definition: styleTest.css.php:45
$count
$count
Definition: UtfNormalTest2.php:96
$runMode
$runMode
Definition: checkDupeMessages.php:28
output
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
in
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning in
Definition: maintenance.txt:1
on
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
Definition: hooks.txt:86
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1230
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$run
$run
Definition: checkDupeMessages.php:27
$runTest
$runTest
Definition: checkDupeMessages.php:26
code
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
Definition: hooks.txt:23
message
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a message
Definition: hooks.txt:1624
Language
Internationalisation code.
Definition: Language.php:74
line
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for so if you want to use a style that puts opening braces on the next line
Definition: design.txt:79