Recommiting r47578, fixed.
authorRotem Liss <rotem@users.mediawiki.org>
Sat, 21 Feb 2009 10:18:45 +0000 (10:18 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Sat, 21 Feb 2009 10:18:45 +0000 (10:18 +0000)
maintenance/language/checkLanguage.inc
maintenance/language/languages.inc
maintenance/language/transstat.php

index 34d4d40..52281b5 100644 (file)
@@ -110,7 +110,7 @@ class CheckLanguageCLI {
                        'untranslated' => 'getUntranslatedMessages',
                        'duplicate'    => 'getDuplicateMessages',
                        'obsolete'     => 'getObsoleteMessages',
-                       'variables'    => 'getMessagesWithoutVariables',
+                       'variables'    => 'getMessagesWithMismatchVariables',
                        'plural'       => 'getMessagesWithoutPlural',
                        'empty'        => 'getEmptyMessages',
                        'whitespace'   => 'getMessagesWithWhitespace',
@@ -157,7 +157,7 @@ class CheckLanguageCLI {
                        'untranslated' => '$1 message(s) of $2 are not translated to $3, but exist in en:',
                        'duplicate'    => '$1 message(s) of $2 are translated the same in en and $3:',
                        'obsolete'     => '$1 message(s) of $2 do not exist in en or are in the ignore list, but exist in $3:',
-                       'variables'    => '$1 message(s) of $2 in $3 don\'t use some variables that en uses:',
+                       'variables'    => '$1 message(s) of $2 in $3 don\'t match the variables used in en:',
                        'plural'       => '$1 message(s) of $2 in $3 don\'t use {{plural}} while en uses:',
                        'empty'        => '$1 message(s) of $2 in $3 are empty or -:',
                        'whitespace'   => '$1 message(s) of $2 in $3 have trailing whitespace:',
@@ -199,7 +199,7 @@ Check codes (ideally, all of them should result 0; all the checks are executed b
        * untranslated: Messages which are required to translate, but are not translated.
        * duplicate: Messages which translation equal to fallback
        * obsolete: Messages which are untranslatable or do not exist, but are translated.
-       * variables: Messages without variables which should be used.
+       * variables: Messages without variables which should be used, or with variables which shouldn't be used.
        * empty: Empty messages and messages that contain only -.
        * whitespace: Messages which have trailing whitespace.
        * xhtml: Messages which are not well-formed XHTML (checks only few common errors).
@@ -587,7 +587,7 @@ Check codes (ideally, all of them should result 0; all the checks are executed b
        * untranslated: Messages which are required to translate, but are not translated.
        * duplicate: Messages which translation equal to fallback
        * obsolete: Messages which are untranslatable, but translated.
-       * variables: Messages without variables which should be used.
+       * variables: Messages without variables which should be used, or with variables which shouldn't be used.
        * empty: Empty messages.
        * whitespace: Messages which have trailing whitespace.
        * xhtml: Messages which are not well-formed XHTML (checks only few common errors).
index 61ad287..6159e84 100644 (file)
@@ -300,17 +300,17 @@ class languages {
        }
 
        /**
-        * Get the messages which do not use some variables.
+        * Get the messages whose variables do not match the original ones.
         *
         * @param $code The language code.
         *
-        * @return The messages which do not use some variables in this language.
+        * @return The messages whose variables do not match the original ones.
         */
-       public function getMessagesWithoutVariables( $code ) {
+       public function getMessagesWithMismatchVariables( $code ) {
                $this->loadGeneralMessages();
                $this->loadMessages( $code );
                $variables = array( '\$1', '\$2', '\$3', '\$4', '\$5', '\$6', '\$7', '\$8', '\$9' );
-               $messagesWithoutVariables = array();
+               $mismatchMessages = array();
                foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
                        $missing = false;
                        foreach ( $variables as $var ) {
@@ -318,12 +318,16 @@ class languages {
                                        !preg_match( "/$var/sU", $value ) ) {
                                        $missing = true;
                                }
+                               if ( !preg_match( "/$var/sU", $this->mGeneralMessages['translatable'][$key] ) &&
+                                       preg_match( "/$var/sU", $value ) ) {
+                                       $missing = true;
+                               }
                        }
                        if ( $missing ) {
-                               $messagesWithoutVariables[$key] = $value;
+                               $mismatchMessages[$key] = $value;
                        }
                }
-               return $messagesWithoutVariables;
+               return $mismatchMessages;
        }
 
        /**
index ee2b844..b433abb 100644 (file)
@@ -96,12 +96,12 @@ foreach ( $wgLanguages->getLanguages() as $code ) {
        $requiredMessagesPercent = $wgOut->formatPercent( $requiredMessagesNumber, $wgRequiredMessagesNumber );
        $obsoleteMessagesNumber = count( $messages['obsolete'] );
        $obsoleteMessagesPercent = $wgOut->formatPercent( $obsoleteMessagesNumber, $messagesNumber, true );
-       $messagesWithoutVariables = $wgLanguages->getMessagesWithoutVariables( $code );
+       $messagesWithMismatchVariables = $wgLanguages->getMessagesWithMismatchVariables( $code );
        $emptyMessages = $wgLanguages->getEmptyMessages( $code );
        $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code );
        $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code );
        $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code );
-       $problematicMessagesNumber = count( array_unique( array_merge( $messagesWithoutVariables, $emptyMessages, $messagesWithWhitespace, $nonXHTMLMessages, $messagesWithWrongChars ) ) );
+       $problematicMessagesNumber = count( array_unique( array_merge( $messagesWithMismatchVariables, $emptyMessages, $messagesWithWhitespace, $nonXHTMLMessages, $messagesWithWrongChars ) ) );
        $problematicMessagesPercent = $wgOut->formatPercent( $problematicMessagesNumber, $messagesNumber, true );
 
        # Output them