Full conversion support for category pages
authorZheng Zhu <zhengzhu@users.mediawiki.org>
Thu, 28 Apr 2005 03:33:54 +0000 (03:33 +0000)
committerZheng Zhu <zhengzhu@users.mediawiki.org>
Thu, 28 Apr 2005 03:33:54 +0000 (03:33 +0000)
RELEASE-NOTES
includes/CategoryPage.php
includes/Parser.php
languages/Language.php
languages/LanguageZh.php

index 392ea43..6a93791 100644 (file)
@@ -30,6 +30,7 @@ New exciting things! Need further work and testing...
 * No longer using sorbs.net to check for open proxies by default.
 * What was $wgDisableUploads is now $wgEnableUploads, and should be set to true if one wishes to enable uploads.
 * Supplying a reason for a block is no longer mandatory
+* Language conversion support for category pages
 * ...and more!
 
 Need to merge:
index b90cb33..c1865de 100644 (file)
@@ -116,17 +116,19 @@ class CategoryPage extends Article {
                        
                        if( $title->getNamespace() == NS_CATEGORY ) {
                                // Subcategory; strip the 'Category' namespace from the link text.
-                               array_push( $children, $sk->makeKnownLinkObj( $title, $title->getText() ) );
+                               array_push( $children, $sk->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ) );
                                
                                // If there's a link from Category:A to Category:B, the sortkey of the resulting
                                // entry in the categorylinks table is Category:A, not A, which it SHOULD be.
                                // Workaround: If sortkey == "Category:".$title, than use $title for sorting,
                                // else use sortkey...
+                               $sortkey='';
                                if( $title->getPrefixedText() == $x->cl_sortkey ) {
-                                       array_push( $children_start_char, $wgContLang->firstChar( $x->page_title ) );
+                                       $sortkey=$wgContLang->firstChar( $x->page_title );
                                } else {
-                                       array_push( $children_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
+                                       $sortkey=$wgContLang->firstChar( $x->cl_sortkey );
                                }
+                               array_push( $children_start_char, $wgContLang->convert( $sortkey ) ) ;
                        } elseif( $wgCategoryMagicGallery && $title->getNamespace() == NS_IMAGE ) {
                                // Show thumbnails of categorized images, in a separate chunk
                                if( $flip ) {
@@ -136,8 +138,8 @@ class CategoryPage extends Article {
                                }
                        } else {
                                // Page in this category
-                               array_push( $articles, $sk->makeKnownLinkObj( $title ) ) ;
-                               array_push( $articles_start_char, $wgContLang->firstChar( $x->cl_sortkey ) ) ;
+                               array_push( $articles, $sk->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ) ) ;
+                               array_push( $articles_start_char, $wgContLang->convert( $wgContLang->firstChar( $x->cl_sortkey ) ) );
                        }
                }
                $dbr->freeResult( $res );
index 3cba239..13ce1ca 100644 (file)
@@ -1357,6 +1357,7 @@ class Parser
                                        } else {
                                                $sortkey = $text;
                                        }
+                                       $sortkey = $wgContLang->convertCategoryKey( $sortkey );
                                        $wgLinkCache->addCategoryLinkObj( $nt, $sortkey );
                                        $this->mOutput->addCategoryLink( $t );
                                        
index d654fad..1460693 100644 (file)
@@ -1902,6 +1902,8 @@ class fakeConverter {
        function getExtraHashOptions() {return '';}
        function getParsedTitle() {return '';}
        function markNoConversion($text) {return $text;}
+       function convertCategoryKey( $key ) {return $key; }
+
 }
 
 #--------------------------------------------------------------------------
@@ -2532,6 +2534,10 @@ class Language {
                return $this->mConverter->convert($text, $isTitle);
        }
 
+       function convertCategoryKey( $key ) {
+               return $this->mConverter->convertCategoryKey( $key );
+       }
+
        /**
         * get the list of variants supported by this langauge
         * see sample implementation in LanguageZh.php
index c8b34f9..f7f3255 100644 (file)
@@ -31,6 +31,10 @@ class ZhConverter extends LanguageConverter {
        function markNoConversion($text) {
                return $text;
        }
+
+       function convertCategoryKey( $key ) {
+               return $this->autoConvert( $key, 'zh-cn' ); 
+       }
 }