http://www.mediawiki.org/wiki/Special:Code/MediaWiki/70187

Revision: 70187
Author:   philip
Date:     2010-07-30 01:49:15 +0000 (Fri, 30 Jul 2010)

Log Message:
-----------
Merge r69080, r69081, r69085, r69086 from trunk: bug fixes of Language 
Converter.

Modified Paths:
--------------
    branches/REL1_16/phase3/includes/Title.php
    branches/REL1_16/phase3/languages/LanguageConverter.php
    branches/REL1_16/phase3/languages/classes/LanguageGan.php
    branches/REL1_16/phase3/languages/classes/LanguageZh.php
    branches/REL1_16/phase3/maintenance/parserTests.txt

Modified: branches/REL1_16/phase3/includes/Title.php
===================================================================
--- branches/REL1_16/phase3/includes/Title.php  2010-07-30 01:20:50 UTC (rev 
70186)
+++ branches/REL1_16/phase3/includes/Title.php  2010-07-30 01:49:15 UTC (rev 
70187)
@@ -2606,9 +2606,8 @@
                // purge variant urls as well
                if($wgContLang->hasVariants()){
                        $variants = $wgContLang->getVariants();
-                       foreach($variants as $vCode){
-                               if($vCode==$wgContLang->getCode()) continue; // 
we don't want default variant
-                               $urls[] = $this->getInternalURL('',$vCode);
+                       foreach ( $variants as $vCode ) {
+                               $urls[] = $this->getInternalURL( '', $vCode );
                        }
                }
 

Modified: branches/REL1_16/phase3/languages/LanguageConverter.php
===================================================================
--- branches/REL1_16/phase3/languages/LanguageConverter.php     2010-07-30 
01:20:50 UTC (rev 70186)
+++ branches/REL1_16/phase3/languages/LanguageConverter.php     2010-07-30 
01:49:15 UTC (rev 70187)
@@ -20,7 +20,6 @@
        var $mVariants, $mVariantFallbacks, $mVariantNames;
        var $mTablesLoaded = false;
        var $mTables;
-       var $mNamespaceTables;
        // 'bidirectional' 'unidirectional' 'disable' for each variant
        var $mManualLevel;
        var $mCacheKey;
@@ -87,7 +86,6 @@
                        } else {
                                $this->mManualLevel[$v] = 'bidirectional';
                        }
-                       $this->mNamespaceTables[$v] = array();
                        $this->mFlags[$v] = $v;
                }
        }
