* New features for checking languages: Checking namespace names, skin names, magic...
authorRotem Liss <rotem@users.mediawiki.org>
Tue, 21 Oct 2008 09:29:47 +0000 (09:29 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Tue, 21 Oct 2008 09:29:47 +0000 (09:29 +0000)
* Code cleanup, whitespace and documentation for the language checking scripts.

maintenance/language/checkLanguage.inc
maintenance/language/checkLanguage.php
maintenance/language/languages.inc

index 44b9159..20e3952 100644 (file)
@@ -13,20 +13,15 @@ class CheckLanguageCLI {
        protected $checks = array();
        protected $L = null;
 
-       protected $defaultChecks = array(
-               'untranslated', 'duplicate', 'obsolete', 'variables', 'empty', 'plural',
-               'whitespace', 'xhtml', 'chars', 'links', 'unbalanced',
-       );
-
        protected $results = array();
 
        private $includeExif = false;
 
        /**
-        * GLOBALS: $wgLanguageCode;
+        * Constructor.
+        * @param $options Options for script.
         */
        public function __construct( Array $options ) {
-
                if ( isset( $options['help'] ) ) {
                        echo $this->help();
                        exit();
@@ -55,11 +50,11 @@ class CheckLanguageCLI {
                        $this->checks = explode( ',', $options['whitelist'] );
                } elseif ( isset( $options['blacklist'] ) ) {
                        $this->checks = array_diff(
-                               $this->defaultChecks,
+                               $this->defaultChecks(),
                                explode( ',', $options['blacklist'] )
                        );
                } else {
-                       $this->checks = $this->defaultChecks;
+                       $this->checks = $this->defaultChecks();
                }
 
                if ( isset($options['output']) ) {
@@ -69,38 +64,87 @@ class CheckLanguageCLI {
                $this->L = new languages( $this->includeExif );
        }
 
+       /**
+        * Get the default checks.
+        * @return A list of the default checks.
+        */
+       protected function defaultChecks() {
+               return array(
+                       'untranslated', 'duplicate', 'obsolete', 'variables', 'empty', 'plural',
+                       'whitespace', 'xhtml', 'chars', 'links', 'unbalanced', 'namespace',
+                       'projecttalk', 'skin', 'magic', 'magic-over', 'magic-case', 'special',
+               );
+       }
+
+       /**
+        * Get the non-message checks.
+        * @return A list of the non-message checks.
+        */
+       protected function nonMessageChecks() {
+               return array(
+                       'namespace', 'projecttalk', 'skin', 'magic', 'magic-over', 'magic-case',
+                       'special',
+               );
+       }
+
+       /**
+        * Get all checks.
+        * @return An array of all check names mapped to their function names.
+        */
        protected function getChecks() {
-               $checks = array();
-               $checks['untranslated'] = 'getUntranslatedMessages';
-               $checks['duplicate'] = 'getDuplicateMessages';
-               $checks['obsolete'] = 'getObsoleteMessages';
-               $checks['variables'] = 'getMessagesWithoutVariables';
-               $checks['plural'] = 'getMessagesWithoutPlural';
-               $checks['empty'] = 'getEmptyMessages';
-               $checks['whitespace'] = 'getMessagesWithWhitespace';
-               $checks['xhtml'] = 'getNonXHTMLMessages';
-               $checks['chars'] = 'getMessagesWithWrongChars';
-               $checks['links'] = 'getMessagesWithDubiousLinks';
-               $checks['unbalanced'] = 'getMessagesWithUnbalanced';
-               return $checks;
+               return array(
+                       'untranslated' => 'getUntranslatedMessages',
+                       'duplicate'    => 'getDuplicateMessages',
+                       'obsolete'     => 'getObsoleteMessages',
+                       'variables'    => 'getMessagesWithoutVariables',
+                       'plural'       => 'getMessagesWithoutPlural',
+                       'empty'        => 'getEmptyMessages',
+                       'whitespace'   => 'getMessagesWithWhitespace',
+                       'xhtml'        => 'getNonXHTMLMessages',
+                       'chars'        => 'getMessagesWithWrongChars',
+                       'links'        => 'getMessagesWithDubiousLinks',
+                       'unbalanced'   => 'getMessagesWithUnbalanced',
+                       'namespace'    => 'getUntranslatedNamespaces',
+                       'projecttalk'  => 'getProblematicProjectTalks',
+                       'skin'         => 'getUntranslatedSkins',
+                       'magic'        => 'getUntranslatedMagicWords',
+                       'magic-over'   => 'getOverridingMagicWords',
+                       'magic-case'   => 'getCaseMismatchMagicWords',
+                       'special'      => 'getUntraslatedSpecialPages',
+               );
        }
 
+       /**
+        * Get all check descriptions.
+        * @return An array of all check names mapped to their descriptions.
+        */
        protected function getDescriptions() {
-               $descriptions = array();
-               $descriptions['untranslated'] = '$1 message(s) of $2 are not translated to $3, but exist in en:';
-               $descriptions['duplicate'] = '$1 message(s) of $2 are translated the same in en and $3:';
-               $descriptions['obsolete'] = '$1 message(s) of $2 do not exist in en or are in the ignore list, but are in $3';
-               $descriptions['variables'] = '$1 message(s) of $2 in $3 don\'t use some variables that en uses:';
-               $descriptions['plural'] = '$1 message(s) of $2 in $3 don\'t use {{plural}} while en uses:';
-               $descriptions['empty'] = '$1 message(s) of $2 in $3 are empty or -:';
-               $descriptions['whitespace'] = '$1 message(s) of $2 in $3 have trailing whitespace:';
-               $descriptions['xhtml'] = '$1 message(s) of $2 in $3 contain illegal XHTML:';
-               $descriptions['chars'] = '$1 message(s) of $2 in $3 include hidden chars which should not be used in the messages:';
-               $descriptions['links'] = '$1 message(s) of $2 in $3 have problematic link(s):';
-               $descriptions['unbalanced'] = '$1 message(s) of $2 in $3 have unbalanced {[]}:';
-               return $descriptions;
+               return array(
+                       '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:',
+                       '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:',
+                       'xhtml'        => '$1 message(s) of $2 in $3 contain illegal XHTML:',
+                       'chars'        => '$1 message(s) of $2 in $3 include hidden chars which should not be used in the messages:',
+                       'links'        => '$1 message(s) of $2 in $3 have problematic link(s):',
+                       'unbalanced'   => '$1 message(s) of $2 in $3 have unbalanced {[]}:',
+                       'namespace'    => '$1 namespace name(s) of $2 are not translated to $3, but exist in en:',
+                       'projecttalk'  => '$1 namespace name(s) and alias(es) in $3 are project talk namespaces without the parameter:',
+                       'skin'         => '$1 skin name(s) of $2 are not translated to $3, but exist in en:',
+                       'magic'        => '$1 magic word(s) of $2 are not translated to $3, but exist in en:',
+                       'magic-over'   => '$1 magic word(s) of $2 in $3 do not contain the original en word(s):',
+                       'magic-case'   => '$1 magic word(s) of $2 in $3 change the case-sensitivity of the original en word:',
+                       'special'      => '$1 special page alias(es) of $2 are not translated to $3, but exist in en:',
+               );
        }
 
+       /**
+        * Get help.
+        * @return The help string.
+        */
        protected function help() {
                return <<<ENDS
 Run this script to check a specific language file, or all of them.
@@ -109,23 +153,30 @@ Parameters:
        * lang: Language code (default: the installation default language).
        * all: Check all customized languages.
        * help: Show this help.
-       * level: Show the following level (default: 2).
+       * level: Show the following display level (default: 2).
        * links: Link the message values (default off).
        * wikilang: For the links, what is the content language of the wiki to display the output in (default en).
        * whitelist: Do only the following checks (form: code,code).
        * blacklist: Don't do the following checks (form: code,code).
        * noexif: Don't check for EXIF messages (a bit hard and boring to translate), if you know that they are currently not translated and want to focus on other problems (default off).
-Check codes (ideally, all of them should result 0; all the checks are executed by default (except duplicate and language specific check blacklists in checkLanguage.inc):
+Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
        * 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.
-       * empty: Empty messages.
+       * 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).
        * chars: Messages with hidden characters.
        * links: Messages which contains broken links to pages (does not find all).
        * unbalanced: Messages which contains unequal numbers of opening {[ and closing ]}.
+       * namespace: Namespace names that were not translated.
+       * projecttalk: Namespace names and aliases where the project talk does not contain $1.
+       * skin: Skin names that were not translated.
+       * magic: Magic words that were not translated.
+       * magic-over: Magic words that override the original English word.
+       * magic-case: Magic words whose translation changes the case-sensitivity of the original English word.
+       * special: Special page names that were not translated.
 Display levels (default: 2):
        * 0: Skip the checks (useful for checking syntax).
        * 1: Show only the stub headers and number of wrong messages, without list of messages.
@@ -135,10 +186,13 @@ Display levels (default: 2):
 ENDS;
        }
 
+       /**
+        * Execute the script.
+        */
        public function execute() {
                $this->doChecks();
                if ( $this->level > 0 ) {
-                       switch ($this->output) {
+                       switch ( $this->output ) {
                                case 'plain':
                                        $this->outputText();
                                        break;
@@ -146,11 +200,14 @@ ENDS;
                                        $this->outputWiki();
                                        break;
                                default:
-                                       throw new MWException( "Invalid output type $this->output");
+                                       throw new MWException( "Invalid output type $this->output" );
                        }
                }
        }
 
+       /**
+        * Execute the checks.
+        */
        protected function doChecks() {
                $ignoredCodes = array( 'en', 'enRTL' );
 
@@ -158,24 +215,33 @@ ENDS;
                # Check the language
                if ( $this->checkAll ) {
                        foreach ( $this->L->getLanguages() as $language ) {
-                               if ( !in_array($language, $ignoredCodes) ) {
+                               if ( !in_array( $language, $ignoredCodes ) ) {
                                        $this->results[$language] = $this->checkLanguage( $language );
                                }
                        }
                } else {
-                       if ( in_array($this->code, $ignoredCodes) ) {
-                               throw new MWException("Cannot check code $this->code.");
+                       if ( in_array( $this->code, $ignoredCodes ) ) {
+                               throw new MWException( "Cannot check code $this->code." );
                        } else {
                                $this->results[$this->code] = $this->checkLanguage( $this->code );
                        }
                }
        }
 
+       /**
+        * Get the check blacklist.
+        * @return The list of checks which should not be executed.
+        */
        protected function getCheckBlacklist() {
                global $checkBlacklist;
                return $checkBlacklist;
        }
 
+       /**
+        * Check a language.
+        * @param $code The language code.
+        * @return The results.
+        */
        protected function checkLanguage( $code ) {
                # Syntax check only
                if ( $this->level === 0 ) {
@@ -187,15 +253,17 @@ ENDS;
                $checkFunctions = $this->getChecks();
                $checkBlacklist = $this->getCheckBlacklist();
                foreach ( $this->checks as $check ) {
-                       if ( isset($checkBlacklist[$code]) &&
-                               in_array($check, $checkBlacklist[$code]) ) {
+                       if ( isset( $checkBlacklist[$code] ) &&
+                               in_array( $check, $checkBlacklist[$code] ) ) {
                                $result[$check] = array();
                                continue;
                        }
 
                        $callback = array( $this->L, $checkFunctions[$check] );
-                       if ( !is_callable($callback ) ) {
-                               throw new MWException( "Unkown check $check." );
+                       if ( !is_callable( $callback ) ) {
+                               # DEBUG
+                               # throw new MWException( "Unkown check $check." );
+                               continue;
                        }
                        $results[$check] = call_user_func( $callback , $code );
                }
@@ -203,6 +271,12 @@ ENDS;
                return $results;
        }
 
+       /**
+        * Format a message key.
+        * @param $key The message key.
+        * @param $code The language code.
+        * @return The formatted message key.
+        */
        protected function formatKey( $key, $code ) {
                if ( $this->doLinks ) {
                        $displayKey = ucfirst( $key );
@@ -216,28 +290,59 @@ ENDS;
                }
        }
 
+       /**
+        * Output the checks results as plain text.
+        * @return The checks results as plain text.
+        */
        protected function outputText() {
                foreach ( $this->results as $code => $results ) {
                        $translated = $this->L->getMessages( $code );
                        $translated = count( $translated['translated'] );
-                       $translatable = $this->L->getGeneralMessages();
-                       $translatable = count( $translatable['translatable'] );
                        foreach ( $results as $check => $messages ) {
                                $count = count( $messages );
                                if ( $count ) {
+                                       switch( $check ) {
+                                               case 'untranslated':
+                                                       $translatable = $this->L->getGeneralMessages();
+                                                       $total = count( $translatable['translatable'] );
+                                                       break;
+                                               case 'namespace':
+                                                       $total = count( $this->L->getNamespaceNames( 'en' ) );
+                                                       break;
+                                               case 'projecttalk':
+                                                       $total = null;
+                                                       break;
+                                               case 'skin':
+                                                       $total = count( $this->L->getSkinNames( 'en' ) );
+                                                       break;
+                                               case 'magic':
+                                                       $total = count( $this->L->getMagicWords( 'en' ) );
+                                                       break;
+                                               case 'magic-over':
+                                               case 'magic-case':
+                                                       $total = count( $this->L->getMagicWords( $code ) );
+                                                       break;
+                                               case 'special':
+                                                       $total = count( $this->L->getSpecialPageAliases( 'en' ) );
+                                                       break;
+                                               default:
+                                                       $total = $translated;
+                                       }
                                        $search = array( '$1', '$2', '$3' );
-                                       $replace = array( $count, $check == 'untranslated' ? $translatable: $translated, $code );
+                                       $replace = array( $count, $total, $code );
                                        $descriptions = $this->getDescriptions();
                                        echo "\n" . str_replace( $search, $replace, $descriptions[$check] ) . "\n";
                                        if ( $this->level == 1 ) {
                                                echo "[messages are hidden]\n";
                                        } else {
                                                foreach ( $messages as $key => $value ) {
-                                                       $displayKey = $this->formatKey( $key, $code );
-                                                       if ( $this->level == 2 ) {
-                                                               echo "* $displayKey\n";
+                                                       if( !in_array( $check, $this->nonMessageChecks() ) ) {
+                                                               $key = $this->formatKey( $key, $code );
+                                                       }
+                                                       if ( $this->level == 2 || empty( $value ) ) {
+                                                               echo "* $key\n";
                                                        } else {
-                                                               echo "* $displayKey:            '$value'\n";
+                                                               echo "* $key:           '$value'\n";
                                                        }
                                                }
                                        }
@@ -247,7 +352,8 @@ ENDS;
        }
 
        /**
-        * Globals: $wgContLang, $IP
+        * Output the checks results as wiki text.
+        * @return The checks results as wiki text.
         */
        function outputWiki() {
                global $wgContLang, $IP;
@@ -259,6 +365,9 @@ ENDS;
                        $problems = 0;
                        $detailTextForLangChecks = array();
                        foreach ( $results as $check => $messages ) {
+                               if( in_array( $check, $this->nonMessageChecks() ) ) {
+                                       continue;
+                               }
                                $count = count( $messages );
                                if ( $count ) {
                                        $problems += $count;
@@ -267,7 +376,7 @@ ENDS;
                                                $displayKey = $this->formatKey( $key, $code );
                                                $messageDetails[] = $displayKey;
                                        }
-                                       $detailTextForLangChecks[] = "===$code-$check===\n* " . implode( ', ', $messageDetails );
+                                       $detailTextForLangChecks[] = "=== $code-$check ===\n* " . implode( ', ', $messageDetails );
                                        $numbers[] = "'''[[#$code-$check|$count]]'''";
                                } else {
                                        $numbers[] = $count;
@@ -279,7 +388,10 @@ ENDS;
                                $detailText .= $detailTextForLang . implode( "\n", $detailTextForLangChecks ) . "\n";
                        }
 
-                       if ( !$problems ) { continue; } // Don't list languages without problems
+                       if ( !$problems ) {
+                               # Don't list languages without problems
+                               continue;
+                       }
                        $language = $wgContLang->getLanguageName( $code );
                        $rows[] = "| $language || $code || $problems || " . implode( ' || ', $numbers );
                }
@@ -291,7 +403,7 @@ ENDS;
 '''Check results are for:''' <code>$version</code>
 
 
-{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;"
+{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear: both;"
 $tableRows
 |}
 
@@ -300,26 +412,30 @@ $detailText
 EOL;
        }
 
+       /**
+        * Check if there are any results for the checks, in any language.
+        * @return True if there are any results, false if not.
+        */
        protected function isEmpty() {
-               $empty = true;
                foreach( $this->results as $code => $results ) {
                        foreach( $results as $check => $messages ) {
                                if( !empty( $messages ) ) {
-                                       $empty = false;
-                                       break;
+                                       return false;
                                }
                        }
-                       if( !$empty ) {
-                               break;
-                       }
                }
-               return $empty;
+               return true;
        }
 }
 
 class CheckExtensionsCLI extends CheckLanguageCLI {
        private $extensions;
 
+       /**
+        * Constructor.
+        * @param $options Options for script.
+        * @param $extension The extension name (or names).
+        */
        public function __construct( Array $options, $extension ) {
                if ( isset( $options['help'] ) ) {
                        echo $this->help();
@@ -347,11 +463,11 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
                        $this->checks = explode( ',', $options['whitelist'] );
                } elseif ( isset( $options['blacklist'] ) ) {
                        $this->checks = array_diff(
-                               $this->defaultChecks,
+                               $this->defaultChecks(),
                                explode( ',', $options['blacklist'] )
                        );
                } else {
-                       $this->checks = $this->defaultChecks;
+                       $this->checks = $this->defaultChecks();
                }
 
                if ( isset($options['output']) ) {
@@ -392,6 +508,21 @@ class CheckExtensionsCLI extends CheckLanguageCLI {
                }
        }
 
+       /**
+        * Get the default checks.
+        * @return A list of the default checks.
+        */
+       protected function defaultChecks() {
+               return array(
+                       'untranslated', 'duplicate', 'obsolete', 'variables', 'empty', 'plural',
+                       'whitespace', 'xhtml', 'chars', 'links', 'unbalanced',
+               );
+       }
+
+       /**
+        * Get help.
+        * @return The help string.
+        */
        protected function help() {
                return <<<ENDS
 Run this script to check the status of a specific language in extensions, or all of them.
@@ -400,13 +531,13 @@ Parameters:
        * First parameter (mandatory): Extension name, multiple extension names (separated by commas), "all" for all the extensions or "wikimedia" for extensions used by Wikimedia.
        * lang: Language code (default: the installation default language).
        * help: Show this help.
-       * level: Show the following level (default: 2).
+       * level: Show the following display level (default: 2).
        * links: Link the message values (default off).
        * wikilang: For the links, what is the content language of the wiki to display the output in (default en).
        * whitelist: Do only the following checks (form: code,code).
        * blacklist: Do not perform the following checks (form: code,code).
        * duplicate: Additionally check for messages which are translated the same to English (default off).
-Check codes (ideally, all of them should result 0; all the checks are executed by default (except duplicate and language specific check blacklists in checkLanguage.inc):
+Check codes (ideally, all of them should result 0; all the checks are executed by default (except language-specific check blacklists in checkLanguage.inc):
        * 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.
@@ -426,10 +557,17 @@ Display levels (default: 2):
 ENDS;
        }
 
+       /**
+        * Execute the script.
+        */
        public function execute() {
                $this->doChecks();
        }
 
+       /**
+        * Check a language and show the results.
+        * @param $code The language code.
+        */
        protected function checkLanguage( $code ) {
                foreach( $this->extensions as $extension ) {
                        $this->L = $extension;
index f8553a1..7a4d3dd 100644 (file)
@@ -11,4 +11,9 @@ require_once( 'checkLanguage.inc' );
 require_once( 'languages.inc' );
 
 $cli = new CheckLanguageCLI( $options );
-$cli->execute();
+
+try {
+       $cli->execute();
+} catch( MWException $e ) {
+       print 'Error: ' . $e->getMessage() . "\n";
+}
index 1a20f6e..66ebf82 100644 (file)
  */
 class languages {
        protected $mLanguages; # List of languages
+
        protected $mRawMessages; # Raw list of the messages in each language
        protected $mMessages; # Messages in each language (except for English), divided to groups
        protected $mGeneralMessages; # General messages in English, divided to groups
        protected $mIgnoredMessages; # All the messages which should be exist only in the English file
        protected $mOptionalMessages; # All the messages which may be translated or not, depending on the language
 
+       protected $mNamespaceNames; # Namespace names
+       protected $mNamespaceAliases; # Namespace aliases
+       protected $mSkinNames; # Skin names
+       protected $mMagicWords; # Magic words
+       protected $mSpecialPageAliases; # Special page aliases
+
        /**
         * Load the list of languages: all the Messages*.php
         * files in the languages directory.
@@ -64,24 +71,46 @@ class languages {
        }
 
        /**
-        * Load the raw messages for a specific language from the messages file.
+        * Load the language file.
         *
         * @param $code The language code.
         */
-       protected function loadRawMessages( $code ) {
-               if ( isset( $this->mRawMessages[$code] ) ) {
+       protected function loadFile( $code ) {
+               if ( isset( $this->mRawMessages[$code] ) &&
+                       isset( $this->mNamespaceNames[$code] ) &&
+                       isset( $this->mNamespaceAliases[$code] ) &&
+                       isset( $this->mSkinNames[$code] ) &&
+                       isset( $this->mMagicWords[$code] ) &&
+                       isset( $this->mSpecialPageAliases[$code] ) ) {
                        return;
                }
+               $this->mRawMessages[$code] = array();
+               $this->mNamespaceNames[$code] = array();
+               $this->mNamespaceAliases[$code] = array();
+               $this->mSkinNames[$code] = array();
+               $this->mMagicWords[$code] = array();
+               $this->mSpecialPageAliases[$code] = array();
                $filename = Language::getMessagesFileName( $code );
                if ( file_exists( $filename ) ) {
                        require( $filename );
                        if ( isset( $messages ) ) {
                                $this->mRawMessages[$code] = $messages;
-                       } else {
-                               $this->mRawMessages[$code] = array();
                        }
-               } else {
-                       $this->mRawMessages[$code] = array();
+                       if ( isset( $namespaceNames ) ) {
+                               $this->mNamespaceNames[$code] = $namespaceNames;
+                       }
+                       if ( isset( $namespaceAliases ) ) {
+                               $this->mNamespaceAliases[$code] = $namespaceAliases;
+                       }
+                       if ( isset( $skinNames ) ) {
+                               $this->mSkinNames[$code] = $skinNames;
+                       }
+                       if ( isset( $magicWords ) ) {
+                               $this->mMagicWords[$code] = $magicWords;
+                       }
+                       if ( isset( $specialPageAliases ) ) {
+                               $this->mSpecialPageAliases[$code] = $specialPageAliases;
+                       }
                }
        }
 
@@ -99,7 +128,7 @@ class languages {
                if ( isset( $this->mMessages[$code] ) ) {
                        return;
                }
-               $this->loadRawMessages( $code );
+               $this->loadFile( $code );
                $this->loadGeneralMessages();
                $this->mMessages[$code]['all'] = $this->mRawMessages[$code];
                $this->mMessages[$code]['required'] = array();
@@ -131,7 +160,7 @@ class languages {
                if ( isset( $this->mGeneralMessages ) ) {
                        return;
                }
-               $this->loadRawMessages( 'en' );
+               $this->loadFile( 'en' );
                $this->mGeneralMessages['all'] = $this->mRawMessages['en'];
                $this->mGeneralMessages['required'] = array();
                $this->mGeneralMessages['optional'] = array();
@@ -183,6 +212,66 @@ class languages {
                return $this->mGeneralMessages;
        }
 
+       /**
+        * Get namespace names for a specific language.
+        *
+        * @param $code The language code.
+        *
+        * @return Namespace names.
+        */
+       public function getNamespaceNames( $code ) {
+               $this->loadFile( $code );
+               return $this->mNamespaceNames[$code];
+       }
+
+       /**
+        * Get namespace aliases for a specific language.
+        *
+        * @param $code The language code.
+        *
+        * @return Namespace aliases.
+        */
+       public function getNamespaceAliases( $code ) {
+               $this->loadFile( $code );
+               return $this->mNamespaceAliases[$code];
+       }
+
+       /**
+        * Get skin names for a specific language.
+        *
+        * @param $code The language code.
+        *
+        * @return Skin names.
+        */
+       public function getSkinNames( $code ) {
+               $this->loadFile( $code );
+               return $this->mSkinNames[$code];
+       }
+
+       /**
+        * Get magic words for a specific language.
+        *
+        * @param $code The language code.
+        *
+        * @return Magic words.
+        */
+       public function getMagicWords( $code ) {
+               $this->loadFile( $code );
+               return $this->mMagicWords[$code];
+       }
+
+       /**
+        * Get special page aliases for a specific language.
+        *
+        * @param $code The language code.
+        *
+        * @return Special page aliases.
+        */
+       public function getSpecialPageAliases( $code ) {
+               $this->loadFile( $code );
+               return $this->mSpecialPageAliases[$code];
+       }
+
        /**
         * Get the untranslated messages for a specific language.
         *
@@ -193,13 +282,7 @@ class languages {
        public function getUntranslatedMessages( $code ) {
                $this->loadGeneralMessages();
                $this->loadMessages( $code );
-               $requiredGeneralMessages = array_keys( $this->mGeneralMessages['required'] );
-               $requiredMessages = array_keys( $this->mMessages[$code]['required'] );
-               $untranslatedMessages = array();
-               foreach ( array_diff( $requiredGeneralMessages, $requiredMessages ) as $key ) {
-                       $untranslatedMessages[$key] = $this->mGeneralMessages['required'][$key];
-               }
-               return $untranslatedMessages;
+               return array_diff_key( $this->mGeneralMessages['required'], $this->mMessages[$code]['required'] );
        }
 
        /**
@@ -221,6 +304,13 @@ class languages {
                return $duplicateMessages;
        }
 
+       /**
+        * Get the obsolete messages for a specific language.
+        *
+        * @param $code The language code.
+        *
+        * @return The obsolete messages for this language.
+        */
        public function getObsoleteMessages( $code ) {
                $this->loadGeneralMessages();
                $this->loadMessages( $code );
@@ -376,6 +466,13 @@ class languages {
                return $wrongCharsMessages;
        }
 
+       /**
+        * Get the messages which include dubious links.
+        *
+        * @param $code The language code.
+        *
+        * @return The messages which include dubious links in this language.
+        */
        public function getMessagesWithDubiousLinks( $code ) {
                $this->loadGeneralMessages();
                $this->loadMessages( $code );
@@ -383,9 +480,9 @@ class languages {
                $messages = array();
                foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
                        $matches = array();
-                       preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches);
+                       preg_match_all( "/\[\[([{$tc}]+)(?:\\|(.+?))?]]/sDu", $value, $matches );
                        for ($i = 0; $i < count($matches[0]); $i++ ) {
-                               if ( preg_match( "/.*project.*/isDu",  $matches[1][$i]) ) {
+                               if ( preg_match( "/.*project.*/isDu",  $matches[1][$i] ) ) {
                                        $messages[$key][] = $matches[0][$i];
                                }
                        }
@@ -398,19 +495,33 @@ class languages {
                return $messages;
        }
 
+       /**
+        * Get the messages which include unbalanced brackets.
+        *
+        * @param $code The language code.
+        *
+        * @return The messages which include unbalanced brackets in this language.
+        */
        public function getMessagesWithUnbalanced( $code ) {
                $this->loadGeneralMessages();
                $this->loadMessages( $code );
                $messages = array();
                foreach ( $this->mMessages[$code]['translated'] as $key => $value ) {
-
                        $a = $b = $c = $d = 0;
-                       foreach ( preg_split('//', $value) as $char ) {
-                               switch ($char) {
-                                       case '[': $a++; break;
-                                       case ']': $b++; break;
-                                       case '{': $c++; break;
-                                       case '}': $d++; break;
+                       foreach ( preg_split( '//', $value ) as $char ) {
+                               switch ( $char ) {
+                                       case '[':
+                                               $a++;
+                                               break;
+                                       case ']':
+                                               $b++;
+                                               break;
+                                       case '{':
+                                               $c++;
+                                               break;
+                                       case '}':
+                                               $d++;
+                                               break;
                                }
                        }
 
@@ -422,6 +533,142 @@ class languages {
                return $messages;
        }
 
+       /**
+        * Get the untranslated namespace names.
+        *
+        * @param $code The language code.
+        *
+        * @return The untranslated namespace names in this language.
+        */
+       public function getUntranslatedNamespaces( $code ) {
+               $this->loadFile( 'en' );
+               $this->loadFile( $code );
+               return array_flip( array_diff_key( $this->mNamespaceNames['en'], $this->mNamespaceNames[$code] ) );
+       }
+
+       /**
+        * Get the project talk namespace names with no $1.
+        *
+        * @param $code The language code.
+        *
+        * @return The problematic project talk namespaces in this language.
+        */
+       public function getProblematicProjectTalks( $code ) {
+               $this->loadFile( $code );
+               $namespaces = array();
+
+               # Check default namespace name
+               if( isset( $this->mNamespaceNames[$code][NS_PROJECT_TALK] ) ) {
+                       $default = $this->mNamespaceNames[$code][NS_PROJECT_TALK];
+                       if ( strpos( $default, '$1' ) === FALSE ) {
+                               $namespaces[$default] = 'default';
+                       }
+               }
+
+               # Check namespace aliases
+               foreach( $this->mNamespaceAliases[$code] as $key => $value ) {
+                       if ( $value == NS_PROJECT_TALK && strpos( $key, '$1' ) === FALSE ) {
+                               $namespaces[$key] = '';
+                       }
+               }
+
+               return $namespaces;
+       }
+
+       /**
+        * Get the untranslated skin names.
+        *
+        * @param $code The language code.
+        *
+        * @return The untranslated skin names in this language.
+        */
+       public function getUntranslatedSkins( $code ) {
+               $this->loadFile( 'en' );
+               $this->loadFile( $code );
+               return array_diff_key( $this->mSkinNames['en'], $this->mSkinNames[$code] );
+       }
+
+       /**
+        * Get the untranslated magic words.
+        *
+        * @param $code The language code.
+        *
+        * @return The untranslated magic words in this language.
+        */
+       public function getUntranslatedMagicWords( $code ) {
+               $this->loadFile( 'en' );
+               $this->loadFile( $code );
+               $magicWords = array();
+               foreach ( $this->mMagicWords['en'] as $key => $value ) {
+                       if ( !isset( $this->mMagicWords[$code][$key] ) ) {
+                               $magicWords[$key] = $value[1];
+                       }
+               }
+               return $magicWords;
+       }
+
+       /**
+        * Get the magic words that override the original English magic word.
+        *
+        * @param $code The language code.
+        *
+        * @return The overriding magic words in this language.
+        */
+       public function getOverridingMagicWords( $code ) {
+               $this->loadFile( 'en' );
+               $this->loadFile( $code );
+               $magicWords = array();
+               foreach ( $this->mMagicWords[$code] as $key => $local ) {
+                       $en = $this->mMagicWords['en'][$key];
+                       array_shift( $local );
+                       array_shift( $en );
+                       foreach ( $en as $word ) {
+                               if ( !in_array( $word, $local ) ) {
+                                       $magicWords[$key] = $word;
+                                       break;
+                               }
+                       }
+               }
+               return $magicWords;
+       }
+
+       /**
+        * Get the magic words which do not match the case-sensitivity of the original words.
+        *
+        * @param $code The language code.
+        *
+        * @return The magic words whose case does not match in this language.
+        */
+       public function getCaseMismatchMagicWords( $code ) {
+               $this->loadFile( 'en' );
+               $this->loadFile( $code );
+               $magicWords = array();
+               foreach ( $this->mMagicWords[$code] as $key => $local ) {
+                       if ( $local[0] != $this->mMagicWords['en'][$key][0] ) {
+                               $magicWords[$key] = $local[0];
+                       }
+               }
+               return $magicWords;
+       }
+
+       /**
+        * Get the untranslated special page names.
+        *
+        * @param $code The language code.
+        *
+        * @return The untranslated special page names in this language.
+        */
+       public function getUntraslatedSpecialPages( $code ) {
+               $this->loadFile( 'en' );
+               $this->loadFile( $code );
+               $specialPageAliases = array();
+               foreach ( $this->mSpecialPageAliases['en'] as $key => $value ) {
+                       if ( !isset( $this->mSpecialPageAliases[$code][$key] ) ) {
+                               $specialPageAliases[$key] = $value[0];
+                       }
+               }
+               return $specialPageAliases;
+       }
 }
 
 class extensionLanguages extends languages {
@@ -449,11 +696,11 @@ class extensionLanguages extends languages {
        }
 
        /**
-        * Load the raw messages for a specific language.
+        * Load the language file.
         *
         * @param $code The language code.
         */
-       protected function loadRawMessages( $code ) {
+       protected function loadFile( $code ) {
                if( !isset( $this->mRawMessages[$code] ) ) {
                        $this->mRawMessages[$code] = $this->mMessageGroup->load( $code );
                        if( empty( $this->mRawMessages[$code] ) ) {