r70187 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70186‎ | r70187 | r70188 >
Date:01:49, 30 July 2010
Author:philip
Status:deferred
Tags:
Comment:
Merge r69080, r69081, r69085, r69086 from trunk: bug fixes of Language Converter.
Modified paths:
  • /branches/REL1_16/phase3/includes/Title.php (modified) (history)
  • /branches/REL1_16/phase3/languages/LanguageConverter.php (modified) (history)
  • /branches/REL1_16/phase3/languages/classes/LanguageGan.php (modified) (history)
  • /branches/REL1_16/phase3/languages/classes/LanguageZh.php (modified) (history)
  • /branches/REL1_16/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: branches/REL1_16/phase3/maintenance/parserTests.txt
@@ -7018,6 +7018,20 @@
70197019 !! end
70207020
70217021 !! 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
70227036 Raw output of variant escape tags (R flag)
70237037 !! options
70247038 language=zh variant=zh-tw
Index: branches/REL1_16/phase3/includes/Title.php
@@ -2606,9 +2606,8 @@
26072607 // purge variant urls as well
26082608 if($wgContLang->hasVariants()){
26092609 $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 );
26132612 }
26142613 }
26152614
Index: branches/REL1_16/phase3/languages/LanguageConverter.php
@@ -20,7 +20,6 @@
2121 var $mVariants, $mVariantFallbacks, $mVariantNames;
2222 var $mTablesLoaded = false;
2323 var $mTables;
24 - var $mNamespaceTables;
2524 // 'bidirectional' 'unidirectional' 'disable' for each variant
2625 var $mManualLevel;
2726 var $mCacheKey;
@@ -87,7 +86,6 @@
8887 } else {
8988 $this->mManualLevel[$v] = 'bidirectional';
9089 }
91 - $this->mNamespaceTables[$v] = array();
9290 $this->mFlags[$v] = $v;
9391 }
9492 }
@@ -492,9 +490,14 @@
493491 * @private
494492 */
495493 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+ }
499502
500503 // apply manual conversion table to global table
501504 $convTable = $convRule->getConvTable();
@@ -547,12 +550,19 @@
548551 */
549552 public function convertTitle( $title ) {
550553 $variant = $this->getPreferredVariant();
551 - if ( $title->getNamespace() === NS_MAIN ) {
 554+ $index = $title->getNamespace();
 555+ if ( $index === NS_MAIN ) {
552556 $text = '';
553557 } 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 );
557567 }
558568 $text .= ':';
559569 }
Index: branches/REL1_16/phase3/languages/classes/LanguageGan.php
@@ -26,48 +26,7 @@
2727 'gan-hant' => '繁體',
2828 );
2929 $this->mVariantNames = array_merge($this->mVariantNames,$names);
30 - $this->loadNamespaceTables();
3130 }
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 - }
7231
7332 function loadDefaultTables() {
7433 require( dirname(__FILE__)."/../../includes/ZhConversion.php" );
Index: branches/REL1_16/phase3/languages/classes/LanguageZh.php
@@ -32,54 +32,7 @@
3333 'zh-my' => '大马',
3434 );
3535 $this->mVariantNames = array_merge($this->mVariantNames,$names);
36 - $this->loadNamespaceTables();
3736 }
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 - }
8437
8538 function loadDefaultTables() {
8639 require( dirname(__FILE__)."/../../includes/ZhConversion.php" );

Follow-up revisions

RevisionCommit summaryAuthorDate
r79923Bug 26642, follow up r70187: Fix the 1.16 namespace conversion bug which caus...philip02:43, 10 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r69080Bug 24072: The manual conversion of title was taken interferes by other manua...philip03:06, 6 July 2010
r690811. Fix the underline bug in the title(namespace) conversion, which displayed ...philip05:00, 6 July 2010
r69085Bug 24027: Variants like "zh" should get purged as others.philip06:59, 6 July 2010
r69086Follow up r69081. Use wfEmptyMsg() rather than the ugly comparison.philip07:29, 6 July 2010

Status & tagging log