r5298 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r5297‎ | r5298 | r5299 >
Date:03:53, 19 September 2004
Author:zhengzhu
Status:old
Tags:
Comment:
Caching the conversion tables, just like the caching of the UTF-8 case conversion tables.
Modified paths:
  • /trunk/phase3/includes/ZhConversion.php (modified) (history)
  • /trunk/phase3/languages/LanguageZh.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ZhConversion.php
@@ -17,7 +17,7 @@
1818 phrases are limited to below 5 characters.
1919 */
2020
21 -$wgZhSimp2Trad=array(
 21+$zhSimp2Trad=array(
2222 "万"=>"萬",
2323 "与"=>"與",
2424 "丑"=>"醜",
@@ -5028,6 +5028,7 @@
50295029 "庞克" => "龐克",
50305030 "龟壳" => "龜殼",
50315031 "当" => "當",
 5032+
50325033 "一国两制" => "一國兩制",
50335034 "一拍即合" => "一拍即合",
50345035 "一板一眼" => "一板一眼",
@@ -5465,7 +5466,7 @@
54665467 "麦当奴道" => "麥當奴道",
54675468 );
54685469
5469 -$wgZhTrad2Simp=array(
 5470+$zhTrad2Simp=array(
54705471 "么"=>"么",
54715472 "瀋"=>"沈",
54725473 "畫"=>"划",
@@ -8328,6 +8329,7 @@
83298330 "鍛鍾" => "锻锺",
83308331 "雕畫" => "雕画",
83318332 "鯰魚" => "鲶鱼",
 8333+
83328334 "三聯畫" => "三联画",
83338335 "人物畫" => "人物画",
83348336 "餘光中" => "余光中",
@@ -8380,6 +8382,7 @@
83818383 "靜物畫" => "静物画",
83828384 "風景畫" => "风景画",
83838385 "麻黃鹼" => "麻黄碱",
 8386+
83848387 "一筆一畫" => "一笔一画",
83858388 "亂塗亂畫" => "乱涂乱画",
83868389 "餘事後敘" => "余事后叙",
Index: trunk/phase3/languages/LanguageZh.php
@@ -2,8 +2,16 @@
33 require_once( "LanguageUtf8.php" );
44 require_once( "LanguageZh_cn.php");
55 require_once( "LanguageZh_tw.php");
6 -require_once( "ZhConversion.php");
76
 7+/* caching the conversion tables */
 8+$zhSimp2Trad = $wgMemc->get($key1 = "$wgDBname:zhConvert:s2t");
 9+$zhTrad2Simp = $wgMemc->get($key2 = "$wgDBname:zhConvert:t2s");
 10+if(empty($zhSimp2Trad) || empty($zhTrad2Simp)) {
 11+ require_once("includes/ZhConversion.php");
 12+ $wgMemc->set($key1, $zhSimp2Trad);
 13+ $wgMemc->set($key2, $zhTrad2Simp);
 14+}
 15+
816 /* class that handles both Traditional and Simplified Chinese
917 right now it only distinguish zh_cn and zh_tw (actuall, zh_cn and
1018 non-zh_cn), will add support for zh_sg, zh_hk, etc, later.
@@ -53,13 +61,13 @@
5462 /* the Simplified/Traditional conversion stuff */
5563
5664 function simp2trad($text) {
57 - global $wgZhSimp2Trad;
58 - return strtr($text, $wgZhSimp2Trad);
 65+ global $zhSimp2Trad;
 66+ return strtr($text, $zhSimp2Trad);
5967 }
6068
6169 function trad2simp($text) {
62 - global $wgZhTrad2Simp;
63 - return strtr($text, $wgZhTrad2Simp);
 70+ global $zhTrad2Simp;
 71+ return strtr($text, $zhTrad2Simp);
6472 }
6573
6674 function autoConvert($text) {

Status & tagging log