added user option to disable Chinese language conversion
authorZheng Zhu <zhengzhu@users.mediawiki.org>
Tue, 7 Dec 2004 22:23:21 +0000 (22:23 +0000)
committerZheng Zhu <zhengzhu@users.mediawiki.org>
Tue, 7 Dec 2004 22:23:21 +0000 (22:23 +0000)
includes/User.php
languages/Language.php
languages/LanguageLatin1.php
languages/LanguageZh.php
languages/LanguageZh_cn.php

index 90b2dfe..f46c9f0 100644 (file)
@@ -1012,7 +1012,7 @@ class User {
        }
 
        function getPageRenderingHash() {
-        global $wgContLang;
+               global $wgContLang;
                if( $this->mHash ){
                        return $this->mHash;
                }
@@ -1029,10 +1029,10 @@ class User {
                $confstr .= '!' . $this->getOption( 'date' );
                $confstr .= '!' . $this->getOption( 'numberheadings' );
                $confstr .= '!' . $this->getOption( 'language' );
-               // add in language variant option if there are multiple variants
-               // supported by the language object
-               if(sizeof($wgContLang->getVariants())>1) {
-                       $confstr .= '!' . $this->getOption( 'variant' );
+               // add in language specific options, if any
+               $extra = $wgContLang->getExtraHashOptions();
+               foreach( $extra as $e ) {
+                       $confstr .= '!' . $this->getOption( $e );
                }
 
                $this->mHash = $confstr;
index 1b95b97..cf4c1ea 100644 (file)
@@ -2223,6 +2223,14 @@ class Language {
                        }
                }
        }
+
+       /*
+               returns an array of extra options used by User::getPageRenderHash()
+       */
+       function getExtraHashOptions() {
+               return array();
+       }
+
 }
 
 # This should fail gracefully if there's not a localization available
index 9a54330..ebc6658 100644 (file)
@@ -292,6 +292,11 @@ class LanguageLatin1 {
        function convertForSearchResult( $termsArray ) {
                return $termsArray;
        }       
+
+       function getExtraHashOptions() {
+               return array();
+       }
+
 }
 
 ?>
index 38cdcb7..842a480 100644 (file)
@@ -15,7 +15,14 @@ class LanguageZh extends LanguageZh_cn {
        var $mZhClient=false;   
        function LanguageZh() {
                global $wgUseZhdaemon, $wgZhdaemonHost, $wgZhdaemonPort;
-               global $wgDisableLangConversion;
+               global $wgDisableLangConversion, $wgUser;
+        
+               if( $wgUser->getID()!=0 ) {
+                       /* allow user to diable conversion */
+                       if( $wgDisableLangConversion == false &&
+                               $wgUser->getOption('nolangconversion') == 1)
+                               $wgDisableLangConversion = true;
+               }               
 
                $this->mZhLanguageCode = $this->getPreferredVariant();
                if($wgUseZhdaemon) {
@@ -139,5 +146,9 @@ class LanguageZh extends LanguageZh_cn {
                $ret = array_unique( explode('|', $terms) );
                return $ret;
        }
+
+       function getExtraHashOptions() {
+               return array('variant', 'nolangconversion');
+       }
 }
 ?>
index eab9d5c..581f687 100644 (file)
@@ -58,6 +58,10 @@ require_once( "LanguageUtf8.php" );
        "Amazon.com" => "http://www.amazon.com/exec/obidos/ISBN=$1"
 );
 
+/* private */ $wgUserTogglesZh_cn = array(
+       'nolangconversion',
+) + $wgUserTogglesEn;
+
 
 # All special pages have to be listed here: a description of ""
 # will make them not show up on the "Special Pages" page, which
@@ -147,7 +151,7 @@ require_once( "LanguageUtf8.php" );
 "tog-watchdefault" => "监视新的以及更改过的文章", /* "Watch new and modified articles", */
 "tog-minordefault" => "细微编辑为默认设置", /* "Mark all edits minor by default", */
 "tog-previewontop" => "在编辑框上方显示预览", /* "Show preview before edit box and not after it" */
-
+"tog-nolangconversion" => "不进行繁简体转换", /* "disable language conversion" */
 # Dates
 
 'sunday' => "星期日",
@@ -958,6 +962,11 @@ class LanguageZh_cn extends LanguageUtf8 {
                return $wgBookstoreListZh_cn ;
        }
 
+       function getUserToggles() {
+               global $wgUserTogglesZh_cn;
+               return $wgUserTogglesZh_cn;
+       }
+
        function getNamespaces() {
                global $wgNamespaceNamesZh_cn;
                return $wgNamespaceNamesZh_cn;