Merged my changes from REL1_4
authorZheng Zhu <zhengzhu@users.mediawiki.org>
Fri, 24 Dec 2004 02:47:38 +0000 (02:47 +0000)
committerZheng Zhu <zhengzhu@users.mediawiki.org>
Fri, 24 Dec 2004 02:47:38 +0000 (02:47 +0000)
13 files changed:
includes/DefaultSettings.php
includes/Skin.php
includes/SkinTemplate.php
includes/SpecialRecentchanges.php
includes/User.php
includes/ZhClient.php
languages/Language.php
languages/LanguageLatin1.php
languages/LanguageZh.php
languages/LanguageZh_cn.php
languages/LanguageZh_tw.php
skins/CologneBlue.php
skins/monobook/main.css

index bf7f45d..c048965 100644 (file)
@@ -367,9 +367,11 @@ $wgPartialMessageCache = false;
 # 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;
+$wgDisableLangConversion = false;
 
 # Whether to use zhdaemon to perform Chinese text processing
+# zhdaemon is under developement, so normally you don't want to
+# use it unless for testing
 $wgUseZhdaemon = false;
 $wgZhdaemonHost="localhost";
 $wgZhdaemonPort=2004;
@@ -956,6 +958,7 @@ $wgForceUIMsgAsContentMsg = array( 'mainpage', 'portal-url' );
 */
 $wgForceUIMsgAsContentMsg = array();
 
+
 /**
  * Authentication plugin.
  */
index 494c76c..2c989b0 100644 (file)
@@ -683,6 +683,20 @@ class Skin extends Linker {
                # Many people don't like this dropdown box
                #$s .= $sep . $this->specialPagesList();
 
+               /* show links to different language variants */
+               global $wgDisableLangConversion, $wgContLang, $wgTitle;
+               $variants = $wgContLang->getVariants();
+               if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
+                       foreach( $variants as $code ) {
+                               $varname = $wgContLang->getVariantname( $code );
+                               if( $varname == 'disable' )
+                                       continue;
+                               $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
+                       }
+               }
+
+
+
                return $s;
        }
 
index cc1676a..6eedc08 100644 (file)
@@ -471,6 +471,7 @@ class SkinTemplate extends Skin {
         * @access private
         */
        function buildContentActionUrls () {
+               global $wgContLang;
                $fname = 'SkinTemplate::buildContentActionUrls';
                wfProfileIn( $fname );
                
@@ -601,7 +602,7 @@ class SkinTemplate extends Skin {
                                }
                        }
                        wfProfileOut( "$fname-live" );
-                       
+
                        if ( $wgUser->getID() != 0 and $action != 'submit' ) {
                                if( !$wgTitle->userIsWatching()) {
                                        $content_actions['watch'] = array(
@@ -628,6 +629,7 @@ class SkinTemplate extends Skin {
                                        'href' => $wgTitle->getLocalUrl( 'action=validate'.$article_time)
                                );
                        }
+
                } else {
                        /* show special page tab */
 
@@ -638,6 +640,29 @@ class SkinTemplate extends Skin {
                        );
                }
 
+               /* show links to different language variants */
+               global $wgDisableLangConversion;
+               $variants = $wgContLang->getVariants();
+               if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
+                       $preferred = $wgContLang->getPreferredVariant();
+                       $actstr = '';
+                       if( $action )
+                               $actstr = 'action=' . $action . '&';
+                       $vcount=0;
+                       foreach( $variants as $code ) {
+                               $varname = $wgContLang->getVariantname( $code );
+                               if( $varname == 'disable' )
+                                       continue;
+                               $selected = ( $code == $preferred )? 'selected' : false;
+                               $content_actions['varlang-' . $vcount] = array(
+                                               'class' => $selected,
+                                               'text' => $varname,
+                                               'href' => $wgTitle->getLocalUrl( $actstr . 'variant=' . $code )
+                                       );
+                               $vcount ++;
+                       }
+               }               
+
                wfProfileOut( $fname );
                return $content_actions;
        }
index 1782843..0df8788 100644 (file)
@@ -80,7 +80,7 @@ function wfSpecialRecentchanges( $par ) {
        }
 
        # Output header
-       $rctext = wfMsg( "recentchangestext" );
+       $rctext = wfMsgForContent( "recentchangestext" );
        $wgOut->addWikiText( $rctext );
 
        
