From 6b5af67986b4ae39ae351fec5bda623a87c6c41c Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Sat, 1 May 2004 15:42:11 +0000 Subject: [PATCH] optional ?ot=php argument to get a copy&pasteable php representation of the mediawiki messages possible update route: 1) get a sorted dump of the default messages (from a clean, fresh install) 2) same for the updated mediawiki messages 3) diff/merge using your favourite editor while paying attention to the wp-specific things --- includes/SpecialAllmessages.php | 132 +++++++++++++++++++------------- 1 file changed, 79 insertions(+), 53 deletions(-) diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index e5322bf90b..93a6ea637a 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -1,60 +1,86 @@ getNsText( NS_TALK ); - $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI ); - $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK ); - $mwMsg =& MagicWord::get( MAG_MSG ); - $navText = str_replace( "$1", $mwMsg->getSynonym( 0 ), wfMsg("allmessagestext" ) ); - $navText .= " - -"; - - $first = true; - $sortedArray = $wgAllMessagesEn; - ksort( $sortedArray ); - - foreach ( $sortedArray as $key => $enMsg ) { - - $titleObj = Title::newFromText( $key ); - $title = $titleObj->getDBkey(); - - $wgMessageCache->disable(); - $message = wfMsg( $key ); - $wgMessageCache->enable(); - $mw = wfMsg ( $key ); - - $colorIt = ($message == $mw) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\""; - - $message = wfEscapeWikiText( $message ); - $mw = wfEscapeWikiText( $mw ); - -# [$wgServer$wgScript?title=$mwnspace:$title&action=edit $key]
- $navText .= -""; + function wfSpecialAllmessages() + { + global $wgOut, $wgAllMessagesEn, $wgRequest; + $ot = $wgRequest->getText('ot'); + $mwMsg =& MagicWord::get( MAG_MSG ); + set_time_limit(0); + $navText = str_replace( "$1", $mwMsg->getSynonym( 0 ), wfMsg("allmessagestext" ) ); + + $first = true; + $sortedArray = $wgAllMessagesEn; + ksort( $sortedArray ); + $messages = array(); + foreach ( $sortedArray as $key => $enMsg ) { + + $messages[$key]['enmsg'] = $enMsg; + $messages[$key]['statmsg'] = wfMsgNoDB( $key ); + $messages[$key]['msg'] = wfMsg ( $key ); + } + if ($ot == 'php') { + $navText .= makePhp($messages); + $wgOut->addHTML('
'.htmlspecialchars($navText).'
'); + } else { + $navText .= makeWikiText($messages); + $wgOut->addWikiText( $navText ); + } + return; } + function makePhp($messages) { + global $wgLanguageCode; + $txt = "\n\n".'$wgAllMessages'.ucfirst($wgLanguageCode).' = array('."\n"; + foreach( $messages as $key => $m ) { + if(strtolower($wgLanguageCode) != 'en' and $m['msg'] == $m['enmsg'] ) { + $comment = ' #default'; + } elseif ($m['msg'] == '<'.$key.'>'){ + $m['msg'] = ''; + $comment = ' #empty'; + } else { + $comment = ''; + } + $txt .= " '".$key."' => \"".str_replace('"','\"',$m['msg'])."\",$comment\n"; + } + $txt .= ');'; + return $txt; + } + - $navText .= "
- '''Name''' - - '''Default text''' - - '''Current text''' -
- [[$mwnspace:$title|$key]]
- [[$mwtalk:$title|$talk]] -
- $message - - $mw -
"; + function makeWikiText($messages) { + global $wgLang; + $talk = $wgLang->getNsText( NS_TALK ); + $mwnspace = $wgLang->getNsText( NS_MEDIAWIKI ); + $mwtalk = $wgLang->getNsText( NS_MEDIAWIKI_TALK ); + $txt = " - $wgOut->addWikiText( $navText ); + "; + foreach( $messages as $key => $m ) { + $titleObj = Title::newFromText( $key ); + $title = $titleObj->getDBkey(); - return; -} + $colorIt = ($m['statmsg'] == $m['msg']) ? " bgcolor=\"#f0f0ff\"" : " bgcolor=\"#ffe2e2\""; + $message = wfEscapeWikiText( $m['statmsg'] ); + $mw = wfEscapeWikiText( $m['msg'] ); + + $txt .= + ""; + } + $txt .= "
+ '''Name''' + + '''Default text''' + + '''Current text''' +
+ [[$mwnspace:$title|$key]]
+ [[$mwtalk:$title|$talk]] +
+ $message + + $mw +
"; + + return $txt; + } -?> + ?> -- 2.20.1