Fix those spaces too from r71596/r71592
[lhc/web/wiklou.git] / languages / Language.php
index 3056143..71793e2 100644 (file)
@@ -1,11 +1,15 @@
 <?php
 /**
- * @defgroup Language Language
+ * Internationalisation code
  *
  * @file
  * @ingroup Language
  */
 
+/**
+ * @defgroup Language Language
+ */
+
 if ( !defined( 'MEDIAWIKI' ) ) {
        echo "This file is part of MediaWiki, it is not a valid entry point.\n";
        exit( 1 );
@@ -35,7 +39,7 @@ if ( function_exists( 'mb_strtoupper' ) ) {
 class FakeConverter {
        var $mLang;
        function FakeConverter( $langobj ) { $this->mLang = $langobj; }
-       function autoConvertToAllVariants( $text ) { return $text; }
+       function autoConvertToAllVariants( $text ) { return array( $this->mLang->getCode() => $text ); }
        function convert( $t ) { return $t; }
        function convertTitle( $t ) { return $t->getPrefixedText(); }
        function getVariants() { return array( $this->mLang->getCode() ); }
@@ -46,7 +50,7 @@ class FakeConverter {
        function getParsedTitle() { return ''; }
        function markNoConversion( $text, $noParse = false ) { return $text; }
        function convertCategoryKey( $key ) { return $key; }
-       function convertLinkToAllVariants( $text ) { return array( $this->mLang->getCode() => $text ); }
+       function convertLinkToAllVariants( $text ) { return autoConvertToAllVariants( $text ); }
        function armourMath( $text ) { return $text; }
 }
 
@@ -241,12 +245,12 @@ class Language {
         */
        function getNamespaces() {
                if ( is_null( $this->namespaceNames ) ) {
-                       global $wgExtraNamespaces, $wgMetaNamespace, $wgMetaNamespaceTalk;
+                       global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
 
                        $this->namespaceNames = self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
-                       if ( $wgExtraNamespaces ) {
-                               $this->namespaceNames = $wgExtraNamespaces + $this->namespaceNames;
-                       }
+                       $validNamespaces = MWNamespace::getCanonicalNamespaces();
+
+                       $this->namespaceNames = $wgExtraNamespaces + $this->namespaceNames + $validNamespaces;
 
                        $this->namespaceNames[NS_PROJECT] = $wgMetaNamespace;
                        if ( $wgMetaNamespaceTalk ) {
@@ -258,11 +262,10 @@ class Language {
                        }
                        
                        # Sometimes a language will be localised but not actually exist on this wiki.
-                       $validNamespaces = MWNamespace::getValidNamespaces();
                        foreach( $this->namespaceNames as $key => $text ) {
-                               if ( ! in_array( $key, $validNamespaces ) ) {
-                                       unset( $this->namespaceNames[$key] );
-                               }
+                               if ( !isset( $validNamespaces[$key] ) ) {
+                                       unset( $this->namespaceNames[$key] );
+                               }
                        }
 
                        # The above mixing may leave namespaces out of canonical order.