r17477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17476‎ | r17477 | r17478 >
Date:17:42, 7 November 2006
Author:rotem
Status:old
Tags:
Comment:
Adding comments for ignored and optional messages in English.
Modified paths:
  • /trunk/phase3/maintenance/language/rebuildLanguage.php (modified) (history)
  • /trunk/phase3/maintenance/language/writeMessagesArray.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/rebuildLanguage.php
@@ -24,7 +24,7 @@
2525 $messages = $messages['all'];
2626
2727 # Rewrite messages array
28 - $messagesText = writeMessagesArray( $messages );
 28+ $messagesText = writeMessagesArray( $messages, $code == 'en' );
2929
3030 # Write to the file
3131 if ( $write ) {
Index: trunk/phase3/maintenance/language/writeMessagesArray.inc
@@ -7,15 +7,17 @@
88 */
99
1010 require_once( 'messages.inc' );
 11+require_once( 'messageTypes.inc' );
1112
1213 /**
1314 * Write a messages array as a PHP text.
1415 *
1516 * @param $messages The messages array.
 17+ * @param $ignoredComments Show comments about ignored and optional messages? (For English.)
1618 *
1719 * @return The PHP text.
1820 */
19 -function writeMessagesArray( $messages ) {
 21+function writeMessagesArray( $messages, $ignoredComments = false ) {
2022 global $wgMessageStrucutre, $wgBlockComments, $wgMessageComments;
2123
2224 # Sort messages to blocks
@@ -39,9 +41,9 @@
4042 }
4143
4244 # Write the block
43 - $messagesText .= writeMessagesBlock( $block, $wgBlockComments[$block], $messages );
 45+ $messagesText .= writeMessagesBlock( $block, $wgBlockComments[$block], $messages, $ignoredComments );
4446 }
45 - $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'] );
 47+ $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'], $ignoredComments );
4648 $messagesText .= ");\n";
4749
4850 return $messagesText;
@@ -53,11 +55,13 @@
5456 * @param $name The block name.
5557 * @param $comment The block comment.
5658 * @param $messages The block messages.
 59+ * @param $ignoredComments Show comments about ignored and optional messages? (For English.)
5760 *
5861 * @return The block, formatted in PHP.
5962 */
60 -function writeMessagesBlock( $name, $comment, $messages ) {
 63+function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) {
6164 global $wgMessageComments;
 65+ global $wgIgnoredMessages, $wgOptionalMessages;
6266 $blockText = '';
6367
6468 # Skip the block if it includes no messages
@@ -107,7 +111,24 @@
108112 # Comma
109113 $blockText .= ',';
110114
111 - if ( array_key_exists( $key, $wgMessageComments ) ) {
 115+ $ignoredComment = "don't translate or duplicate this message to other languages";
 116+ $optionalComment = "only translate this message to other languages if you have to change it";
 117+ $showIgnoredOrOptionalComment = in_array( $key, $wgIgnoredMessages ) || in_array( $key, $wgOptionalMessages );
 118+ if ( $ignoredComments ) {
 119+ if ( array_key_exists( $key, $wgMessageComments ) ) {
 120+ $blockText .= ' # ' . $wgMessageComments[$key];
 121+ if ( $showIgnoredOrOptionalComment ) {
 122+ $blockText .= '; ';
 123+ }
 124+ } elseif ( $showIgnoredOrOptionalComment ) {
 125+ $blockText .= ' # ';
 126+ }
 127+ if ( in_array( $key, $wgIgnoredMessages ) ) {
 128+ $blockText .= $ignoredComment;
 129+ } elseif ( in_array( $key, $wgOptionalMessages ) ) {
 130+ $blockText .= $optionalComment;
 131+ }
 132+ } elseif ( array_key_exists( $key, $wgMessageComments ) ) {
112133 $blockText .= ' # ' . $wgMessageComments[$key];
113134 }
114135