From: Rotem Liss Date: Tue, 7 Nov 2006 17:42:22 +0000 (+0000) Subject: Adding comments for ignored and optional messages in English. X-Git-Tag: 1.31.0-rc.0~55262 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=3deca13323f79748fecc1a705f74dc107a86cf46;p=lhc%2Fweb%2Fwiklou.git Adding comments for ignored and optional messages in English. --- diff --git a/maintenance/language/rebuildLanguage.php b/maintenance/language/rebuildLanguage.php index 4817daaaa6..1643d30b0d 100644 --- a/maintenance/language/rebuildLanguage.php +++ b/maintenance/language/rebuildLanguage.php @@ -24,7 +24,7 @@ function rebuildLanguage( $code, $write ) { $messages = $messages['all']; # Rewrite messages array - $messagesText = writeMessagesArray( $messages ); + $messagesText = writeMessagesArray( $messages, $code == 'en' ); # Write to the file if ( $write ) { diff --git a/maintenance/language/writeMessagesArray.inc b/maintenance/language/writeMessagesArray.inc index 7596a49cf0..9cff30c5dc 100644 --- a/maintenance/language/writeMessagesArray.inc +++ b/maintenance/language/writeMessagesArray.inc @@ -7,15 +7,17 @@ */ require_once( 'messages.inc' ); +require_once( 'messageTypes.inc' ); /** * Write a messages array as a PHP text. * * @param $messages The messages array. + * @param $ignoredComments Show comments about ignored and optional messages? (For English.) * * @return The PHP text. */ -function writeMessagesArray( $messages ) { +function writeMessagesArray( $messages, $ignoredComments = false ) { global $wgMessageStrucutre, $wgBlockComments, $wgMessageComments; # Sort messages to blocks @@ -39,9 +41,9 @@ function writeMessagesArray( $messages ) { } # Write the block - $messagesText .= writeMessagesBlock( $block, $wgBlockComments[$block], $messages ); + $messagesText .= writeMessagesBlock( $block, $wgBlockComments[$block], $messages, $ignoredComments ); } - $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'] ); + $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'], $ignoredComments ); $messagesText .= ");\n"; return $messagesText; @@ -53,11 +55,13 @@ function writeMessagesArray( $messages ) { * @param $name The block name. * @param $comment The block comment. * @param $messages The block messages. + * @param $ignoredComments Show comments about ignored and optional messages? (For English.) * * @return The block, formatted in PHP. */ -function writeMessagesBlock( $name, $comment, $messages ) { +function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) { global $wgMessageComments; + global $wgIgnoredMessages, $wgOptionalMessages; $blockText = ''; # Skip the block if it includes no messages @@ -107,7 +111,24 @@ function writeMessagesBlock( $name, $comment, $messages ) { # Comma $blockText .= ','; - if ( array_key_exists( $key, $wgMessageComments ) ) { + $ignoredComment = "don't translate or duplicate this message to other languages"; + $optionalComment = "only translate this message to other languages if you have to change it"; + $showIgnoredOrOptionalComment = in_array( $key, $wgIgnoredMessages ) || in_array( $key, $wgOptionalMessages ); + if ( $ignoredComments ) { + if ( array_key_exists( $key, $wgMessageComments ) ) { + $blockText .= ' # ' . $wgMessageComments[$key]; + if ( $showIgnoredOrOptionalComment ) { + $blockText .= '; '; + } + } elseif ( $showIgnoredOrOptionalComment ) { + $blockText .= ' # '; + } + if ( in_array( $key, $wgIgnoredMessages ) ) { + $blockText .= $ignoredComment; + } elseif ( in_array( $key, $wgOptionalMessages ) ) { + $blockText .= $optionalComment; + } + } elseif ( array_key_exists( $key, $wgMessageComments ) ) { $blockText .= ' # ' . $wgMessageComments[$key]; }