Translation checker added (nl: fixed); more conditional inclusion; misc. tweaks
authorTim Starling <tstarling@users.mediawiki.org>
Sat, 25 Oct 2003 08:01:33 +0000 (08:01 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sat, 25 Oct 2003 08:01:33 +0000 (08:01 +0000)
includes/Article.php
includes/OutputPage.php
includes/Profiling.php
includes/Setup.php
includes/Skin.php
languages/Language.php
languages/LanguageNl.php
maintenance/checktrans2.php [new file with mode: 0755]
wiki.phtml

index 326cda5..43fda88 100644 (file)
@@ -255,7 +255,7 @@ class Article {
        {
                global $wgUser, $wgOut, $wgLang;
                global $oldid, $diff; # From query
-               global $wgLinkCache;
+               global $wgLinkCache, $IP;
                $fname = "Article::view";
                wfProfileIn( $fname );
 
@@ -266,6 +266,7 @@ class Article {
                # diff page instead of the article.
 
                if ( isset( $diff ) ) {
+                       include_once( "$IP/DifferenceEngine.php" );
                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                        $de = new DifferenceEngine( $oldid, $diff );
                        $de->showDiffPage();
index 5d8982d..adc63df 100644 (file)
@@ -240,6 +240,10 @@ class OutputPage {
        {
                global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
                global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
+               
+               $fname = "OutputPage::output";
+               wfProfileIn( $fname );
+               
                $sk = $wgUser->getSkin();
 
                $this->sendCacheControl();
@@ -1196,7 +1200,7 @@ $t[] = "</table>" ;
        /* private */ function replaceVariables( $text )
        {
                global $wgLang;
-               $fname = "OutputPage:replaceVariables";
+               $fname = "OutputPage::replaceVariables";
                wfProfileIn( $fname );
 
                /* As with sigs, use server's local time --
index e82fd23..ee82e4f 100755 (executable)
@@ -78,14 +78,15 @@ class Profiler
                $prof .= sprintf( $titleFormat, "Name", "Calls", "Total", "Each", "%" );
                $this->mCollated = array();
                $this->mCalls = array();
-               $total = 0;
                
                # Estimate profiling overhead
                $profileCount = count( $this->mStack );
+               wfProfileIn( "-overhead-total" );
                for ($i=0; $i<$profileCount ; $i++) {
-                       wfProfileIn( "--profiling overhead--" );
-                       wfProfileOut( "--profiling overhead--" );
+                       wfProfileIn( "-overhead-internal" );
+                       wfProfileOut( "-overhead-internal" );
                }
+               wfProfileOut( "-overhead-total" );
                
                # Collate
                foreach ( $this->mStack as $entry ) {
@@ -98,19 +99,17 @@ class Profiler
                        $elapsed = $end - $start;
                        $this->mCollated[$fname] += $elapsed;
                        $this->mCalls[$fname] ++;
-                       
-                       if ( $fname != "--profiling overhead--" ) {
-                               $total += $elapsed;
-                       }
                }
-               
-               $overhead = $this->mCollated["--profiling overhead--"] / $this->mCalls["--profiling overhead--"];
-               
+
+               $total = $this->mCollated["-total"];
+               $overhead = $this->mCollated["-overhead-internal"] / $profileCount;
+               $this->mCalls["-overhead-total"] = $profileCount;
+
                # Output
                foreach ( $this->mCollated as $fname => $elapsed ) {
                        $calls = $this->mCalls[$fname];
                        # Adjust for overhead
-                       if ( $fname != "--profiling overhead--" ) {
+                       if ( $fname[0] != "-" ) {
                                $elapsed -= $overhead * $calls;
                        }
                        
@@ -125,5 +124,6 @@ class Profiler
 }
 
 $wgProfiler = new Profiler();
+$wgProfiler->profileIn( "-total" );
 
 ?>
index d12a96b..ee96f3d 100644 (file)
@@ -6,12 +6,29 @@
 #
 
 global $IP;
+
+if( !isset( $wgProfiling ) )
+       $wgProfiling = false;
+
+if ( $wgProfiling ) {
+       include_once( "$IP/Profiling.php" );
+} else {
+       function wfProfileIn( $fn ) {}
+       function wfProfileOut( $fn = "" ) {}
+       function wfGetProfilingOutput( $s, $e ) {}
+       function wfProfileClose() {}
+}
+
+$fname = "Setup.php";
+wfProfileIn( $fname );
+wfProfileIn( "$fname-includes" );
+
+# Only files which are used on every invocation should be included here
+# Otherwise, include them conditionally [TS]
 include_once( "$IP/GlobalFunctions.php" );
 include_once( "$IP/Namespace.php" );
 include_once( "$IP/Skin.php" );
 include_once( "$IP/OutputPage.php" );
-include_once( "$IP/DifferenceEngine.php" );
-include_once( "$IP/SearchEngine.php" );
 include_once( "$IP/User.php" );
 include_once( "$IP/LinkCache.php" );
 include_once( "$IP/Title.php" );
@@ -20,6 +37,8 @@ include_once( "$IP/MagicWord.php" );
 include_once( "$IP/MemCachedClient.inc.php" );
 include_once( "$IP/Block.php" );
 
+wfProfileOut( "$fname-includes" );
+wfProfileIn( "$fname-memcached" );
 global $wgUser, $wgLang, $wgOut, $wgTitle;
 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
 global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
@@ -42,6 +61,8 @@ if( $wgUseMemCached ) {
                $wgUseMemCached = false;
        }
 }
+wfProfileOut( "$fname-memcached" );
+wfProfileIn( "$fname-misc" );
 
 include_once( "$IP/Language.php" );
 
@@ -55,21 +76,14 @@ if( ! class_exists( $wgLangClass ) ) {
 }
 $wgLang = new $wgLangClass();
 
-if( !isset( $wgProfiling ) )
-       $wgProfiling = false;
-
-if ( $wgProfiling ) {
-       include_once( "$IP/Profiling.php" );
-} else {
-       function wfProfileIn( $fn ) {}
-       function wfProfileOut( $fn = "" ) {}
-       function wfGetProfilingOutput( $s, $e ) {}
-       function wfProfileClose() {}
-}
 
 $wgUser = User::loadFromSession();
 $wgDeferredUpdateList = array();
 $wgLinkCache = new LinkCache();
 $wgMagicWords = array();
 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
+
+wfProfileOut( "$fname-misc" );
+wfProfileOut( $fname );
+
 ?>
index 99400a8..6558e81 100644 (file)
@@ -356,11 +356,14 @@ class Skin {
                global $wgUser, $wgOut, $wgLang;
                $fname =  "Skin::doAfterContent";
                wfProfileIn( $fname );
+               wfProfileIn( "$fname-1" );
 
                $s = "\n</div><br clear=all>\n";
-
                $s .= "\n<div id='footer'>";
                $s .= "<table width='98%' border=0 cellspacing=0><tr>";
+               
+               wfProfileOut( "$fname-1" );
+               wfProfileIn( "$fname-2" );
 
                $qb = $this->qbSetting();
                $shove = ($qb != 0);
@@ -370,6 +373,8 @@ class Skin {
                if ( $shove && $left ) { # Left
                        $s .= $this->getQuickbarCompensator();
                }
+               wfProfileOut( "$fname-2" );
+               wfProfileIn( "$fname-3" );
                $l = $wgLang->isRTL() ? "right" : "left";
                $s .= "<td class='bottom' align='$l' valign='top'>";
 
@@ -385,8 +390,11 @@ class Skin {
                        $s .= $this->getQuickbarCompensator();
                }
                $s .= "</tr></table>\n</div>\n</div>\n";
-
+               
+               wfProfileOut( "$fname-3" );
+               wfProfileIn( "$fname-4" );
                if ( 0 != $qb ) { $s .= $this->quickBar(); }
+               wfProfileOut( "$fname-4" );
                wfProfileOut( $fname );
                return $s;
        }
@@ -1139,7 +1147,10 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
        # otherwise the cache won't get updated properly.  See LINKCACHE.DOC.
        #
        function makeLink( $title, $text = "", $query = "", $trail = "" ) {
-               return $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail );
+               wfProfileIn( "Skin::makeLink" );
+               $result = $this->makeLinkObj( Title::newFromText( $title ), $text, $query, $trail );
+               wfProfileOut( "Skin::makeLink" );
+               return $result;
        }
 
        function makeKnownLink( $title, $text = "", $query = "", $trail = "" ) {
@@ -1158,8 +1169,6 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
        function makeLinkObj( &$nt, $text= "", $query = "", $trail = "" )
        {
                global $wgOut, $wgUser;
-               $fname = "Skin::makeLinkObj";
-               wfProfileIn( $fname );
                if ( $nt->isExternal() ) {
                        $u = $nt->getFullURL();
                        if ( "" == $text ) { $text = $nt->getPrefixedText(); }
@@ -1207,7 +1216,6 @@ if ( isset ( $wgUseApproval ) && $wgUseApproval )
                                }
                        }
                }
-               wfProfileOut( $fname );
                return $retVal;
        }
 
index 684af7a..6cf4f84 100644 (file)
@@ -1,5 +1,4 @@
 <?
-
 #--------------------------------------------------------------------------
 # Constants
 #--------------------------------------------------------------------------
index a215f01..e104087 100644 (file)
  "ab" => "Apsua byzwa",
  "ar" => "&#8238;&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;&#8236;",
  "as" => "Asami",
- "av" => "Avara"
+ "av" => "Avara",
  "ay" => "Aymara",
  "az" => "Azerbacan",
- "bm" => "Bambankan"
+ "bm" => "Bambankan",
  "ba" => "Baskort",
  "be" => "&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1080;",
  "bg" => "Bülgarski ezik",
  "lv" => "Latvie&scaron;u",
  "ln" => "Lingala",
  "lt" => "Lietuvi&#371;",
'lg" => "Luganda",
"lg" => "Luganda",
  "hu" => "Magyar",
  "mk" => "Makedonski",
  "mg" => "Malagasy",
  "tw" => "Twi",
  "uk" => "&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;",
  "ur" => "Urdu",
- "ve" => Tshivenda",
+ "ve" => "Tshivenda",
  "vi" => "Tiêng Viêt Nam",
  "vo" => "Volapük",
  "wo" => "Wolof",
diff --git a/maintenance/checktrans2.php b/maintenance/checktrans2.php
new file mode 100755 (executable)
index 0000000..f36755b
--- /dev/null
@@ -0,0 +1,104 @@
+<?
+
+# Checks translation of all language files
+function wfLocalUrl() { return "";}
+function wfLocalUrle() { return "";}
+
+function check($arrayname, $lang, $text)
+{
+       $arraynameprinted = 0;
+       
+       global $count, $total;
+
+       $msgarray = $arrayname . ucfirst( $lang );
+       $msgarrayen = $arrayname . "En";
+
+       eval( $text );
+       if ( !is_array( $$msgarrayen ) ) {
+               print "\nArray '$msgarrayen' not present\n";
+               return;
+       } elseif ( !is_array( $$msgarray ) ) {
+               print "\nArray '$msgarray' not present\n";
+               return;
+       }
+
+       foreach ( $$msgarrayen as $code => $msg ) {
+               ++$total;
+
+               if ( ! array_key_exists( $code, $$msgarray ) ) {
+                       if (!$arraynameprinted) {
+                               print("\nIn array '$msgarray':\n");
+                               $arraynameprinted = 1;
+                       }
+                       
+                       if ( is_numeric( $code ) ) {
+                               print "$code ($msg)\n";
+                       } else {
+                               print "{$code}\n";
+                       }
+                       ++$count;
+               }
+       }
+}
+
+function getLanguage( $lang )
+{
+       $fileName = "../languages/Language" . ucfirst( $lang ) . ".php";
+       $file = fopen( $fileName, "r" );
+       $text = fread( $file, filesize( $fileName ) );
+       $clipPos = strpos( $text, "class Language" );
+       $text = substr( $text, 0, $clipPos );
+       $text = preg_replace( "/^<\?(php|)/", "", $text );
+       $text = preg_replace( "/^include.*$/m", "", $text );
+       
+       return $text;
+}
+       
+function checkLanguage( $lang, $enText ) 
+{
+       $text = $enText . getLanguage( $lang );
+       check("wgLanguageNames", $lang, $text);
+       check("wgNamespaceNames", $lang, $text);
+       check("wgDefaultUserOptions", $lang, $text);
+       check("wgQuickbarSettings", $lang, $text);
+       check("wgSkinNames", $lang, $text);
+       check("wgMathNames", $lang, $text);
+       check("wgUserToggles", $lang, $text);
+       check("wgWeekdayNames", $lang, $text);
+       check("wgMonthNames", $lang, $text);
+       check("wgMonthAbbreviations", $lang, $text);
+       check("wgValidSpecialPages", $lang, $text);
+       check("wgSysopSpecialPages", $lang, $text);
+       check("wgDeveloperSpecialPages", $lang, $text);
+       check("wgAllMessages", $lang, $text);
+}
+
+if ( $argc > 1 ) {
+       array_shift( $argv );
+       $glob = implode( " ", $argv );
+} else {
+       $glob = "../languages/Language?*.php";
+}
+
+umask( 000 );
+set_time_limit( 0 );
+$count = $total = 0;
+$enText = getLanguage( "" );
+$filenames = glob( $glob );
+$width = 80;
+foreach ( $filenames as $filename ) {
+       if ( preg_match( "/languages\/Language(.*)\.php/", $filename, $m ) ) {
+               $lang = strtolower( $m[1] );
+               if ( $lang != "utf8" ) {
+                       print "\n" . str_repeat( "-", $width );
+                       print "\n$lang\n";
+                       print str_repeat( "-", $width ) . "\n";
+                       checkLanguage( $lang, $enText );
+               }
+       }
+}
+
+print "\n" . str_repeat( "-", $width ) . "\n";
+print "{$count} messages of {$total} not translated.\n";
+
index ef7798a..27d9e4c 100644 (file)
@@ -50,6 +50,7 @@ wfProfileOut();
 if ( -1 == $wgTitle->getNamespace() ) {
        wfSpecialPage();
 } else if ( "" != $search ) {
+       include_once( "$IP/SearchEngine.php" );
        if($go) {
        
                wfGo ($search);