* tweak some -{}- parsings
authorShinjiman <shinjiman@users.mediawiki.org>
Tue, 8 Jul 2008 02:34:11 +0000 (02:34 +0000)
committerShinjiman <shinjiman@users.mediawiki.org>
Tue, 8 Jul 2008 02:34:11 +0000 (02:34 +0000)
* adding namespace aliases for the Chinese language (zh)
  patches by fdcn

languages/LanguageConverter.php
languages/messages/MessagesZh.php

index 13fc287..887586d 100644 (file)
@@ -79,7 +79,7 @@ class LanguageConverter {
        }
 
        /**
        }
 
        /**
-        * @access public
+        * @public
         */
        function getVariants() {
                return $this->mVariants;
         */
        function getVariants() {
                return $this->mVariants;
@@ -107,7 +107,7 @@ class LanguageConverter {
         * get preferred language variants.
         * @param boolean $fromUser Get it from $wgUser's preferences
         * @return string the preferred language code
         * get preferred language variants.
         * @param boolean $fromUser Get it from $wgUser's preferences
         * @return string the preferred language code
-        * @access public
+        * @public
         */
        function getPreferredVariant( $fromUser = true ) {
                global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant;
         */
        function getPreferredVariant( $fromUser = true ) {
                global $wgUser, $wgRequest, $wgVariantArticlePath, $wgDefaultLanguageVariant;
@@ -325,7 +325,7 @@ class LanguageConverter {
        }
 
        /**
        }
 
        /**
-        * @access private
+        * @private
         */
        function applyManualConv($convRule,$variant){
                if(!$variant) $variant = $this->getPreferredVariant();
         */
        function applyManualConv($convRule,$variant){
                if(!$variant) $variant = $this->getPreferredVariant();
@@ -337,7 +337,7 @@ class LanguageConverter {
                // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
                if($is_title_flag){
                        $this->mTitleFromFlag = true;
                // use syntax -{T|zh:TitleZh;zh-tw:TitleTw}- for custom conversion in title
                if($is_title_flag){
                        $this->mTitleFromFlag = true;
-                       $this->mTitleDisplay =  $convRule->getRulesTitle();
+                       $this->mTitleDisplay =  $convRule->getTitle();
                }
 
                if($this->mManualLevel[$variant]=='disable') return;
                }
 
                if($this->mManualLevel[$variant]=='disable') return;
@@ -426,7 +426,7 @@ class LanguageConverter {
         * @param string $text text to be converted
         * @param bool $isTitle whether this conversion is for the article title
         * @return string converted text
         * @param string $text text to be converted
         * @param bool $isTitle whether this conversion is for the article title
         * @return string converted text
-        * @access public
+        * @public
         */
        function convert( $text , $isTitle=false) {
 
         */
        function convert( $text , $isTitle=false) {
 
@@ -463,10 +463,10 @@ class LanguageConverter {
                                                        $this->mVariantNames,
                                                        $this->mDoContentConvert,
                                                        $this->mDoTitleConvert);
                                                        $this->mVariantNames,
                                                        $this->mDoContentConvert,
                                                        $this->mDoTitleConvert);
-                       $crule->parseRules($plang,
+                       $crule->parse($plang,
                                                        $this->getVariantFallbacks($plang),
                                                        $this->mManualLevel[$plang]=='disable');
                                                        $this->getVariantFallbacks($plang),
                                                        $this->mManualLevel[$plang]=='disable');
-                       $text .= $crule->getRulesDisplay();
+                       $text .= $crule->getDisplay();
                        $this->applyManualConv($crule,$plang);
 
                        if(array_key_exists(1, $marked)){
                        $this->applyManualConv($crule,$plang);
 
                        if(array_key_exists(1, $marked)){
@@ -489,7 +489,7 @@ class LanguageConverter {
         * @param string $link the name of the link
         * @param mixed $nt the title object of the link
         * @return null the input parameters may be modified upon return
         * @param string $link the name of the link
         * @param mixed $nt the title object of the link
         * @return null the input parameters may be modified upon return
-        * @access public
+        * @public
         */
        function findVariantLink( &$link, &$nt ) {
                global $wgDisableLangConversion;
         */
        function findVariantLink( &$link, &$nt ) {
                global $wgDisableLangConversion;
@@ -532,7 +532,7 @@ class LanguageConverter {
     /**
         * returns language specific hash options
         *
     /**
         * returns language specific hash options
         *
-        * @access public
+        * @public
         */
        function getExtraHashOptions() {
                $variant = $this->getPreferredVariant();
         */
        function getExtraHashOptions() {
                $variant = $this->getPreferredVariant();
@@ -542,7 +542,7 @@ class LanguageConverter {
     /**
         * get title text as defined in the body of the article text
         *
     /**
         * get title text as defined in the body of the article text
         *
-        * @access public
+        * @public
         */
        function getParsedTitle() {
                return $this->mTitleDisplay;
         */
        function getParsedTitle() {
                return $this->mTitleDisplay;
@@ -799,6 +799,7 @@ class LanguageConverter {
 }
 
 /**
 }
 
 /**
+ * parser for rules of language conversion , parse rules in -{ }- tag
  * @ingroup Language
  * @author  fdcn <fdcn64@gmail.com>
  */
  * @ingroup Language
  * @author  fdcn <fdcn64@gmail.com>
  */
@@ -860,16 +861,14 @@ class ConverterRule {
         * @private
         */
        function parseFlags(){
         * @private
         */
        function parseFlags(){
-               $flags = array();
                $text = $this->mText;
                $text = $this->mText;
-
-               // for multi-FLAGs
                if(strlen($text) < 2 ) {
                        $this->flags = array( 'R' );
                        $this->rules = $text;
                        return;
                }
 
                if(strlen($text) < 2 ) {
                        $this->flags = array( 'R' );
                        $this->rules = $text;
                        return;
                }
 
+               $flags = array();
                $tt = explode($this->mMarkup['flagsep'], $text, 2);
 
                if(count($tt) == 2) {
                $tt = explode($this->mMarkup['flagsep'], $text, 2);
 
                if(count($tt) == 2) {
@@ -1007,11 +1006,12 @@ class ConverterRule {
                        return $this->rules;
                }
        }
                        return $this->rules;
                }
        }
+
        /**
         * Parse rules and flags
         * @public
         */
        /**
         * Parse rules and flags
         * @public
         */
-       function parseRules($variant,$variantFallbacks,$isMCDisable=false){
+       function parse($variant,$variantFallbacks,$isMCDisable=false){
                $this->parseFlags();
                $this->generateConvTable();
 
                $this->parseFlags();
                $this->generateConvTable();
 
@@ -1021,7 +1021,7 @@ class ConverterRule {
                if(count($this->bidtable)==0 && count($this->unidtable)==0
                        && !in_array('N',$flags) && !in_array('T',$flags) )
                {
                if(count($this->bidtable)==0 && count($this->unidtable)==0
                        && !in_array('N',$flags) && !in_array('T',$flags) )
                {
-                       $flags = array('R');
+                       $this->flags = $flags = array('R');
                }
 
                if( in_array('R',$flags) ) {
                }
 
                if( in_array('R',$flags) ) {
@@ -1056,7 +1056,7 @@ class ConverterRule {
         * @param string $variant the current variant
         * @public
         */
         * @param string $variant the current variant
         * @public
         */
-       function getRulesDisplay(){
+       function getDisplay(){
                return $this->ruleDisplay;
        }
        /**
                return $this->ruleDisplay;
        }
        /**
@@ -1064,7 +1064,7 @@ class ConverterRule {
         * @param string $variant the current variant
         * @public
         */
         * @param string $variant the current variant
         * @public
         */
-       function getRulesTitle(){
+       function getTitle(){
                return $this->ruleTitle;
        }
 
                return $this->ruleTitle;
        }
 
index ab17282..1115fb5 100644 (file)
 
 $fallback = 'zh-hans';
 
 
 $fallback = 'zh-hans';
 
+$namespaceAliases = array(
+       '媒体'        => NS_MEDIA,
+       '媒體'        => NS_MEDIA,
+       '特殊'  => NS_SPECIAL,
+       '对话'  => NS_TALK,
+       '對話'  => NS_TALK,
+       '讨论'        => NS_TALK,
+       '討論'        => NS_TALK,
+       '用户'  => NS_USER,
+       '用戶'  => NS_USER,
+       '用户对话' => NS_USER_TALK,
+       '用戶對話' => NS_USER_TALK,
+       '用户讨论' => NS_USER_TALK,
+       '用戶討論' => NS_USER_TALK,
+       # This has never worked so it's unlikely to annoy anyone if I disable it -- TS
+       #'{{SITENAME}}_对话' => NS_PROJECT_TALK
+       #"{{SITENAME}}_對話" => NS_PROJECT_TALK
+       '图像' => NS_IMAGE,
+       '圖像' => NS_IMAGE,
+       '图像对话' => NS_IMAGE_TALK,
+       '圖像對話' => NS_IMAGE_TALK,
+       '模板'        => NS_TEMPLATE,
+       '模板讨论'=> NS_TEMPLATE_TALK,
+       "樣板" => NS_TEMPLATE,
+       "樣板討論" => NS_TEMPLATE_TALK,
+       '帮助'        => NS_HELP,
+       '帮助讨论'=> NS_HELP_TALK,
+       "幫助" => NS_HELP,
+       "幫助討論" => NS_HELP_TALK,
+       '分类'        => NS_CATEGORY,
+       '分类讨论'=> NS_CATEGORY_TALK,
+       "分類" => NS_CATEGORY,
+       "分類討論" => NS_CATEGORY_TALK,
+);
+
 $messages = array(
 /*
 Short names for language variants used for language conversion links.
 $messages = array(
 /*
 Short names for language variants used for language conversion links.