Caching the conversion tables, just like the caching of the UTF-8 case conversion...
authorZheng Zhu <zhengzhu@users.mediawiki.org>
Sun, 19 Sep 2004 03:53:06 +0000 (03:53 +0000)
committerZheng Zhu <zhengzhu@users.mediawiki.org>
Sun, 19 Sep 2004 03:53:06 +0000 (03:53 +0000)
includes/ZhConversion.php
languages/LanguageZh.php

index 6fca80f..6a16fc2 100644 (file)
@@ -17,7 +17,7 @@
    phrases are limited to below 5 characters.
 */
 
-$wgZhSimp2Trad=array(
+$zhSimp2Trad=array(
 "万"=>"萬",
 "与"=>"與",
 "丑"=>"醜",
@@ -5028,6 +5028,7 @@ $wgZhSimp2Trad=array(
 "庞克" =>    "龐克",
 "龟壳" =>    "龜殼",
 "当" =>    "當",
+
 "一国两制" =>      "一國兩制",
 "一拍即合" =>      "一拍即合",
 "一板一眼" =>      "一板一眼",
@@ -5465,7 +5466,7 @@ $wgZhSimp2Trad=array(
 "麦当奴道" =>      "麥當奴道",
 );
 
-$wgZhTrad2Simp=array(
+$zhTrad2Simp=array(
 "么"=>"么",
 "瀋"=>"沈",
 "畫"=>"划",
@@ -8328,6 +8329,7 @@ $wgZhTrad2Simp=array(
 "鍛鍾" =>    "锻锺",
 "雕畫" =>    "雕画",
 "鯰魚" =>    "鲶鱼",
+
 "三聯畫" =>         "三联画",
 "人物畫" =>         "人物画",
 "餘光中" =>         "余光中",
@@ -8380,6 +8382,7 @@ $wgZhTrad2Simp=array(
 "靜物畫" =>         "静物画",
 "風景畫" =>         "风景画",
 "麻黃鹼" =>         "麻黄碱",
+
 "一筆一畫" =>      "一笔一画",
 "亂塗亂畫" =>      "乱涂乱画",
 "餘事後敘" =>      "余事后叙",
index 3f3228f..4d93ade 100644 (file)
@@ -2,7 +2,15 @@
 require_once( "LanguageUtf8.php" );
 require_once( "LanguageZh_cn.php");
 require_once( "LanguageZh_tw.php");
-require_once( "ZhConversion.php");
+
+/* caching the conversion tables */
+$zhSimp2Trad = $wgMemc->get($key1 = "$wgDBname:zhConvert:s2t");
+$zhTrad2Simp = $wgMemc->get($key2 = "$wgDBname:zhConvert:t2s");
+if(empty($zhSimp2Trad) || empty($zhTrad2Simp)) {
+    require_once("includes/ZhConversion.php");
+    $wgMemc->set($key1, $zhSimp2Trad);
+    $wgMemc->set($key2, $zhTrad2Simp);
+}
 
 /* class that handles both Traditional and Simplified Chinese
    right now it only distinguish zh_cn and zh_tw (actuall, zh_cn and
@@ -53,13 +61,13 @@ class LanguageZh extends LanguageUtf8 {
   /* the Simplified/Traditional conversion stuff */
 
        function simp2trad($text) {
-               global $wgZhSimp2Trad;
-               return strtr($text, $wgZhSimp2Trad);
+               global $zhSimp2Trad;
+               return strtr($text, $zhSimp2Trad);
        }
 
        function trad2simp($text) {
-               global $wgZhTrad2Simp;
-               return strtr($text, $wgZhTrad2Simp);
+               global $zhTrad2Simp;
+               return strtr($text, $zhTrad2Simp);
        }
        
        function autoConvert($text) {