From 405b5431121c1890e56dcc64b034dd457edcb5b9 Mon Sep 17 00:00:00 2001 From: Zheng Zhu Date: Tue, 7 Dec 2004 22:23:21 +0000 Subject: [PATCH] added user option to disable Chinese language conversion --- includes/User.php | 10 +++++----- languages/Language.php | 8 ++++++++ languages/LanguageLatin1.php | 5 +++++ languages/LanguageZh.php | 13 ++++++++++++- languages/LanguageZh_cn.php | 11 ++++++++++- 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/includes/User.php b/includes/User.php index 90b2dfeb55..f46c9f0d74 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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; diff --git a/languages/Language.php b/languages/Language.php index 1b95b97da0..cf4c1ea8ac 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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 diff --git a/languages/LanguageLatin1.php b/languages/LanguageLatin1.php index 9a54330bd3..ebc6658785 100644 --- a/languages/LanguageLatin1.php +++ b/languages/LanguageLatin1.php @@ -292,6 +292,11 @@ class LanguageLatin1 { function convertForSearchResult( $termsArray ) { return $termsArray; } + + function getExtraHashOptions() { + return array(); + } + } ?> diff --git a/languages/LanguageZh.php b/languages/LanguageZh.php index 38cdcb7e55..842a4805a8 100644 --- a/languages/LanguageZh.php +++ b/languages/LanguageZh.php @@ -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'); + } } ?> diff --git a/languages/LanguageZh_cn.php b/languages/LanguageZh_cn.php index eab9d5cfec..581f6873d3 100644 --- a/languages/LanguageZh_cn.php +++ b/languages/LanguageZh_cn.php @@ -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; -- 2.20.1