25 require_once __DIR__ .
'/../commandLine.inc';
32 if ( isset( $options[
'lang'] ) && isset( $options[
'clang'] ) ) {
33 if ( !isset( $options[
'mode'] ) ) {
36 if ( !strcmp( $options[
'mode'],
'wiki' ) ) {
38 } elseif ( !strcmp( $options[
'mode'],
'php' ) ) {
40 } elseif ( !strcmp( $options[
'mode'],
'raw' ) ) {
48 Run
this script to print out the duplicates against a message array.
51 * clang:
Language code to be compared.
53 * mode: Output format, can be either:
54 * text: Text output on the console (
default)
55 * wiki: Wiki format, with * at beginning of each line
56 * php: Output text as PHP syntax in an array named \$dupeMessages
57 * raw: Raw output
for duplicates
63 $langCode = $options[
'lang'];
64 $langCodeC = $options[
'clang'];
65 $langCodeF = ucfirst( strtolower( preg_replace(
'/-/',
'_', $langCode ) ) );
66 $langCodeFC = ucfirst( strtolower( preg_replace(
'/-/',
'_', $langCodeC ) ) );
67 $messagesFile =
$messagesDir .
'Messages' . $langCodeF .
'.php';
68 $messagesFileC =
$messagesDir .
'Messages' . $langCodeFC .
'.php';
69 if ( file_exists( $messagesFile ) && file_exists( $messagesFileC ) ) {
72 echo
"Messages file(s) could not be found.\nMake sure both files are exists.\n";
80 } elseif ( !strcmp(
$runMode,
'raw' ) ) {
83 include $messagesFile;
84 $messageExist = isset( $messages );
85 if ( $messageExist ) {
86 $wgMessages[$langCode] = $messages;
88 include $messagesFileC;
89 $messageCExist = isset( $messages );
90 if ( $messageCExist ) {
91 $wgMessages[$langCodeC] = $messages;
95 if ( ( $messageExist ) && ( $messageCExist ) ) {
98 print
'$dupeMessages = [' .
"\n";
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 ) ) ) {
106 } elseif ( !strcmp(
$runMode,
'php' ) ) {
107 print
"'$key' => '',\n";
108 } elseif ( !strcmp(
$runMode,
'wiki' ) ) {
109 $uKey = ucfirst( $key );
110 print
"* MediaWiki:$uKey/$langCode\n";
122 if ( !strcmp(
$runMode,
'text' ) ) {
124 echo
"\nThere are $count duplicated message in $langCode, against to $langCodeC.\n";
126 echo
"\nThere are $count duplicated messages in $langCode, against to $langCodeC.\n";
130 if ( !$messageExist ) {
131 echo
"There are no messages defined in $langCode.\n";
133 if ( !$messageCExist ) {
134 echo
"There are no messages defined in $langCodeC.\n";