@@ -492,9 +490,14 @@
         * @private
         */
        function applyManualConv( $convRule ) {
-               // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom
-               // conversion in title
-               $this->mConvRuleTitle = $convRule->getTitle();
+               // Use syntax -{T|zh-cn:TitleCN; zh-tw:TitleTw}- to custom
+               // title conversion.
+               // Bug 24072: mConvRuleTitle won't work if the title conversion
+               // rule was followed by other manual conversion rule(s).
+               $newConvRuleTitle = $convRule->getTitle();
+               if( $newConvRuleTitle ) {
+                       $this->mConvRuleTitle = $newConvRuleTitle;
+               }
 
                // apply manual conversion table to global table
                $convTable = $convRule->getConvTable();
@@ -547,12 +550,19 @@
         */
        public function convertTitle( $title ) {
                $variant = $this->getPreferredVariant();
-               if ( $title->getNamespace() === NS_MAIN ) {
+               $index = $title->getNamespace();
+               if ( $index === NS_MAIN ) {
                        $text = '';
                } else {
-                       $text = $title->getNsText();
-                       if ( isset( $this->mNamespaceTables[$variant][$text] ) 
) {
-                               $text = 
$this->mNamespaceTables[$variant][$text];
+                       // first let's check if a message has given us a 
converted name
+                       $nsConvKey = 'conversion-ns' . $index;
+                       if ( !wfEmptyMsg( $nsConvKey ) ) {
+                               $text = wfMsgForContentNoTrans( $nsConvKey );
+                       } else {
+                               // the message does not exist, try retrieve it 
from the current
+                               // variant's namespace names.
+                               $langObj = $this->mLangObj->factory( $variant );
+                               $text = $langObj->getFormattedNsText( $index );
                        }
                        $text .= ':';
                }

Modified: branches/REL1_16/phase3/languages/classes/LanguageGan.php
===================================================================
--- branches/REL1_16/phase3/languages/classes/LanguageGan.php   2010-07-30 
01:20:50 UTC (rev 70186)
+++ branches/REL1_16/phase3/languages/classes/LanguageGan.php   2010-07-30 
01:49:15 UTC (rev 70187)
@@ -26,48 +26,7 @@
                        'gan-hant' => '繁體',
                );
                $this->mVariantNames = array_merge($this->mVariantNames,$names);
-               $this->loadNamespaceTables();
        }
-       
-       function loadNamespaceTables() {
-               global $wgMetaNamespace;
-               $nsproject     = $wgMetaNamespace;
-               $projecttable  = array(
-                       'Wikipedia'       => '维基百科',
-                       'Wikisource'      => '维基文库',
-                       'Wikinews'        => '维基新闻',
-                       'Wiktionary'      => '维基词典',
-                       'Wikibooks'       => '维基教科书',
-                       'Wikiquote'       => '维基语录',
-               );
-               $this->mNamespaceTables['gan-hans'] = array(
-                       'Media'          => '媒体',
-                       'Special'        => '特殊',
-                       'Talk'           => '談詑',
-                       'User'           => '用户',
-                       'User talk'      => '用户談詑',
-                       $nsproject
-                                       => isset($projecttable[$nsproject]) ? 
-                                               $projecttable[$nsproject] : 
$nsproject,
-                       $nsproject . ' talk'
-                                       => isset($projecttable[$nsproject]) ?
-                                               $projecttable[$nsproject] . 
'談詑' : $nsproject . '談詑',
-                       'File'           => '文件',
-                       'File talk'      => '文件談詑',
-                       'MediaWiki'      => 'MediaWiki',
-                       'MediaWiki talk' => 'MediaWiki談詑',
-                       'Template'       => '模板',
-                       'Template talk'  => '模板談詑',
-                       'Help'           => '帮助',
-                       'Help talk'      => '帮助談詑',
-                       'Category'       => '分类',
-                       'Category talk'  => '分类談詑',
-               );
-               $this->mNamespaceTables['gan-hant'] = 
array_merge($this->mNamespaceTables['gan-hans']);
-               $this->mNamespaceTables['gan-hant']['File'] = '檔案';
-               $this->mNamespaceTables['gan-hant']['File talk'] = '檔案談詑';
-               $this->mNamespaceTables['gan'] = 
array_merge($this->mNamespaceTables['gan-hans']);
-       }
 
        function loadDefaultTables() {
                require( dirname(__FILE__)."/../../includes/ZhConversion.php" );

Modified: branches/REL1_16/phase3/languages/classes/LanguageZh.php
===================================================================
--- branches/REL1_16/phase3/languages/classes/LanguageZh.php    2010-07-30 
01:20:50 UTC (rev 70186)
+++ branches/REL1_16/phase3/languages/classes/LanguageZh.php    2010-07-30 
01:49:15 UTC (rev 70187)
@@ -32,54 +32,7 @@
                        'zh-my'   => '大马',
                );
                $this->mVariantNames = array_merge($this->mVariantNames,$names);
-               $this->loadNamespaceTables();
        }
-       
-       function loadNamespaceTables() {
-               global $wgMetaNamespace;
-               $nsproject     = $wgMetaNamespace;
-               $projecttable  = array(
-                       'Wikipedia'       => '维基百科',
-                       'Wikisource'      => '维基文库',
-                       'Wikinews'        => '维基新闻',
-                       'Wiktionary'      => '维基词典',
-                       'Wikibooks'       => '维基教科书',
-                       'Wikiquote'       => '维基语录',
-               );
-               $this->mNamespaceTables['zh-hans'] = array(
-                       'Media'          => '媒体',
-                       'Special'        => '特殊',
-                       'Talk'           => '讨论',
-                       'User'           => '用户',
-                       'User talk'      => '用户讨论',
-                       $nsproject
-                                       => isset($projecttable[$nsproject]) ? 
-                                               $projecttable[$nsproject] : 
$nsproject,
-                       $nsproject . ' talk'
-                                       => isset($projecttable[$nsproject]) ?
-                                               $projecttable[$nsproject] . 
'讨论' : $nsproject . '讨论',
-                       'File'           => '文件',
-                       'File talk'      => '文件讨论',
-                       'MediaWiki'      => 'MediaWiki',
-                       'MediaWiki talk' => 'MediaWiki讨论',
-                       'Template'       => '模板',
-                       'Template talk'  => '模板讨论',
-                       'Help'           => '帮助',
-                       'Help talk'      => '帮助讨论',
-                       'Category'       => '分类',
-                       'Category talk'  => '分类讨论',
-               );
-               $this->mNamespaceTables['zh-hant'] = 
array_merge($this->mNamespaceTables['zh-hans']);
-               $this->mNamespaceTables['zh-hant']['File'] = '檔案';
-               $this->mNamespaceTables['zh-hant']['File talk'] = '檔案討論';
-               $this->mNamespaceTables['zh'] = 
array_merge($this->mNamespaceTables['zh-hans']);
-               $this->mNamespaceTables['zh-cn'] = 
array_merge($this->mNamespaceTables['zh-hans']);
-               $this->mNamespaceTables['zh-hk'] = 
array_merge($this->mNamespaceTables['zh-hant']);
-               $this->mNamespaceTables['zh-mo'] = 
array_merge($this->mNamespaceTables['zh-hant']);
-               $this->mNamespaceTables['zh-my'] = 
array_merge($this->mNamespaceTables['zh-hans']);
-               $this->mNamespaceTables['zh-sg'] = 
array_merge($this->mNamespaceTables['zh-hans']);
-               $this->mNamespaceTables['zh-tw'] = 
array_merge($this->mNamespaceTables['zh-hant']);
-       }
 
        function loadDefaultTables() {
                require( dirname(__FILE__)."/../../includes/ZhConversion.php" );

Modified: branches/REL1_16/phase3/maintenance/parserTests.txt
===================================================================
--- branches/REL1_16/phase3/maintenance/parserTests.txt 2010-07-30 01:20:50 UTC 
(rev 70186)
+++ branches/REL1_16/phase3/maintenance/parserTests.txt 2010-07-30 01:49:15 UTC 
(rev 70187)
@@ -7018,6 +7018,20 @@
 !! end
 
 !! test
+Bug 24072: more test on conversion rule for title
+!! options
+language=zh variant=zh-tw showtitle
+!! input
+This should be stripped-{T|zh:China;zh-tw:Taiwan}-!
+This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-.
+!! result
+Taiwan
+<p>This should be stripped!
+This won't take interferes with the title rule.
+</p>
+!! end
+
+!! test
 Raw output of variant escape tags (R flag)
 !! options
 language=zh variant=zh-tw



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to