r6564 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r6563‎ | r6564 | r6565 >
Date:22:08, 7 December 2004
Author:zhengzhu
Status:old
Tags:
Comment:
added user option to disable Chinese language conversion
Modified paths:
  • /branches/REL1_4/phase3/includes/User.php (modified) (history)
  • /branches/REL1_4/phase3/languages/Language.php (modified) (history)
  • /branches/REL1_4/phase3/languages/LanguageLatin1.php (modified) (history)
  • /branches/REL1_4/phase3/languages/LanguageZh.php (modified) (history)
  • /branches/REL1_4/phase3/languages/LanguageZh_cn.php (modified) (history)

Diff [purge]

Index: branches/REL1_4/phase3/includes/User.php
@@ -970,7 +970,7 @@
971971 }
972972
973973 function getPageRenderingHash() {
974 - global $wgContLang;
 974+ global $wgContLang;
975975 if( $this->mHash ){
976976 return $this->mHash;
977977 }
@@ -987,10 +987,10 @@
988988 $confstr .= '!' . $this->getOption( 'date' );
989989 $confstr .= '!' . $this->getOption( 'numberheadings' );
990990 $confstr .= '!' . $this->getOption( 'language' );
991 - // add in language variant option if there are multiple variants
992 - // supported by the language object
993 - if(sizeof($wgContLang->getVariants())>1) {
994 - $confstr .= '!' . $this->getOption( 'variant' );
 991+ // add in language specific options, if any
 992+ $extra = $wgContLang->getExtraHashOptions();
 993+ foreach( $extra as $e ) {
 994+ $confstr .= '!' . $this->getOption( $e );
995995 }
996996
997997 $this->mHash = $confstr;
Index: branches/REL1_4/phase3/languages/LanguageLatin1.php
@@ -292,6 +292,10 @@
293293 function convertForSearchResult( $termsArray ) {
294294 return $termsArray;
295295 }
 296+
 297+ function getExtraHashOptions() {
 298+ return array();
 299+ }
296300 }
297301
298302 ?>
Index: branches/REL1_4/phase3/languages/Language.php
@@ -2222,6 +2222,13 @@
22232223 }
22242224 }
22252225 }
 2226+
 2227+ /*
 2228+ returns an array of extra options used by User::getPageRenderHash()
 2229+ */
 2230+ function getExtraHashOptions() {
 2231+ return array();
 2232+ }
22262233 }
22272234
22282235 # This should fail gracefully if there's not a localization available
Index: branches/REL1_4/phase3/languages/LanguageZh.php
@@ -15,7 +15,14 @@
1616 var $mZhClient=false;
1717 function LanguageZh() {
1818 global $wgUseZhdaemon, $wgZhdaemonHost, $wgZhdaemonPort;
19 - global $wgDisableLangConversion;
 19+ global $wgDisableLangConversion, $wgUser;
 20+
 21+ if( $wgUser->getID()!=0 ) {
 22+ /* allow user to diable conversion */
 23+ if( $wgDisableLangConversion == false &&
 24+ $wgUser->getOption('nolangconversion') == 1)
 25+ $wgDisableLangConversion = true;
 26+ }
2027
2128 $this->mZhLanguageCode = $this->getPreferredVariant();
2229 if($wgUseZhdaemon) {
@@ -137,5 +144,9 @@
138145 $ret = array_unique( explode('|', $terms) );
139146 return $ret;
140147 }
 148+
 149+ function getExtraHashOptions() {
 150+ return array('variant', 'nolangconversion');
 151+ }
141152 }
142153 ?>
Index: branches/REL1_4/phase3/languages/LanguageZh_cn.php
@@ -58,6 +58,9 @@
5959 "Amazon.com" => "http://www.amazon.com/exec/obidos/ISBN=$1"
6060 );
6161
 62+/* private */ $wgUserTogglesZh_cn = array(
 63+ 'nolangconversion',
 64+) + $wgUserTogglesEn;
6265
6366 # All special pages have to be listed here: a description of ""
6467 # will make them not show up on the "Special Pages" page, which
@@ -147,7 +150,7 @@
148151 "tog-watchdefault" => "监视新的以及更改过的文章", /* "Watch new and modified articles", */
149152 "tog-minordefault" => "细微编辑为默认设置", /* "Mark all edits minor by default", */
150153 "tog-previewontop" => "在编辑框上方显示预览", /* "Show preview before edit box and not after it" */
151 -
 154+"tog-nolangconversion" => "不进行繁简体转换", /* "disable language conversion" */
152155 # Dates
153156
154157 'sunday' => "星期日",
@@ -958,6 +961,11 @@
959962 return $wgBookstoreListZh_cn ;
960963 }
961964
 965+ function getUserToggles() {
 966+ global $wgUserTogglesZh_cn;
 967+ return $wgUserTogglesZh_cn;
 968+ }
 969+
962970 function getNamespaces() {
963971 global $wgNamespaceNamesZh_cn;
964972 return $wgNamespaceNamesZh_cn;

Status & tagging log