From 443be5db162b0e870fad47b0a41317837838fcb7 Mon Sep 17 00:00:00 2001 From: Rotem Liss Date: Tue, 21 Nov 2006 19:26:11 +0000 Subject: [PATCH] Fixes for the script rebuildLanguage.php: * (bug 7983) Sort blocks in the correct order * Sort the unknown messages alphabetically * Use single apostrophe on messages which include dollar signs which are not followed by numbers --- maintenance/language/messages.inc | 8 ++++++++ maintenance/language/writeMessagesArray.inc | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 2a15a14a40..754f5a3c56 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1998,4 +1998,12 @@ $wgMessageComments = array( 'autoredircomment' => 'This should be changed to the new naming convention, but existed beforehand', ); +/** Messages which contain dollar signs (which are not followed by numbers), and therefore should use a single apostrophe */ +$wgMessagseWithDollarSigns = array( + 'linkprefix', + 'enotif_subject', + 'enotif_body', + 'allmessagesnotsupportedDB', +); + ?> diff --git a/maintenance/language/writeMessagesArray.inc b/maintenance/language/writeMessagesArray.inc index 9cff30c5dc..b0d17c59ca 100644 --- a/maintenance/language/writeMessagesArray.inc +++ b/maintenance/language/writeMessagesArray.inc @@ -22,12 +22,11 @@ function writeMessagesArray( $messages, $ignoredComments = false ) { # Sort messages to blocks $sortedMessages['unknown'] = $messages; - foreach ( $messages as $key => $value ) { - foreach ( $wgMessageStrucutre as $blockName => $block ) { - if ( in_array( $key, $block ) ) { - $sortedMessages[$blockName][$key] = $value; + foreach ( $wgMessageStrucutre as $blockName => $block ) { + foreach ( $block as $key ) { + if ( array_key_exists( $key, $sortedMessages['unknown'] ) ) { + $sortedMessages[$blockName][$key] = $sortedMessages['unknown'][$key]; unset( $sortedMessages['unknown'][$key] ); - break; } } } @@ -43,7 +42,8 @@ function writeMessagesArray( $messages, $ignoredComments = false ) { # Write the block $messagesText .= writeMessagesBlock( $block, $wgBlockComments[$block], $messages, $ignoredComments ); } - $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'], $ignoredComments ); + ksort( $sortedMessages['unknown'] ); + $messagesText .= writeMessagesBlock( 'unknown', 'Unknown messages', $sortedMessages['unknown'], $ignoredComments ); # Write the unknown messages, alphabetically sorted $messagesText .= ");\n"; return $messagesText; @@ -60,7 +60,7 @@ function writeMessagesArray( $messages, $ignoredComments = false ) { * @return The block, formatted in PHP. */ function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) { - global $wgMessageComments; + global $wgMessageComments, $wgMessagseWithDollarSigns; global $wgIgnoredMessages, $wgOptionalMessages; $blockText = ''; @@ -102,7 +102,7 @@ function writeMessagesBlock( $name, $comment, $messages, $ignoredComments ) { # Check for the appropriate apostrophe and add the value if ( strpos( $value, "'" ) === false ) { $blockText .= "'$value'"; - } elseif ( strpos( $value, '"' ) === false ) { + } elseif ( strpos( $value, '"' ) === false && !in_array( $key, $wgMessagseWithDollarSigns ) ) { $blockText .= "\"$value\""; } else { $blockText .= "'" . str_replace( "'", "\'", $value ) . "'"; -- 2.20.1