$wgUseDatabaseMessages = true;
$wgMsgCacheExpiry = 86400;
$wgPartialMessageCache = false;
+
+# Whether to enable language variant conversion. Currently only zh
+# supports this function, to convert between Traditional and Simplified
+# Chinese. This flag is meant to isolate the (untested) conversion
+# code, so that if it breaks, only zh will be affected
+$wgDisableLangConversion = true;
+
# Miscellaneous configuration settings
#
function replaceInternalLinks( $s ) {
global $wgLang, $wgContLang, $wgLinkCache;
+ global $wgDisableLangConversion;
static $fname = 'Parser::replaceInternalLinks' ;
# use a counter to prevent too much unknown links from
# being checked for different language variants.
continue;
}
- //check other language variants of the link
- //if the article does not exist
- global $wgContLang;
- $variants = $wgContLang->getVariants();
-
- if(sizeof($variants) > 1 && $convertCount < 200) {
- $varnt = false;
- if($nt->getArticleID() == 0) {
- foreach ( $variants as $v ) {
- if($v == $wgContLang->getPreferredVariant())
- continue;
- $convertCount ++;
- $varlink = $wgContLang->autoConvert($link, $v);
- $varnt = Title::newFromText($varlink);
- if($varnt && $varnt->getArticleID()>0) {
- break;
+ #check other language variants of the link
+ #if the article does not exist
+ if(!$wgDisableLangConversion) {
+ global $wgContLang;
+ $variants = $wgContLang->getVariants();
+
+ if(sizeof($variants) > 1 && $convertCount < 200) {
+ $varnt = false;
+ if($nt->getArticleID() == 0) {
+ foreach ( $variants as $v ) {
+ if($v == $wgContLang->getPreferredVariant())
+ continue;
+ $convertCount ++;
+ $varlink = $wgContLang->autoConvert($link, $v);
+ $varnt = Title::newFromText($varlink);
+ if($varnt && $varnt->getArticleID()>0) {
+ break;
+ }
}
}
- }
- if($varnt && $varnt->getArticleID()>0) {
- $nt = $varnt;
- $link = $varlink;
+ if($varnt && $varnt->getArticleID()>0) {
+ $nt = $varnt;
+ $link = $varlink;
+ }
}
}
-
$ns = $nt->getNamespace();
$iw = $nt->getInterWiki();
function mainPrefsForm( $err ) {
global $wgUser, $wgOut, $wgLang, $wgContLang, $wgUseDynamicDates, $wgValidSkinNames;
global $wgAllowRealName, $wgImageLimits;
- global $wgLanguageNames;
+ global $wgLanguageNames, $wgDisableLangConversion;
$wgOut->setPageTitle( wfMsg( 'preferences' ) );
$wgOut->setArticleRelated( false );
$wgOut->addHtml("</select></label></div>\n" );
/* see if there are multiple language variants to choose from*/
- $variants = $wgContLang->getVariants();
- $size=sizeof($variants);
+ if(!$wgDisableLangConversion) {
+ $variants = $wgContLang->getVariants();
+ $size=sizeof($variants);
- $variantArray=array();
- foreach($variants as $v) {
- $v = str_replace( '_', '-', strtolower($v));
- if($name=$wgLanguageNames[$v]) {
- $variantArray[$v] = $name;
+ $variantArray=array();
+ foreach($variants as $v) {
+ $v = str_replace( '_', '-', strtolower($v));
+ if($name=$wgLanguageNames[$v]) {
+ $variantArray[$v] = $name;
+ }
}
- }
- $size=sizeof($variantArray);
+ $size=sizeof($variantArray);
- if(sizeof($variantArray) > 1) {
+ if(sizeof($variantArray) > 1) {
$wgOut->addHtml("
<div><label>$yv: <select name=\"wpUserVariant\">\n");
- foreach($variantArray as $code => $name) {
- $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
- $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
+ foreach($variantArray as $code => $name) {
+ $sel = ($code==$this->mUserVariant)? 'selected="selected"' : '';
+ $wgOut->addHtml("\t<option value=\"$code\" $sel>$code - $name</option>\n");
+ }
}
- $wgOut->addHtml("</select></label></div>\n");
}
-
# Fields for changing password
#
$this->mOldpass = htmlspecialchars( $this->mOldpass );
$this->checkbox( 'wgUseDatabaseMessages' ) .
$this->checkbox( 'wgUseCategoryMagic' ) .
$this->checkbox( 'wgUseCategoryBrowser' ) .
+ $this->checkbox( 'wgDisableLangConversion' ).
$this->textbox( 'wgHitcounterUpdateFreq' ) .
$this->textbox( 'wgExtraSubtitle' ).
$this->textbox( 'wgSiteSupportPage' ) .
# syntax of the markup:
# -{code1:text1;code2:text2;...}- or
# -{text}- in which case no conversion should take place for text
- function convert( $text ) {
-
+ function convert( $text , $isTitle=false) {
+ global $wgDisableLangConversion;
+ if($wgDisableLangConversion)
+ return $text;
if(sizeof($this->getVariants())<2)
return $text;
+
+ if($isTitle)
+ return $this->convertTitle($text);
// no conversion if redirecting
if(substr($text,0,9) == "#REDIRECT") {
function autoConvert($text, $toVariant=false) {
return $text;
}
-
+
+ /* hook for converting the title, which may needs special treatment
+ */
+ function convertTitle($text) {
+ return $text;
+ }
+
# returns a list of language variants for conversion.
# right now mainly used in the Chinese conversion
function getVariants() {
return $this->lang->getPreferredVariant();
}
- function convert( $text ) {
- return utf8_decode( $this->lang->convert( utf8_encode( $text ) ) );
+ function convert( $text, $isTitle=false ) {
+ return utf8_decode( $this->lang->convert( utf8_encode( $text ), $isTitle ) );
}
function autoConvert($text, $toVariant=false) {
return utf8_decode( $this->lang->autoConvert( utf8_encode( $text ), $toVariant ) );
}
+
+ /* hook for converting the title, which may needs special treatment
+ */
+ function convertTitle($text) {
+ return utf8_decode( $this->lang->convertTitle( utf8_encode( $text ) ) );
+ }
+
function getVariants() {
return $this->lang->getVariants();
return $t;
}
+ # only convert titles having more than one character
+ function convertTitle($text) {
+ $len=0;
+ if( function_exists( 'mb_strlen' ) )
+ $len = mb_strlen($text);
+ else
+ $len = strlen($text)/3;
+ if($len>1)
+ return $this->autoConvert( $text);
+ return $text;
+ }
+
function getVariants() {
return array("zh-cn", "zh-tw", "zh-sg", "zh-hk");
}