Index: branches/REL1_16/phase3/maintenance/parserTests.txt |
— | — | @@ -7018,6 +7018,20 @@ |
7019 | 7019 | !! end |
7020 | 7020 | |
7021 | 7021 | !! test |
| 7022 | +Bug 24072: more test on conversion rule for title |
| 7023 | +!! options |
| 7024 | +language=zh variant=zh-tw showtitle |
| 7025 | +!! input |
| 7026 | +This should be stripped-{T|zh:China;zh-tw:Taiwan}-! |
| 7027 | +This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-. |
| 7028 | +!! result |
| 7029 | +Taiwan |
| 7030 | +<p>This should be stripped! |
| 7031 | +This won't take interferes with the title rule. |
| 7032 | +</p> |
| 7033 | +!! end |
| 7034 | + |
| 7035 | +!! test |
7022 | 7036 | Raw output of variant escape tags (R flag) |
7023 | 7037 | !! options |
7024 | 7038 | language=zh variant=zh-tw |
Index: branches/REL1_16/phase3/includes/Title.php |
— | — | @@ -2606,9 +2606,8 @@ |
2607 | 2607 | // purge variant urls as well |
2608 | 2608 | if($wgContLang->hasVariants()){ |
2609 | 2609 | $variants = $wgContLang->getVariants(); |
2610 | | - foreach($variants as $vCode){ |
2611 | | - if($vCode==$wgContLang->getCode()) continue; // we don't want default variant |
2612 | | - $urls[] = $this->getInternalURL('',$vCode); |
| 2610 | + foreach ( $variants as $vCode ) { |
| 2611 | + $urls[] = $this->getInternalURL( '', $vCode ); |
2613 | 2612 | } |
2614 | 2613 | } |
2615 | 2614 | |
Index: branches/REL1_16/phase3/languages/LanguageConverter.php |
— | — | @@ -20,7 +20,6 @@ |
21 | 21 | var $mVariants, $mVariantFallbacks, $mVariantNames; |
22 | 22 | var $mTablesLoaded = false; |
23 | 23 | var $mTables; |
24 | | - var $mNamespaceTables; |
25 | 24 | // 'bidirectional' 'unidirectional' 'disable' for each variant |
26 | 25 | var $mManualLevel; |
27 | 26 | var $mCacheKey; |
— | — | @@ -87,7 +86,6 @@ |
88 | 87 | } else { |
89 | 88 | $this->mManualLevel[$v] = 'bidirectional'; |
90 | 89 | } |
91 | | - $this->mNamespaceTables[$v] = array(); |
92 | 90 | $this->mFlags[$v] = $v; |
93 | 91 | } |
94 | 92 | } |
— | — | @@ -492,9 +490,14 @@ |
493 | 491 | * @private |
494 | 492 | */ |
495 | 493 | function applyManualConv( $convRule ) { |
496 | | - // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom |
497 | | - // conversion in title |
498 | | - $this->mConvRuleTitle = $convRule->getTitle(); |
| 494 | + // Use syntax -{T|zh-cn:TitleCN; zh-tw:TitleTw}- to custom |
| 495 | + // title conversion. |
| 496 | + // Bug 24072: mConvRuleTitle won't work if the title conversion |
| 497 | + // rule was followed by other manual conversion rule(s). |
| 498 | + $newConvRuleTitle = $convRule->getTitle(); |
| 499 | + if( $newConvRuleTitle ) { |
| 500 | + $this->mConvRuleTitle = $newConvRuleTitle; |
| 501 | + } |
499 | 502 | |
500 | 503 | // apply manual conversion table to global table |
501 | 504 | $convTable = $convRule->getConvTable(); |
— | — | @@ -547,12 +550,19 @@ |
548 | 551 | */ |
549 | 552 | public function convertTitle( $title ) { |
550 | 553 | $variant = $this->getPreferredVariant(); |
551 | | - if ( $title->getNamespace() === NS_MAIN ) { |
| 554 | + $index = $title->getNamespace(); |
| 555 | + if ( $index === NS_MAIN ) { |
552 | 556 | $text = ''; |
553 | 557 | } else { |
554 | | - $text = $title->getNsText(); |
555 | | - if ( isset( $this->mNamespaceTables[$variant][$text] ) ) { |
556 | | - $text = $this->mNamespaceTables[$variant][$text]; |
| 558 | + // first let's check if a message has given us a converted name |
| 559 | + $nsConvKey = 'conversion-ns' . $index; |
| 560 | + if ( !wfEmptyMsg( $nsConvKey ) ) { |
| 561 | + $text = wfMsgForContentNoTrans( $nsConvKey ); |
| 562 | + } else { |
| 563 | + // the message does not exist, try retrieve it from the current |
| 564 | + // variant's namespace names. |
| 565 | + $langObj = $this->mLangObj->factory( $variant ); |
| 566 | + $text = $langObj->getFormattedNsText( $index ); |
557 | 567 | } |
558 | 568 | $text .= ':'; |
559 | 569 | } |
Index: branches/REL1_16/phase3/languages/classes/LanguageGan.php |
— | — | @@ -26,48 +26,7 @@ |
27 | 27 | 'gan-hant' => '繁體', |
28 | 28 | ); |
29 | 29 | $this->mVariantNames = array_merge($this->mVariantNames,$names); |
30 | | - $this->loadNamespaceTables(); |
31 | 30 | } |
32 | | - |
33 | | - function loadNamespaceTables() { |
34 | | - global $wgMetaNamespace; |
35 | | - $nsproject = $wgMetaNamespace; |
36 | | - $projecttable = array( |
37 | | - 'Wikipedia' => '维基百科', |
38 | | - 'Wikisource' => '维基文库', |
39 | | - 'Wikinews' => '维基新闻', |
40 | | - 'Wiktionary' => '维基词典', |
41 | | - 'Wikibooks' => '维基教科书', |
42 | | - 'Wikiquote' => '维基语录', |
43 | | - ); |
44 | | - $this->mNamespaceTables['gan-hans'] = array( |
45 | | - 'Media' => '媒体', |
46 | | - 'Special' => '特殊', |
47 | | - 'Talk' => '談詑', |
48 | | - 'User' => '用户', |
49 | | - 'User talk' => '用户談詑', |
50 | | - $nsproject |
51 | | - => isset($projecttable[$nsproject]) ? |
52 | | - $projecttable[$nsproject] : $nsproject, |
53 | | - $nsproject . ' talk' |
54 | | - => isset($projecttable[$nsproject]) ? |
55 | | - $projecttable[$nsproject] . '談詑' : $nsproject . '談詑', |
56 | | - 'File' => '文件', |
57 | | - 'File talk' => '文件談詑', |
58 | | - 'MediaWiki' => 'MediaWiki', |
59 | | - 'MediaWiki talk' => 'MediaWiki談詑', |
60 | | - 'Template' => '模板', |
61 | | - 'Template talk' => '模板談詑', |
62 | | - 'Help' => '帮助', |
63 | | - 'Help talk' => '帮助談詑', |
64 | | - 'Category' => '分类', |
65 | | - 'Category talk' => '分类談詑', |
66 | | - ); |
67 | | - $this->mNamespaceTables['gan-hant'] = array_merge($this->mNamespaceTables['gan-hans']); |
68 | | - $this->mNamespaceTables['gan-hant']['File'] = '檔案'; |
69 | | - $this->mNamespaceTables['gan-hant']['File talk'] = '檔案談詑'; |
70 | | - $this->mNamespaceTables['gan'] = array_merge($this->mNamespaceTables['gan-hans']); |
71 | | - } |
72 | 31 | |
73 | 32 | function loadDefaultTables() { |
74 | 33 | require( dirname(__FILE__)."/../../includes/ZhConversion.php" ); |
Index: branches/REL1_16/phase3/languages/classes/LanguageZh.php |
— | — | @@ -32,54 +32,7 @@ |
33 | 33 | 'zh-my' => '大马', |
34 | 34 | ); |
35 | 35 | $this->mVariantNames = array_merge($this->mVariantNames,$names); |
36 | | - $this->loadNamespaceTables(); |
37 | 36 | } |
38 | | - |
39 | | - function loadNamespaceTables() { |
40 | | - global $wgMetaNamespace; |
41 | | - $nsproject = $wgMetaNamespace; |
42 | | - $projecttable = array( |
43 | | - 'Wikipedia' => '维基百科', |
44 | | - 'Wikisource' => '维基文库', |
45 | | - 'Wikinews' => '维基新闻', |
46 | | - 'Wiktionary' => '维基词典', |
47 | | - 'Wikibooks' => '维基教科书', |
48 | | - 'Wikiquote' => '维基语录', |
49 | | - ); |
50 | | - $this->mNamespaceTables['zh-hans'] = array( |
51 | | - 'Media' => '媒体', |
52 | | - 'Special' => '特殊', |
53 | | - 'Talk' => '讨论', |
54 | | - 'User' => '用户', |
55 | | - 'User talk' => '用户讨论', |
56 | | - $nsproject |
57 | | - => isset($projecttable[$nsproject]) ? |
58 | | - $projecttable[$nsproject] : $nsproject, |
59 | | - $nsproject . ' talk' |
60 | | - => isset($projecttable[$nsproject]) ? |
61 | | - $projecttable[$nsproject] . '讨论' : $nsproject . '讨论', |
62 | | - 'File' => '文件', |
63 | | - 'File talk' => '文件讨论', |
64 | | - 'MediaWiki' => 'MediaWiki', |
65 | | - 'MediaWiki talk' => 'MediaWiki讨论', |
66 | | - 'Template' => '模板', |
67 | | - 'Template talk' => '模板讨论', |
68 | | - 'Help' => '帮助', |
69 | | - 'Help talk' => '帮助讨论', |
70 | | - 'Category' => '分类', |
71 | | - 'Category talk' => '分类讨论', |
72 | | - ); |
73 | | - $this->mNamespaceTables['zh-hant'] = array_merge($this->mNamespaceTables['zh-hans']); |
74 | | - $this->mNamespaceTables['zh-hant']['File'] = '檔案'; |
75 | | - $this->mNamespaceTables['zh-hant']['File talk'] = '檔案討論'; |
76 | | - $this->mNamespaceTables['zh'] = array_merge($this->mNamespaceTables['zh-hans']); |
77 | | - $this->mNamespaceTables['zh-cn'] = array_merge($this->mNamespaceTables['zh-hans']); |
78 | | - $this->mNamespaceTables['zh-hk'] = array_merge($this->mNamespaceTables['zh-hant']); |
79 | | - $this->mNamespaceTables['zh-mo'] = array_merge($this->mNamespaceTables['zh-hant']); |
80 | | - $this->mNamespaceTables['zh-my'] = array_merge($this->mNamespaceTables['zh-hans']); |
81 | | - $this->mNamespaceTables['zh-sg'] = array_merge($this->mNamespaceTables['zh-hans']); |
82 | | - $this->mNamespaceTables['zh-tw'] = array_merge($this->mNamespaceTables['zh-hant']); |
83 | | - } |
84 | 37 | |
85 | 38 | function loadDefaultTables() { |
86 | 39 | require( dirname(__FILE__)."/../../includes/ZhConversion.php" ); |