From 825c1a2e90db89eec16b3ac86a7a3818f7b51c3e Mon Sep 17 00:00:00 2001 From: Zheng Zhu Date: Fri, 8 Oct 2004 05:19:23 +0000 Subject: [PATCH] initial support for zh-hk and zh-sg --- languages/LanguageZh.php | 60 ++++++++++++++++++++++++++----------- languages/LanguageZh_hk.php | 6 ++++ languages/LanguageZh_sg.php | 6 ++++ languages/Names.php | 2 ++ 4 files changed, 57 insertions(+), 17 deletions(-) create mode 100644 languages/LanguageZh_hk.php create mode 100644 languages/LanguageZh_sg.php diff --git a/languages/LanguageZh.php b/languages/LanguageZh.php index b450a7a5d1..eb09c70116 100644 --- a/languages/LanguageZh.php +++ b/languages/LanguageZh.php @@ -3,12 +3,16 @@ require_once( "LanguageZh_cn.php"); require_once( "LanguageZh_tw.php"); /* caching the conversion tables */ -$zhSimp2Trad = $wgMemc->get($key1 = "$wgDBname:zhConvert:s2t"); -$zhTrad2Simp = $wgMemc->get($key2 = "$wgDBname:zhConvert:t2s"); +$zh2TW = $wgMemc->get($key1 = "$wgDBname:zhConvert:tw"); +$zh2CN = $wgMemc->get($key2 = "$wgDBname:zhConvert:cn"); +$zh2SG = $wgMemc->get($key3 = "$wgDBname:zhConvert:sg"); +$zh2HK = $wgMemc->get($key4 = "$wgDBname:zhConvert:hk"); if(empty($zhSimp2Trad) || empty($zhTrad2Simp)) { require_once("includes/ZhConversion.php"); - $wgMemc->set($key1, $zhSimp2Trad); - $wgMemc->set($key2, $zhTrad2Simp); + $wgMemc->set($key1, $zh2TW); + $wgMemc->set($key2, $zh2CN); + $wgMemc->set($key3, $zh2SG); + $wgMemc->set($key4, $zh2HK); } /* class that handles both Traditional and Simplified Chinese @@ -53,30 +57,52 @@ class LanguageZh extends LanguageZh_cn { /* the Simplified/Traditional conversion stuff */ - function simp2trad($text) { - global $zhSimp2Trad; - return strtr($text, $zhSimp2Trad); + function zh2tw($text) { + global $zh2TW; + return strtr($text, $zh2TW); } - function trad2simp($text) { - global $zhTrad2Simp; - return strtr($text, $zhTrad2Simp); + function zh2cn($text) { + global $zh2CN; + return strtr($text, $zh2CN); + } + + function zh2sg($text) { + global $zh2SG, $zh2CN; + return strtr(strtr($text, $zh2CN), $zh2SG); + } + + function zh2hk($text) { + global $zh2HK, $zh2TW; + return strtr(strtr($text, $zh2TW), $zh2HK); } function autoConvert($text, $toVariant=false) { if(!$toVariant) $toVariant = $this->getPreferredVariant(); - - if($toVariant == "zh-cn") { - return $this->trad2simp($text); - } - else { - return $this->simp2trad($text); + $fname="zhconvert"; + wfProfileIn( $fname ); + $t = $text; + switch($toVariant) { + case 'zh-cn': + $t = $this->zh2cn($text); + break; + case 'zh-tw': + $t = $this->zh2tw($text); + break; + case 'zh-sg': + $t = $this->zh2sg($text); + break; + case 'zh-hk': + $t = $this->zh2hk($text); + break; } + wfProfileOut( $fname ); + return $t; } function getVariants() { - return array("zh-cn", "zh-tw"); + return array("zh-cn", "zh-tw", "zh-sg", "zh-hk"); } } ?> diff --git a/languages/LanguageZh_hk.php b/languages/LanguageZh_hk.php new file mode 100644 index 0000000000..633215988d --- /dev/null +++ b/languages/LanguageZh_hk.php @@ -0,0 +1,6 @@ + '閩南語', # Min-nan alias (site is at minnan) 'zh-cn' => '中文(简体)', # Simplified 'zh-tw' => '中文(繁体)', # Traditional + 'zh-sg' => '中文(简体)', # Simplified (Singapore) + 'zh-hk' => '中文(繁体)', # Traditional (Hong Kong) 'zu' => 'isiZulu', # Zulu ); ?> -- 2.20.1