make conversion table for zh-sg default to zh-cn, and zh-hk default to zh-tw
[lhc/web/wiklou.git] / languages / LanguageZh.php
index 9b65a82..c97e41f 100644 (file)
@@ -102,8 +102,8 @@ class LanguageZh extends LanguageZh_cn {
                $this->mTables = array();
                $this->mTables['zh-cn'] = $zh2CN;
                $this->mTables['zh-tw'] = $zh2TW;
-               $this->mTables['zh-sg'] = array_merge($zh2CN, $zh2SG);
-               $this->mTables['zh-hk'] = array_merge($zh2TW, $zh2HK);
+               $this->mTables['zh-sg'] = $zh2SG;
+               $this->mTables['zh-hk'] = $zh2HK;
 
                $cached = $this->parseCachedTable('zh-cn');
                $this->mTables['zh-cn'] = array_merge($this->mTables['zh-cn'], $cached);
@@ -112,10 +112,10 @@ class LanguageZh extends LanguageZh_cn {
                $this->mTables['zh-tw'] = array_merge($this->mTables['zh-tw'], $cached);
 
                $cached = $this->parseCachedTable('zh-sg');
-               $this->mTables['zh-sg'] = array_merge($this->mTables['zh-sg'], $cached);
+               $this->mTables['zh-sg'] = array_merge($this->mTables['zh-cn'], $this->mTables['zh-sg'], $cached);
 
                $cached = $this->parseCachedTable('zh-hk');
-               $this->mTables['zh-hk'] = array_merge($this->mTables['zh-hk'], $cached);
+               $this->mTables['zh-hk'] = array_merge($this->mTables['zh-tw'], $this->mTables['zh-hk'], $cached);
                if($this->lockCache()) {
                        $wgMemc->set($this->mCacheKey, $this->mTables, 43200);
                        $this->unlockCache();
@@ -189,7 +189,9 @@ class LanguageZh extends LanguageZh_cn {
                                $m = explode( '=>', $t );
                                if( count( $m ) != 2)
                                        continue;
-                               $ret[trim($m[0])] = trim($m[1]);
+                               // trim any trailling comments starting with '//'
+                               $tt = explode('//', $m[1], 2);
+                               $ret[trim($m[0])] = trim($tt[0]);
                        }
                }
                $parsed[$key] = true;
@@ -222,7 +224,7 @@ class LanguageZh extends LanguageZh_cn {
                }
 
                // get language variant preference from logged in users 
-               if($wgUser->getID()!=0) {
+               if( $wgUser->isLoggedIn() ) {
                        $this->mZhLanguageCode = $wgUser->getOption('variant');
                }
 
@@ -430,7 +432,7 @@ class LanguageZh extends LanguageZh_cn {
                static $cache=array();
                global $wgDisableLangConversion;
                $pref = $this->getPreferredVariant();
-               if( $wgDisableLangConversion || $pref == 'zh' || $count > 50)
+               if( $count > 50 )
                        return;
                $count++;
                $variants = $this->autoConvertToAllVariants($link);
@@ -443,7 +445,8 @@ class LanguageZh extends LanguageZh_cn {
                        $varnt = Title::newFromText( $v );
                        if( $varnt && $varnt->getArticleID() > 0 ) {
                                $nt = $varnt;
-                               $link = $v;
+                               if( !$wgDisableLangConversion && $pref != 'zh' )
+                                       $link = $v;
                                break;
                        }
                }