From 0f6234916a965c2bed4265cea1a969b9ea65649f Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sat, 25 Oct 2003 08:01:33 +0000 Subject: [PATCH] Translation checker added (nl: fixed); more conditional inclusion; misc. tweaks --- includes/Article.php | 3 +- includes/OutputPage.php | 6 ++- includes/Profiling.php | 22 ++++---- includes/Setup.php | 40 +++++++++----- includes/Skin.php | 20 ++++--- languages/Language.php | 1 - languages/LanguageNl.php | 8 +-- maintenance/checktrans2.php | 104 ++++++++++++++++++++++++++++++++++++ wiki.phtml | 1 + 9 files changed, 168 insertions(+), 37 deletions(-) create mode 100755 maintenance/checktrans2.php diff --git a/includes/Article.php b/includes/Article.php index 326cda56a4..43fda886ee 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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(); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 5d8982d85d..adc63df86e 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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[] = "" ; /* private */ function replaceVariables( $text ) { global $wgLang; - $fname = "OutputPage:replaceVariables"; + $fname = "OutputPage::replaceVariables"; wfProfileIn( $fname ); /* As with sigs, use server's local time -- diff --git a/includes/Profiling.php b/includes/Profiling.php index e82fd23fac..ee82e4f121 100755 --- a/includes/Profiling.php +++ b/includes/Profiling.php @@ -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" ); ?> diff --git a/includes/Setup.php b/includes/Setup.php index d12a96b5e9..ee96f3d496 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -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 ); + ?> diff --git a/includes/Skin.php b/includes/Skin.php index 99400a8f97..6558e810d6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -356,11 +356,14 @@ class Skin { global $wgUser, $wgOut, $wgLang; $fname = "Skin::doAfterContent"; wfProfileIn( $fname ); + wfProfileIn( "$fname-1" ); $s = "\n
\n"; - $s .= "\n\n\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; } diff --git a/languages/Language.php b/languages/Language.php index 684af7a0ad..6cf4f84574 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1,5 +1,4 @@ "Apsua byzwa", "ar" => "‮العربية‬", "as" => "Asami", - "av" => "Avara" + "av" => "Avara", "ay" => "Aymara", "az" => "Azerbacan", - "bm" => "Bambankan" + "bm" => "Bambankan", "ba" => "Baskort", "be" => "Беларуски", "bg" => "Bülgarski ezik", @@ -155,7 +155,7 @@ "lv" => "Latviešu", "ln" => "Lingala", "lt" => "Lietuvių", - 'lg" => "Luganda", + "lg" => "Luganda", "hu" => "Magyar", "mk" => "Makedonski", "mg" => "Malagasy", @@ -224,7 +224,7 @@ "tw" => "Twi", "uk" => "Українська", "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 index 0000000000..f36755b864 --- /dev/null +++ b/maintenance/checktrans2.php @@ -0,0 +1,104 @@ + $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"; + diff --git a/wiki.phtml b/wiki.phtml index ef7798a22b..27d9e4cb63 100644 --- a/wiki.phtml +++ b/wiki.phtml @@ -50,6 +50,7 @@ wfProfileOut(); if ( -1 == $wgTitle->getNamespace() ) { wfSpecialPage(); } else if ( "" != $search ) { + include_once( "$IP/SearchEngine.php" ); if($go) { wfGo ($search); -- 2.20.1