From 292f8462e8c1de362eb13f989afeb4b7e21e2ae0 Mon Sep 17 00:00:00 2001 From: Shinjiman Date: Tue, 8 Jul 2008 02:34:11 +0000 Subject: [PATCH] * tweak some -{}- parsings * adding namespace aliases for the Chinese language (zh) patches by fdcn --- languages/LanguageConverter.php | 34 +++++++++++++++--------------- languages/messages/MessagesZh.php | 35 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/languages/LanguageConverter.php b/languages/LanguageConverter.php index 13fc287b1b..887586dd0c 100644 --- a/languages/LanguageConverter.php +++ b/languages/LanguageConverter.php @@ -79,7 +79,7 @@ class LanguageConverter { } /** - * @access public + * @public */ 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 - * @access public + * @public */ 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(); @@ -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; - $this->mTitleDisplay = $convRule->getRulesTitle(); + $this->mTitleDisplay = $convRule->getTitle(); } 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 - * @access public + * @public */ function convert( $text , $isTitle=false) { @@ -463,10 +463,10 @@ class LanguageConverter { $this->mVariantNames, $this->mDoContentConvert, $this->mDoTitleConvert); - $crule->parseRules($plang, + $crule->parse($plang, $this->getVariantFallbacks($plang), $this->mManualLevel[$plang]=='disable'); - $text .= $crule->getRulesDisplay(); + $text .= $crule->getDisplay(); $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 - * @access public + * @public */ function findVariantLink( &$link, &$nt ) { global $wgDisableLangConversion; @@ -532,7 +532,7 @@ class LanguageConverter { /** * returns language specific hash options * - * @access public + * @public */ function getExtraHashOptions() { $variant = $this->getPreferredVariant(); @@ -542,7 +542,7 @@ class LanguageConverter { /** * get title text as defined in the body of the article text * - * @access public + * @public */ 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 */ @@ -860,16 +861,14 @@ class ConverterRule { * @private */ function parseFlags(){ - $flags = array(); $text = $this->mText; - - // for multi-FLAGs 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) { @@ -1007,11 +1006,12 @@ class ConverterRule { return $this->rules; } } + /** * Parse rules and flags * @public */ - function parseRules($variant,$variantFallbacks,$isMCDisable=false){ + function parse($variant,$variantFallbacks,$isMCDisable=false){ $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) ) { - $flags = array('R'); + $this->flags = $flags = array('R'); } if( in_array('R',$flags) ) { @@ -1056,7 +1056,7 @@ class ConverterRule { * @param string $variant the current variant * @public */ - function getRulesDisplay(){ + function getDisplay(){ return $this->ruleDisplay; } /** @@ -1064,7 +1064,7 @@ class ConverterRule { * @param string $variant the current variant * @public */ - function getRulesTitle(){ + function getTitle(){ return $this->ruleTitle; } diff --git a/languages/messages/MessagesZh.php b/languages/messages/MessagesZh.php index ab17282765..1115fb5e79 100644 --- a/languages/messages/MessagesZh.php +++ b/languages/messages/MessagesZh.php @@ -10,6 +10,41 @@ $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. -- 2.20.1