Fixes for the script rebuildLanguage.php:
authorRotem Liss <rotem@users.mediawiki.org>
Tue, 21 Nov 2006 19:26:11 +0000 (19:26 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Tue, 21 Nov 2006 19:26:11 +0000 (19:26 +0000)
* (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
maintenance/language/writeMessagesArray.inc

index 2a15a14..754f5a3 100644 (file)
@@ -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',
+);
+
 ?>
index 9cff30c..b0d17c5 100644 (file)
@@ -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 ) . "'";