From ff1e0c05815411d6b513dc5cfe1d49cf5362e064 Mon Sep 17 00:00:00 2001 From: Zheng Zhu Date: Thu, 28 Apr 2005 03:33:54 +0000 Subject: [PATCH] Full conversion support for category pages --- RELEASE-NOTES | 1 + includes/CategoryPage.php | 12 +++++++----- includes/Parser.php | 1 + languages/Language.php | 6 ++++++ languages/LanguageZh.php | 4 ++++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 392ea435e3..6a937911ff 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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: diff --git a/includes/CategoryPage.php b/includes/CategoryPage.php index b90cb3361e..c1865de069 100644 --- a/includes/CategoryPage.php +++ b/includes/CategoryPage.php @@ -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 ); diff --git a/includes/Parser.php b/includes/Parser.php index 3cba2393aa..13ce1ca759 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1357,6 +1357,7 @@ class Parser } else { $sortkey = $text; } + $sortkey = $wgContLang->convertCategoryKey( $sortkey ); $wgLinkCache->addCategoryLinkObj( $nt, $sortkey ); $this->mOutput->addCategoryLink( $t ); diff --git a/languages/Language.php b/languages/Language.php index d654fad677..1460693f8e 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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 diff --git a/languages/LanguageZh.php b/languages/LanguageZh.php index c8b34f9608..f7f3255fdd 100644 --- a/languages/LanguageZh.php +++ b/languages/LanguageZh.php @@ -31,6 +31,10 @@ class ZhConverter extends LanguageConverter { function markNoConversion($text) { return $text; } + + function convertCategoryKey( $key ) { + return $this->autoConvert( $key, 'zh-cn' ); + } } -- 2.20.1