index becea05..faf7ab5 100644 (file)
@@ -1089,9 +1089,7 @@ class User {
                $confstr .= '!' . $this->getOption( 'language' );
                // add in language specific options, if any
                $extra = $wgContLang->getExtraHashOptions();
-               foreach( $extra as $e ) {
-                       $confstr .= '!' . $this->getOption( $e );
-               }
+               $confstr .= $extra;
 
                $this->mHash = $confstr;
                return $confstr ;
index 13b195e..fb0d826 100644 (file)
@@ -148,20 +148,20 @@ class ZhClient {
 class ZhClientFake {
        function ZhClientFake() {
                global $wgMemc, $wgDBname;
-               $this->zh2TW = $wgMemc->get($key1 = "$wgDBname:zhConvert:tw");
-               $this->zh2CN = $wgMemc->get($key2 = "$wgDBname:zhConvert:cn");
-               $this->zh2SG = $wgMemc->get($key3 = "$wgDBname:zhConvert:sg");
-               $this->zh2HK = $wgMemc->get($key4 = "$wgDBname:zhConvert:hk");
-               if(empty($this->zh2TW) || empty($this->zh2CN) || empty($this->zh2SG) || empty($this->zh2HK)) {
+               $this->mZh2TW = $wgMemc->get($key1 = "$wgDBname:zhConvert:tw");
+               $this->mZh2CN = $wgMemc->get($key2 = "$wgDBname:zhConvert:cn");
+               $this->mZh2SG = $wgMemc->get($key3 = "$wgDBname:zhConvert:sg");
+               $this->mZh2HK = $wgMemc->get($key4 = "$wgDBname:zhConvert:hk");
+               if(empty($this->mZh2TW) || empty($this->mZh2CN) || empty($this->mZh2SG) || empty($this->mZh2HK)) {
                        require("includes/ZhConversion.php");
-                       $this->zh2TW = $zh2TW;
-                       $this->zh2CN = $zh2CN;
-                       $this->zh2HK = $zh2HK;
-                       $this->zh2SG = $zh2SG;
-                       $wgMemc->set($key1, $this->zh2TW);
-                       $wgMemc->set($key2, $this->zh2CN);
-                       $wgMemc->set($key3, $this->zh2SG);
-                       $wgMemc->set($key4, $this->zh2HK);
+                       $this->mZh2TW = $zh2TW;
+                       $this->mZh2CN = $zh2CN;
+                       $this->mZh2HK = $zh2HK;
+                       $this->mZh2SG = $zh2SG;
+                       $wgMemc->set($key1, $this->mZh2TW);
+                       $wgMemc->set($key2, $this->mZh2CN);
+                       $wgMemc->set($key3, $this->mZh2SG);
+                       $wgMemc->set($key4, $this->mZh2HK);
                }
        }
 
@@ -175,7 +175,7 @@ class ZhClientFake {
         * @access private
         */
        function zh2tw($text) {
-               return strtr($text, $this->zh2TW);
+               return strtr($text, $this->mZh2TW);
        }
 
        /**
@@ -184,7 +184,7 @@ class ZhClientFake {
         * @access private
         */
        function zh2cn($text) {
-               return strtr($text, $this->zh2CN);
+               return strtr($text, $this->mZh2CN);
        }
 
        /**
@@ -193,7 +193,7 @@ class ZhClientFake {
         * @access private
         */
        function zh2sg($text) {
-               return strtr(strtr($text, $this->zh2CN), $this->zh2SG);
+               return strtr(strtr($text, $this->mZh2CN), $this->mZh2SG);
        }
 
        /**
@@ -202,7 +202,7 @@ class ZhClientFake {
         * @access private
         */
        function zh2hk($text) {
-               return strtr(strtr($text, $this->zh2TW), $this->zh2HK);
+               return strtr(strtr($text, $this->mZh2TW), $this->mZh2HK);
        }
 
        /**
index dfea12c..b31031e 100644 (file)
@@ -1387,7 +1387,7 @@ to a previously blocked IP address or username.',
 'blocklogpage' => 'Block_log',
 'blocklogentry'        => 'blocked "$1" with an expiry time of $2',
 'blocklogtext' => 'This is a log of user blocking and unblocking actions. Automatically
-blocked IP addresses are not be listed. See the [[Special:Ipblocklist|IP block list]] for
+blocked IP addresses are not listed. See the [[Special:Ipblocklist|IP block list]] for
 the list of currently operational bans and blocks.',
 'unblocklogentry'      => 'unblocked "$1"',
 'range_block_disabled' => 'The sysop ability to create range blocks is disabled.',
@@ -1551,7 +1551,7 @@ article [[Train]].
 
 'allmessages'  => 'All system messages',
 'allmessagestext'      => 'This is a list of all system messages available in the MediaWiki: namespace.',
-'allmessagesnotsupportedUI' => 'Your current interface language <b>$1</b> is not supported by Special:AllMessages at this site.',
+'allmessagesnotsupportedUI' => 'Your current interface language <b>$1</b> is not supported by Special:AllMessages at this site. ',
 'allmessagesnotsupportedDB' => 'Special:AllMessages not supported because wgUseDatabaseMessages is off.',
 
 # Thumbnails
@@ -1742,6 +1742,14 @@ ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\');
 'sitesettings-performance' => 'Performance',
 'sitesettings-images' => 'Images',
 
+# short names for language variants used for language conversion links. 
+# to disable showing a particular link, set it to 'disable', e.g.
+# 'variantname-zh-sg' => 'disable',
+'variantname-zh-cn' => 'cn',
+'variantname-zh-tw' => 'tw',
+'variantname-zh-hk' => 'hk',
+'variantname-zh-sg' => 'sg',
+'variantname-zh' => 'zh',
 
 );
 
@@ -1798,6 +1806,12 @@ class Language {
                return false;
        }
 
+       # short names for language variants used for language conversion links. 
+       # so far only used by zh
+       function getVariantname( $code ) {
+               return wfMsg( 'variantname-' . $code );
+       }
+
        function specialPage( $name ) {
                return $this->getNsText(NS_SPECIAL) . ':' . $name;
        }
@@ -1851,7 +1865,8 @@ class Language {
 
        function getMonthName( $key ) {
                global $wgMonthNamesEn, $wgContLang;
-               if( get_class( $wgContLang ) == get_class( $this ) )
+               // see who called us and use the correct message function
+               if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
                        return wfMsgForContent($wgMonthNamesEn[$key-1]);
                else
                        return wfMsg($wgMonthNamesEn[$key-1]);
@@ -1864,15 +1879,17 @@ class Language {
 
        function getMonthAbbreviation( $key ) {
                global $wgMonthAbbreviationsEn, $wgContLang;
-               if( get_class( $wgContLang ) == get_class( $this ) )
+               // see who called us and use the correct message function
+               if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
                        return wfMsgForContent(@$wgMonthAbbreviationsEn[$key-1]);
                else
                        return wfMsg(@$wgMonthAbbreviationsEn[$key-1]);
        }
 
        function getWeekdayName( $key ) {
-               global $wgWeekdayNamesEn,  $wgContLang;
-               if( get_class( $wgContLang ) == get_class( $this ) )
+               global $wgWeekdayNamesEn, $wgContLang;
+               // see who called us and use the correct message function
+               if( get_class( $wgContLang->getLangObj() ) == get_class( $this ) )
                        return wfMsgForContent($wgWeekdayNamesEn[$key-1]);
                else
                        return wfMsg($wgWeekdayNamesEn[$key-1]);
@@ -2174,105 +2191,8 @@ class Language {
                return $text;
        }
 
-       # convert text to different variants of a language. the automatic
-       # conversion is done in autoConvert(). here we parse the text 
-       # marked with -{}-, which specifies special conversions of the 
-       # text that can not be accomplished in autoConvert()
-       #
-       # syntax of the markup:
-       # -{code1:text1;code2:text2;...}-  or
-       # -{text}- in which case no conversion should take place for text
+       # convert text to different variants of a language.
        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") {
-                       return $text;
-               }
-
-
-               $plang = $this->getPreferredVariant();
-               $fallback = $this->getVariantFallback($plang);
-
-               $tarray = explode("-{", $text);
-               $tfirst = array_shift($tarray);
-               $text = $this->autoConvert($tfirst);
-               
-               foreach($tarray as $txt) {
-                       $marked = explode("}-", $txt);
-                       
-                       $choice = explode(";", $marked{0});
-                       if(!array_key_exists(1, $choice)) {
-                               /* a single choice */
-                               $text .= $choice{0};
-                       } else {
-                               $choice1=false;
-                               $choice2=false;
-                               foreach($choice as $c) {
-                                       $v = explode(":", $c);
-                                       if(!array_key_exists(1, $v)) {
-                                               //syntax error in the markup, give up
-                                               break;                  
-                                       }
-                                       $code = trim($v{0});
-                                       $content = trim($v{1});
-                                       if($code == $plang) {
-                                               $choice1 = $content;
-                                               break;
-                                       }
-                                       if($code == $fallback)
-                                               $choice2 = $content;
-                               }
-                               if ( $choice1 )
-                                       $text .= $choice1;
-                               elseif ( $choice2 )
-                                       $text .= $choice2;
-                               else
-                                       $text .= $marked{0};
-                       }
-                       if(array_key_exists(1, $marked))
-                               $text .= $this->autoConvert($marked{1});
-               }
-               
-               return $text;
-       }
-
-       /* this does the real conversion to the preferred variant.
-          see LanguageZh.php for example
-       */
-       function autoConvert( $text, $toVariant=false ) {
-               return $text;
-       }
-
-       /* returns all possible variants of the given text
-
-          normally we will just call autoConvert() for each variant, but
-          in case of zh where the conversion is performed by zhdaemon, 
-          possibily over the network, we want to 
-          cut down the number of connections to save time. 
-       */
-       function autoConvertToAllVariants($text) {
-               $ret = array();
-               $variants = $this->getVariants();
-               if(sizeof($variants)==1) {
-                       return $false;
-               }
-               foreach( $variants as $lang=>$v ) {
-                       $ret[$v] = $this->autoConvert( $text, $v );
-               }
-               return $ret;
-       }
-
-       /* hook for converting the title, which may needs special treatment
-       */
-       function convertTitle( $text ) {
                return $text;
        }
 
@@ -2293,67 +2213,24 @@ class Language {
        }
 
        function getPreferredVariant() {
-               global $wgUser;
-
-               $lang ='';              
-
-               // if user logged in, get in from user's preference
-               if( $wgUser->getID() != 0 ) {
-                       $lang = $wgUser->getOption( 'variant' );
-               }
-               if($lang != '')
-                       return $lang;
-
-               // if we have multiple variants for this langauge, 
-               // pick the first one that's not utf8 (it could be
-               // utf8 if the language does not have a language file)
-               $v = $this->getVariants();
-               if( !empty( $v ) ) {
-                       return $v[0];
-               }
-               if($lang != '')
-                       return $lang;
-
-               // get it from the class name
-               $lang = strtolower( substr( get_class( $this ), 8 ) );
-
-               return $lang;
+               return strtolower( substr( get_class( $this ), 8 ) );
        }
 
        /* if a language supports multiple variants, it is
                possible that non-existing link in one variant
                actually exists in another variant. this function 
-               tries to find it.
+               tries to find it. See e.g. LanguageZh.php
 
        */
        function findVariantLink( &$link, &$nt ) {
-               static $count=0; //used to limit this operation
-               static $cache=array();
-               global $wgDisableLangConversion;
-               $count++;
-               if( $wgDisableLangConversion || $count > 50)
-                       return;
-               $variants = $this->autoConvertToAllVariants($link);
-               if($variants == false) //give up
-                       return;
-               foreach( $variants as $v ) {
-                       if(isset($cache[$v]))
-                               continue;
-                       $cache[$v] = 1;
-                       $varnt = Title::newFromText( $v );
-                       if( $varnt && $varnt->getArticleID() > 0 ) {
-                               $nt = $varnt;
-                               $link = $v;
-                               break;
-                       }
-               }
+               return;
        }
 
        /*
                returns an array of extra options used by User::getPageRenderHash()
        */
        function getExtraHashOptions() {
-               return array();
+               return '';
        }
        
        /**
@@ -2370,6 +2247,10 @@ class Language {
                return $trail;
        }
 
+       function getLangObj() {
+               return $this;
+       }
+
 }
 
 # This should fail gracefully if there's not a localization available
index ebc6658..f680133 100644 (file)
@@ -275,14 +275,8 @@ class LanguageLatin1 {
                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 getVariantname( $code ) {
+               return utf8_decode( $this->lang->getVariantname( $code ) );
        }
 
        function getVariants() {
@@ -294,9 +288,16 @@ class LanguageLatin1 {
        }       
 
        function getExtraHashOptions() {
-               return array();
+               return '';
+       }
+       
+       function linkTrail() {
+               return $this->lang->linkTrail();
        }
 
+       function getLangObj() {
+               return $this->lang;
+       }
 }
 
 ?>
index 842a480..bac6d1e 100644 (file)
@@ -16,15 +16,7 @@ class LanguageZh extends LanguageZh_cn {
        function LanguageZh() {
                global $wgUseZhdaemon, $wgZhdaemonHost, $wgZhdaemonPort;
                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) {
                        $this->mZhClient=new ZhClient($wgZhdaemonHost, $wgZhdaemonPort);
                        if(!$this->mZhClient->isconnected())
@@ -36,23 +28,29 @@ class LanguageZh extends LanguageZh_cn {
        }
        
        /* 
-               get preferred language variants. eventually this will check the
-               user's preference setting as well, once the language option in
-               the setting pages is finalized.
+               get preferred language variants.
        */
        function getPreferredVariant() {
-               global $wgUser;
+               global $wgUser, $wgRequest;
                
                if($this->mZhLanguageCode)
                        return $this->mZhLanguageCode;
-               
-               // get language variant preference for logged in users 
+
+               // see if the preference is set in the request
+               $zhreq = $wgRequest->getText( 'variant' );
+               if( in_array( $zhreq, $this->getVariants() ) ) {
+                       $this->mZhLanguageCode = $zhreq;
+                       return $zhreq;
+               }
+
+               // get language variant preference from logged in users 
                if($wgUser->getID()!=0) {
                        $this->mZhLanguageCode = $wgUser->getOption('variant');
                }
-               else {
+
+               if( !$this->mZhLanguageCode ) {
                        // see if some zh- variant is set in the http header,
-                       $this->mZhLanguageCode="zh-cn";
+                       $this->mZhLanguageCode="zh";
                        $header = str_replace( '_', '-', strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"]));
                        $zh = strstr($header, 'zh-');
                        if($zh) {
@@ -75,11 +73,11 @@ class LanguageZh extends LanguageZh_cn {
                        "\"$1\"", $text);
        }
 
-
-       
        function autoConvert($text, $toVariant=false) {
                if(!$toVariant) 
                        $toVariant = $this->getPreferredVariant();
+               if($toVariant == 'zh')
+                       return $text;
                $fname="zhautoConvert";
                wfProfileIn( $fname );
                $t = $this->mZhClient->convert($text, $toVariant);
@@ -92,12 +90,90 @@ class LanguageZh extends LanguageZh_cn {
                wfProfileIn( $fname );
                $ret = $this->mZhClient->convertToAllVariants($text);
                if($ret == false) {//fall back...
-                       $ret = Language::autoConvertToAllVariants($text);
+                       $ret = ZhClientFake::autoConvertToAllVariants($text);
                }
                wfProfileOut( $fname );
                return $ret;
        }
     
+       # convert text to different variants of a language. the automatic
+       # conversion is done in autoConvert(). here we parse the text 
+       # marked with -{}-, which specifies special conversions of the 
+       # text that can not be accomplished in autoConvert()
+       #
+       # syntax of the markup:
+       # -{code1:text1;code2:text2;...}-  or
+       # -{text}- in which case no conversion should take place for text
+       function convert( $text , $isTitle=false) {
+               global $wgDisableLangConversion;
+
+               if($wgDisableLangConversion)
+                       return $text; 
+               
+               // no conversion if redirecting
+               if(strtolower( substr( $text,0,9 ) ) == "#redirect") {
+                       return $text;
+               }
+
+               if( $isTitle ) {
+                       global $wgRequest;
+                       $isredir = $wgRequest->getText( 'redirect', 'yes' );
+                       $action = $wgRequest->getText( 'action' );
+                       if ( $isredir == 'no' || $action == 'edit' ) {
+                               return $text;
+                       }
+                       else {
+                               $text = $this->convertTitle($text);
+                               return $text;
+                       }
+               }
+
+               $plang = $this->getPreferredVariant();
+               $fallback = $this->getVariantFallback($plang);
+
+               $tarray = explode("-{", $text);
+               $tfirst = array_shift($tarray);
+               $text = $this->autoConvert($tfirst);
+               foreach($tarray as $txt) {
+                       $marked = explode("}-", $txt);
+                       
+                       $choice = explode(";", $marked{0});
+                       if(!array_key_exists(1, $choice)) {
+                               /* a single choice */
+                               $text .= $choice{0};
+                       } else {
+                               $choice1=false;
+                               $choice2=false;
+                               foreach($choice as $c) {
+                                       $v = explode(":", $c);
+                                       if(!array_key_exists(1, $v)) {
+                                               //syntax error in the markup, give up
+                                               break;                  
+                                       }
+                                       $code = trim($v{0});
+                                       $content = trim($v{1});
+                                       if($code == $plang) {
+                                               $choice1 = $content;
+                                               break;
+                                       }
+                                       if($code == $fallback)
+                                               $choice2 = $content;
+                               }
+                               if ( $choice1 )
+                                       $text .= $choice1;
+                               elseif ( $choice2 )
+                                       $text .= $choice2;
+                               else
+                                       $text .= $marked{0};
+                       }
+                       if(array_key_exists(1, $marked))
+                               $text .= $this->autoConvert($marked{1});
+               }
+               
+               return $text;
+       }
+
+
        # only convert titles having more than one character
        function convertTitle($text) {
                $len=0;
@@ -111,11 +187,12 @@ class LanguageZh extends LanguageZh_cn {
        }
 
        function getVariants() {
-               return array("zh-cn", "zh-tw", "zh-sg", "zh-hk");
+               return array("zh", "zh-cn", "zh-tw", "zh-sg", "zh-hk");
        }
 
        function getVariantFallback($v) {
                switch ($v) {
+               case 'zh': return 'zh-cn'; break;
                case 'zh-cn': return 'zh-sg'; break;
                case 'zh-sg': return 'zh-cn'; break;
                case 'zh-tw': return 'zh-hk'; break;
@@ -147,8 +224,34 @@ class LanguageZh extends LanguageZh_cn {
                return $ret;
        }
 
+       function findVariantLink( &$link, &$nt ) {
+               static $count=0; //used to limit this operation
+               static $cache=array();
+               global $wgDisableLangConversion;
+               $pref = $this->getPreferredVariant();
+               if( $wgDisableLangConversion || $pref == 'zh' || $count > 50)
+                       return;
+               $count++;
+               $variants = $this->autoConvertToAllVariants($link);
+               if($variants == false) //give up
+                       return;
+               foreach( $variants as $v ) {
+                       if(isset($cache[$v]))
+                               continue;
+                       $cache[$v] = 1;
+                       $varnt = Title::newFromText( $v );
+                       if( $varnt && $varnt->getArticleID() > 0 ) {
+                               $nt = $varnt;
+                               $link = $v;
+                               break;
+                       }
+               }
+       }
+
        function getExtraHashOptions() {
-               return array('variant', 'nolangconversion');
+               global $wgUser;
+               $variant = $this->getPreferredVariant();
+               return '!' . $variant ;
        }
 }
 ?>
index 581f687..cad289e 100644 (file)
@@ -151,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' => "星期日",
@@ -545,8 +545,7 @@ alt=\"Google\" align=\"middle\"></a>
 "rcnote"               => "下面是最近<strong>$2</strong>天内最新的<strong>$1</strong>次改动。",
 "rcnotefrom"   => "下面是自<b>$2</b>(最多显示<b>$1</b>)。",
 "rclistfrom"   => "显示自$1以来的新更改",
-# "rclinks"            => "显示最后$2小时/$3天内的$1此修改",
-"rclinks"              => "显示最近 $2 天内最新的 $1 次改动。",
+"rclinks"              => "显示最近 $2 天内最新的 $1 次改动。<br />$3",
 "rchide"               => "以$4形式;$1个小修改;$2个二级名字空间;$3个多重修改",
 "diff"                 => "差异",
 "hist"                 => "历史",
@@ -953,6 +952,69 @@ Wikipedia与这些公司并没有任何商业关系,因此本表不应该
 'mw_math_source' => "显示为TeX代码(使用文字浏览器时)",  /* "Leave it as TeX (for text browsers)" */
 'mw_math_modern' => "推荐为新版浏览器使用",  /* "Recommended for modern browsers" */
 
+# some untranslated messages as of 1.4 beta1
+'1movedto2' => "$1移动到$2", //"$1 moved to $2",
+'1movedto2_redir' => "$1重定向到$2", //"$1 moved to $2 over redirect",
+'acct_creation_throttle_hit' => "对不起,您已经注册了$1账号。你不能再注册了。", //"Sorry, you have already created $1 accounts. You can't make any more.",
+'addgroup' => "增加新的组", //"Add Group",
+'allarticles' => "所有条目", //"All articles",
+'allmessages' => "系统界面", //"All system messages",
+'allmessagesnotsupportedDB' => "系统界面功能处于关闭状态 (wgUseDatabaseMessages)。", //"Special:AllMessages not supported because wgUseDatabaseMessages is off.",
+'allmessagestext' => "这里列出所有可定制的系统界面。", //"This is a list of all system messages available in the MediaWiki: namespace.",
+'allpagesformtext1' => "列出从 $1 起的条目", //"Display pages starting at: $1",
+'allpagesformtext2' => "选定名字空间: $1 $1", //"Choose namespace: $1 $2",
+'allpagesnamespace' => "所有 $1 名字空间的条目", //"All pages ($1 namespace)",
+'allpagesnext' => "下一页", //"Next",
+'allpagesprev' => "上一页", //"Previous",
+'allpagessubmit' => "提交", //"Go",
+'ancientpages' => "老条目", //"Oldest pages",
+'and' => "和", //"and",
+'anontalk' => "该IP的对话页", //"Talk for this IP",
+'anonymous' => "匿名用户", //"Anonymous user(s) of 1.4",
+'article' => "条目", //"Content page",
+'autoblocker' => "你的IP和被封了的 \"$1\" 是一样的。封锁原因: \"$2\".",//"Autoblocked because you share an IP address with \"$1\". Reason \"$2\".",
+'blocklogentry' => "封锁 $1, $2",//"blocked \"$1\" with an expiry time of $2",
+'blocklogpage' => "封锁记录", //"Block_log",
+'categoriespagetext' => "以下列出所有的页面分类。", //"The following categories exists in the wiki.",
+'categoryarticlecount' => "该类页面共有 $1 条目", //There are $1 articles in this category.",
+'clearyourcache' => "'''注意:''' 保存设置后,要清掉浏览器的缓存才能生效:'''Mozilla:''' 点''刷新'' (或用快键''Ctrl-R''),'''IE / Opera:''' ''Ctrl-F5'', '''Safari:''' ''Cmd-R'', '''Konqueror''' ''Ctrl-R''。",//"'''Note:''' After saving, you have to clear your browser cache to see the changes: '''Mozilla:''' click ''Reload'' (or ''Ctrl-R''), '''IE / Opera:''' ''Ctrl-F5'', '''Safari:''' ''Cmd-R'', '''Konqueror''' ''Ctrl-R''.",
+'edit' => "编辑", //"Edit",
+'navigation' => "导航", //"Navigation",
+'nstab-category' => "分类", //"Category",
+'nstab-help' => "帮助",//"Help",
+'nstab-image' => "图像",//"Image",
+'nstab-main' => "条目", //"Article",
+'nstab-mediawiki' => "界面",//"Message",
+'nstab-special' => "特殊",//"Special",
+'nstab-template' => "模板", //"Template",
+'nstab-user' => "用户页面", //"User page",
+'nstab-wp' => "关于", //"About",
+'portal' => "社区",//"Community portal",
+'prefs-help-userdata' => "*<strong>真实姓名</strong>(可选):用以对您的贡献署名。<br />*<strong>点子邮件</strong>(可选):让他人通过网站在不知道您的电子邮件地址的情况下通过电子邮件与您联络,以及通过电子邮件取得遗忘的密码。", /*"* <strong>Real name</strong> (optional): if you choose to provide it this will be used for giving you attribution for your work.<br />
+* <strong>Email</strong> (optional): Enables people to contact you through the website without you having to reveal your
+email address to them, and it can be used to send you a new password if you forget it.", */
+'prefs-misc' => "杂项", //"Misc settings",
+'prefs-personal' => "用户数据",//"User data",
+'prefs-rc' => "最近更新", //"Recent changes and stub display",
+'showhideminor' => "$1 小修改 | $2 bots | $3 登录用户 | $4 检查过的", //"$1 minor edits | $2 bots | $3 logged in users | $4 patrolled edits ",
+'skin' => "皮肤", //"Skin",
+'talk' => "讨论",//"Discussion",
+'timezonelegend' => "时区", //"Time zone",
+'toolbox' => "工具",//"Toolbox",
+'watch' => "监视",//"Watch",
+'yourlanguage' => "界面语言", //"Your language"
+'yourrealname' => "真实姓名*", //"Your real name"
+'yourvariant' => "中文字体", //"language variant"
+
+# short names for language variants used for language conversion links. 
+# to disable showing a particular link, set it to 'disable', e.g.
+# 'variantname-zh-sg' => 'disable',
+'variantname-zh-cn' => '大陆简体',
+'variantname-zh-tw' => '台湾繁体',
+'variantname-zh-hk' => '香港繁体',
+'variantname-zh-sg' => '新加坡简体',
+'variantname-zh' => '不转换',
+
 );
 
 class LanguageZh_cn extends LanguageUtf8 {
index 7e54838..0fa99a8 100644 (file)
@@ -543,8 +543,7 @@ alt=\"Google\" align=\"middle\"></a>
 "rcnote"               => "下面是最近<strong>$2</strong>天內最新的<strong>$1</strong>次改動。",
 "rcnotefrom"   => "下面是自<b>$2</b>(最多顯示<b>$1</b>)。",
 "rclistfrom"   => "顯示自$1以來的新更改",
-# "rclinks"            => "顯示最後$2小時/$3天內的$1此修改",
-"rclinks"              => "顯示最近 $2 天內最新的 $1 次改動。",
+"rclinks"              => "顯示最近 $2 天內最新的 $1 次改動。<br />$3",
 "rchide"               => "以$4形式;$1個小修改;$2個二級名字空間;$3個多重修改",
 "diff"                 => "差異",
 "hist"                 => "歷史",
@@ -937,6 +936,61 @@ alt=\"Google\" align=\"middle\"></a>
 "talkpagemoved" => "相應的對話頁也已經移動。",
 "talkpagenotmoved" => "相應的對話頁<strong>沒有</strong>被移動。",
 
+
+# some untranslated messages as of 1.4 beta1
+'1movedto2' => "$1移動到$2", //"$1 moved to $2",
+'1movedto2_redir' => "$1重定向到$2", //"$1 moved to $2 over redirect",
+'acct_creation_throttle_hit' => "對不起,您已經註冊了$1賬號。你不能再註冊了。", //"Sorry, you have already created $1 accounts. You can't make any more.",
+'addgroup' => "增加新的組", //"Add Group",
+'allarticles' => "所有條目", //"All articles",
+'allmessages' => "系統界面", //"All system messages",
+'allmessagesnotsupportedDB' => "系統界面功能處於關閉狀態 (wgUseDatabaseMessages)。", //"Special:AllMessages not supported because wgUseDatabaseMessages is off.",
+'allmessagestext' => "這裡列出所有可定製的系統界面。", //"This is a list of all system messages available in the MediaWiki: namespace.",
+'allpagesformtext1' => "列出從 $1 起的條目", //"Display pages starting at: $1",
+'allpagesformtext2' => "選定名字空間: $1 $1", //"Choose namespace: $1 $2",
+'allpagesnamespace' => "所有 $1 名字空間的條目", //"All pages ($1 namespace)",
+'allpagesnext' => "下一頁", //"Next",
+'allpagesprev' => "上一頁", //"Previous",
+'allpagessubmit' => "提交", //"Go",
+'ancientpages' => "老條目", //"Oldest pages",
+'and' => "和", //"and",
+'anontalk' => "該IP的對話頁", //"Talk for this IP",
+'anonymous' => "匿名用戶", //"Anonymous user(s) of 1.4",
+'article' => "條目", //"Content page",
+'autoblocker' => "你的IP和被封了的 \"$1\" 是一樣的。封鎖原因: \"$2\".",//"Autoblocked because you share an IP address with \"$1\". Reason \"$2\".",
+'blocklogentry' => "封鎖 $1, $2",//"blocked \"$1\" with an expiry time of $2",
+'blocklogpage' => "封鎖記錄", //"Block_log",
+'categoriespagetext' => "以下列出所有的頁面分類。", //"The following categories exists in the wiki.",
+'categoryarticlecount' => "該類頁面共有 $1 條目", //There are $1 articles in this category.",
+'clearyourcache' => "'''註意:''' 保存設置後,要清掉瀏覽器的緩存才能生效:'''Mozilla:''' 點''刷新'' (或用快鍵''Ctrl-R''),'''IE / Opera:''' ''Ctrl-F5'', '''Safari:''' ''Cmd-R'', '''Konqueror''' ''Ctrl-R''。",//"'''Note:''' After saving, you have to clear your browser cache to see the changes: '''Mozilla:''' click ''Reload'' (or ''Ctrl-R''), '''IE / Opera:''' ''Ctrl-F5'', '''Safari:''' ''Cmd-R'', '''Konqueror''' ''Ctrl-R''.",
+'edit' => "編輯", //"Edit",
+'navigation' => "導航", //"Navigation",
+'nstab-category' => "分類", //"Category",
+'nstab-help' => "幫助",//"Help",
+'nstab-image' => "圖像",//"Image",
+'nstab-main' => "條目", //"Article",
+'nstab-mediawiki' => "界面",//"Message",
+'nstab-special' => "特殊",//"Special",
+'nstab-template' => "模板", //"Template",
+'nstab-user' => "用戶頁面", //"User page",
+'nstab-wp' => "關於", //"About",
+'portal' => "社區",//"Community portal",
+'prefs-help-userdata' => "*<strong>真實姓名</strong>(可選):用以對您的貢獻署名。<br />*<strong>點子郵件</strong>(可選):讓他人通過網站在不知道您的電子郵件地址的情況下通過電子郵件與您聯絡,以及通過電子郵件取得遺忘的密碼。", /*"* <strong>Real name</strong> (optional): if you choose to provide it this will be used for giving you attribution for your work.<br />
+* <strong>Email</strong> (optional): Enables people to contact you through the website without you having to reveal your
+email address to them, and it can be used to send you a new password if you forget it.", */
+'prefs-misc' => "雜項", //"Misc settings",
+'prefs-personal' => "用戶數據",//"User data",
+'prefs-rc' => "最近更新", //"Recent changes and stub display",
+'showhideminor' => "$1 小修改 | $2 bots | $3 登錄用戶 | $4 檢查過的", //"$1 minor edits | $2 bots | $3 logged in users | $4 patrolled edits ",
+'skin' => "皮膚", //"Skin",
+'talk' => "討論",//"Discussion",
+'timezonelegend' => "時區", //"Time zone",
+'toolbox' => "工具",//"Toolbox",
+'watch' => "監視",//"Watch",
+'yourlanguage' => "界面語言", //"Your language"
+'yourrealname' => "真實姓名*", //"Your real name"
+'yourvariant' => "中文字體", //"language variant"
+
 );
 
 class LanguageZh_tw extends LanguageZh_cn {
index ee0c91b..50072c4 100644 (file)
@@ -150,6 +150,21 @@ class SkinCologneBlue extends Skin {
                        $s .=  $this->makeKnownLink( $li, wfMsg( "login" ), $q );
                }
 
+               /* show links to different language variants */
+               global $wgDisableLangConversion;
+               $variants = $wgContLang->getVariants();
+               if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
+                       $actstr = '';
+                       foreach( $variants as $code ) {
+                               $varname = $wgContLang->getVariantname( $code );
+                               if( $varname == 'disable' )
+                                       continue;
+                               $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
+                       }
+               }
+
+
+
                return $s;
        }
 
index 754af28..0d13364 100644 (file)
@@ -790,7 +790,7 @@ li#pt-login {
 }
 /* offsets to distinguish the tab groups */
 li#ca-talk { margin-right: 1.6em; }
-li#ca-watch, li#ca-watch { margin-left: 1.6em; }
+li#ca-watch, li#ca-watch, li#ca-varlang-0 { margin-left: 1.6em; }
 
 
 /*