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
/* 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");
}
}
?>
'zh-cfr' => '閩南語', # 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
);
?>