initial support for zh-hk and zh-sg
authorZheng Zhu <zhengzhu@users.mediawiki.org>
Fri, 8 Oct 2004 05:19:23 +0000 (05:19 +0000)
committerZheng Zhu <zhengzhu@users.mediawiki.org>
Fri, 8 Oct 2004 05:19:23 +0000 (05:19 +0000)
languages/LanguageZh.php
languages/LanguageZh_hk.php [new file with mode: 0644]
languages/LanguageZh_sg.php [new file with mode: 0644]
languages/Names.php

index b450a7a..eb09c70 100644 (file)
@@ -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 (file)
index 0000000..6332159
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+require_once( "LanguageZh_tw.php");
+
+class LanguageZh_hk extends LanguageZh_tw { 
+# Inherit everything for now
+}
diff --git a/languages/LanguageZh_sg.php b/languages/LanguageZh_sg.php
new file mode 100644 (file)
index 0000000..cfb04ce
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+require_once( "LanguageZh_cn.php");
+
+class LanguageZh_sg extends LanguageZh_cn { 
+# Inherit everything for now
+}
index 13abbfd..0e9e3d7 100644 (file)
        'zh-cfr' => '&#38313;&#21335;&#35486;', # Min-nan alias (site is at minnan)
        'zh-cn' => '&#20013;&#25991;(&#31616;&#20307;)',        # Simplified
        'zh-tw' => '&#20013;&#25991;(&#32321;&#20307;)',        # Traditional
+       'zh-sg' => '&#20013;&#25991;(&#31616;&#20307;)', # Simplified (Singapore)
+       'zh-hk' => '&#20013;&#25991;(&#32321;&#20307;)',        # Traditional (Hong Kong)
        'zu' => 'isiZulu',              # Zulu
 );
 ?>