Make the {{ns:}} core parser function accept localized namespace names and aliases...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 9 Oct 2008 00:56:26 +0000 (00:56 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Thu, 9 Oct 2008 00:56:26 +0000 (00:56 +0000)
instead of underscores so that it matches the output of {{NAMESPACE}} and related magic words.

RELEASE-NOTES
includes/parser/CoreParserFunctions.php

index 87523f4..dc89751 100644 (file)
@@ -158,6 +158,9 @@ The following extensions are migrated into MediaWiki 1.14:
   solutions such as CSS-based overlays and ImageMap.
 * (bug 368) Don't use caption for alt attribute; allow manual specification
   using new "alt=" parameter for images
+* (bug 44) The {{ns:}} core parser function now also accepts localized namespace
+  names and aliases; also, its output now uses spaces instead of underscores to
+  match the behavior of the {{NAMESPACE}} magic word
 
 === Bug fixes in 1.14 ===
 
index c60b74c..c496544 100644 (file)
@@ -68,20 +68,13 @@ class CoreParserFunctions {
 
        static function ns( $parser, $part1 = '' ) {
                global $wgContLang;
-               $found = false;
                if ( intval( $part1 ) || $part1 == "0" ) {
-                       $text = $wgContLang->getNsText( intval( $part1 ) );
-                       $found = true;
+                       $index = intval( $part1 );
                } else {
-                       $param = str_replace( ' ', '_', strtolower( $part1 ) );
-                       $index = MWNamespace::getCanonicalIndex( strtolower( $param ) );
-                       if ( !is_null( $index ) ) {
-                               $text = $wgContLang->getNsText( $index );
-                               $found = true;
-                       }
+                       $index = $wgContLang->getNsIndex( str_replace( ' ', '_', $part1 ) );
                }
-               if ( $found ) {
-                       return $text;
+               if ( $index !== false ) {
+                       return $wgContLang->getFormattedNsText( $index );
                } else {
                        return array( 'found' => false );
                }