r37297 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37296‎ | r37297 | r37298 >
Date:02:34, 8 July 2008
Author:shinjiman
Status:old
Tags:
Comment:
* tweak some -{}- parsings
* adding namespace aliases for the Chinese language (zh)
patches by fdcn
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -79,7 +79,7 @@
8080 }
8181
8282 /**
83 - * @access public
 83+ * @public
8484 */
8585 function getVariants() {
8686 return $this->mVariants;
@@ -107,7 +107,7 @@
108108 * get preferred language variants.
109109 * @param boolean $fromUser Get it from $wgUser's preferences
110110 * @return string the preferred language code
111 - * @access public
 111+ * @public
112112 */
113113 function getPreferredVariant( $fromUser = true ) {
114114 global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant;
@@ -325,7 +325,7 @@
326326 }
327327
328328 /**
329 - * @access private
 329+ * @private
330330 */
331331 function applyManualConv($convRule,$variant){
332332 if(!$variant) $variant = $this->getPreferredVariant();
@@ -337,7 +337,7 @@
338338 // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
339339 if($is_title_flag){
340340 $this->mTitleFromFlag = true;
341 - $this->mTitleDisplay = $convRule->getRulesTitle();
 341+ $this->mTitleDisplay = $convRule->getTitle();
342342 }
343343
344344 if($this->mManualLevel[$variant]=='disable') return;
@@ -426,7 +426,7 @@
427427 * @param string $text text to be converted
428428 * @param bool $isTitle whether this conversion is for the article title
429429 * @return string converted text
430 - * @access public
 430+ * @public
431431 */
432432 function convert( $text , $isTitle=false) {
433433
@@ -463,10 +463,10 @@
464464 $this->mVariantNames,
465465 $this->mDoContentConvert,
466466 $this->mDoTitleConvert);
467 - $crule->parseRules($plang,
 467+ $crule->parse($plang,
468468 $this->getVariantFallbacks($plang),
469469 $this->mManualLevel[$plang]=='disable');
470 - $text .= $crule->getRulesDisplay();
 470+ $text .= $crule->getDisplay();
471471 $this->applyManualConv($crule,$plang);
472472
473473 if(array_key_exists(1, $marked)){
@@ -489,7 +489,7 @@
490490 * @param string $link the name of the link
491491 * @param mixed $nt the title object of the link
492492 * @return null the input parameters may be modified upon return
493 - * @access public
 493+ * @public
494494 */
495495 function findVariantLink( &$link, &$nt ) {
496496 global $wgDisableLangConversion;
@@ -532,7 +532,7 @@
533533 /**
534534 * returns language specific hash options
535535 *
536 - * @access public
 536+ * @public
537537 */
538538 function getExtraHashOptions() {
539539 $variant = $this->getPreferredVariant();
@@ -542,7 +542,7 @@
543543 /**
544544 * get title text as defined in the body of the article text
545545 *
546 - * @access public
 546+ * @public
547547 */
548548 function getParsedTitle() {
549549 return $this->mTitleDisplay;
@@ -799,6 +799,7 @@
800800 }
801801
802802 /**
 803+ * parser for rules of language conversion , parse rules in -{ }- tag
803804 * @ingroup Language
804805 * @author fdcn <fdcn64@gmail.com>
805806 */
@@ -860,16 +861,14 @@
861862 * @private
862863 */
863864 function parseFlags(){
864 - $flags = array();
865865 $text = $this->mText;
866 -
867 - // for multi-FLAGs
868866 if(strlen($text) < 2 ) {
869867 $this->flags = array( 'R' );
870868 $this->rules = $text;
871869 return;
872870 }
873871
 872+ $flags = array();
874873 $tt = explode($this->mMarkup['flagsep'], $text, 2);
875874
876875 if(count($tt) == 2) {
@@ -1007,11 +1006,12 @@
10081007 return $this->rules;
10091008 }
10101009 }
 1010+
10111011 /**
10121012 * Parse rules and flags
10131013 * @public
10141014 */
1015 - function parseRules($variant,$variantFallbacks,$isMCDisable=false){
 1015+ function parse($variant,$variantFallbacks,$isMCDisable=false){
10161016 $this->parseFlags();
10171017 $this->generateConvTable();
10181018
@@ -1021,7 +1021,7 @@
10221022 if(count($this->bidtable)==0 && count($this->unidtable)==0
10231023 && !in_array('N',$flags) && !in_array('T',$flags) )
10241024 {
1025 - $flags = array('R');
 1025+ $this->flags = $flags = array('R');
10261026 }
10271027
10281028 if( in_array('R',$flags) ) {
@@ -1056,7 +1056,7 @@
10571057 * @param string $variant the current variant
10581058 * @public
10591059 */
1060 - function getRulesDisplay(){
 1060+ function getDisplay(){
10611061 return $this->ruleDisplay;
10621062 }
10631063 /**
@@ -1064,7 +1064,7 @@
10651065 * @param string $variant the current variant
10661066 * @public
10671067 */
1068 - function getRulesTitle(){
 1068+ function getTitle(){
10691069 return $this->ruleTitle;
10701070 }
10711071
Index: trunk/phase3/languages/messages/MessagesZh.php
@@ -10,6 +10,41 @@
1111
1212 $fallback = 'zh-hans';
1313
 14+$namespaceAliases = array(
 15+ '媒体' => NS_MEDIA,
 16+ '媒體' => NS_MEDIA,
 17+ '特殊' => NS_SPECIAL,
 18+ '对话' => NS_TALK,
 19+ '對話' => NS_TALK,
 20+ '讨论' => NS_TALK,
 21+ '討論' => NS_TALK,
 22+ '用户' => NS_USER,
 23+ '用戶' => NS_USER,
 24+ '用户对话' => NS_USER_TALK,
 25+ '用戶對話' => NS_USER_TALK,
 26+ '用户讨论' => NS_USER_TALK,
 27+ '用戶討論' => NS_USER_TALK,
 28+ # This has never worked so it's unlikely to annoy anyone if I disable it -- TS
 29+ #'{{SITENAME}}_对话' => NS_PROJECT_TALK
 30+ #"{{SITENAME}}_對話" => NS_PROJECT_TALK
 31+ '图像' => NS_IMAGE,
 32+ '圖像' => NS_IMAGE,
 33+ '图像对话' => NS_IMAGE_TALK,
 34+ '圖像對話' => NS_IMAGE_TALK,
 35+ '模板' => NS_TEMPLATE,
 36+ '模板讨论'=> NS_TEMPLATE_TALK,
 37+ "樣板" => NS_TEMPLATE,
 38+ "樣板討論" => NS_TEMPLATE_TALK,
 39+ '帮助' => NS_HELP,
 40+ '帮助讨论'=> NS_HELP_TALK,
 41+ "幫助" => NS_HELP,
 42+ "幫助討論" => NS_HELP_TALK,
 43+ '分类' => NS_CATEGORY,
 44+ '分类讨论'=> NS_CATEGORY_TALK,
 45+ "分類" => NS_CATEGORY,
 46+ "分類討論" => NS_CATEGORY_TALK,
 47+);
 48+
1449 $messages = array(
1550 /*
1651 Short names for language variants used for language conversion links.

Status & tagging log