From e30e9bdd1285095da3c431d98a833593275fd9f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Sat, 29 Apr 2006 13:15:19 +0000 Subject: [PATCH] * Parser can now know that it is parsing an interface message * (bug 4737) MediaWiki:Viewcount supports {{PLURAL}} now --- RELEASE-NOTES | 2 ++ includes/GlobalFunctions.php | 6 +++--- includes/OutputPage.php | 6 ++++-- includes/Parser.php | 17 +++++++++++------ includes/Skin.php | 2 +- includes/SkinTemplate.php | 2 +- includes/SpecialUserlogout.php | 2 +- languages/Messages.php | 2 +- languages/MessagesFi.php | 2 +- 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6497f62a66..53ab7eef91 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -138,6 +138,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 5741) Introduce {{NUMBEROFUSERS}} magic word * (bug 93) tags and tildes in templates * The returnto parameter is now actually used by SpecialUserlogin.php +* Parser can now know that it is parsing an interface message +* (bug 4737) MediaWiki:Viewcount supports {{PLURAL}} now == Compatibility == diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 97f9638eb0..53a7bdbc45 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -564,16 +564,16 @@ function wfMsgExt( $key, $options ) { $options = array($options); } - $string = wfMsgGetKey( $key, true ); + $string = wfMsgGetKey( $key, true, false, false ); if( !in_array('replaceafter', $options) ) { $string = wfMsgReplaceArgs( $string, $args ); } if( in_array('parse', $options) ) { - $string = $wgOut->parse( $string, true ); + $string = $wgOut->parse( $string, true, true ); } elseif ( in_array('parseinline', $options) ) { - $string = $wgOut->parse( $string, true ); + $string = $wgOut->parse( $string, true, true ); if( preg_match( "~^

(.*)\n?

$~", $string, $m = null ) ) { $string = $m[1]; } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index d6e653acb0..3062e1f834 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -352,12 +352,14 @@ class OutputPage { } /** - * Parse wikitext and return the HTML. This is for special pages that add the text later + * Parse wikitext and return the HTML. */ - function parse( $text, $linestart = true ) { + function parse( $text, $linestart = true, $interface = false ) { global $wgParser, $wgTitle; + if ( $interface) { $this->mParserOptions->setInterfaceMessage(true); } $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart, true, $this->mRevisionId ); + if ( $interface) { $this->mParserOptions->setInterfaceMessage(false); } return $parserOutput->getText(); } diff --git a/includes/Parser.php b/includes/Parser.php index fcbb603a16..83ee8ecc71 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2472,7 +2472,7 @@ class Parser * @private */ function braceSubstitution( $piece ) { - global $wgContLang, $wgAllowDisplayTitle, $action; + global $wgContLang, $wgLang, $wgAllowDisplayTitle, $action; $fname = 'Parser::braceSubstitution'; wfProfileIn( $fname ); @@ -2624,11 +2624,12 @@ class Parser } } + $lang = $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang; # GRAMMAR if ( !$found && $argc == 1 ) { $mwGrammar =& MagicWord::get( MAG_GRAMMAR ); if ( $mwGrammar->matchStartAndRemove( $part1 ) ) { - $text = $linestart . $wgContLang->convertGrammar( $args[0], $part1 ); + $text = $linestart . $lang->convertGrammar( $args[0], $part1 ); $found = true; } } @@ -2638,7 +2639,7 @@ class Parser $mwPluralForm =& MagicWord::get( MAG_PLURAL ); if ( $mwPluralForm->matchStartAndRemove( $part1 ) ) { if ($argc==2) {$args[2]=$args[1];} - $text = $linestart . $wgContLang->convertPlural( $part1, $args[0], $args[1], $args[2]); + $text = $linestart . $lang->convertPlural( $part1, $args[0], $args[1], $args[2]); $found = true; } } @@ -4154,7 +4155,8 @@ class ParserOptions var $mEditSection; # Create "edit section" links var $mNumberHeadings; # Automatically number headings var $mAllowSpecialInclusion; # Allow inclusion of special pages - var $mTidy; # Ask for tidy cleanup + var $mTidy; # Ask for tidy cleanup + var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR function getUseTeX() { return $this->mUseTeX; } function getUseDynamicDates() { return $this->mUseDynamicDates; } @@ -4166,7 +4168,8 @@ class ParserOptions function getEditSection() { return $this->mEditSection; } function getNumberHeadings() { return $this->mNumberHeadings; } function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } - function getTidy() { return $this->mTidy; } + function getTidy() { return $this->mTidy; } + function getInterfaceMessage() { return $this->mInterfaceMessage; } function setUseTeX( $x ) { return wfSetVar( $this->mUseTeX, $x ); } function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); } @@ -4177,8 +4180,9 @@ class ParserOptions function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); } function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } - function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } + function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } function setSkin( &$x ) { $this->mSkin =& $x; } + function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); } function ParserOptions() { global $wgUser; @@ -4221,6 +4225,7 @@ class ParserOptions $this->mNumberHeadings = $user->getOption( 'numberheadings' ); $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion; $this->mTidy = false; + $this->mInterfaceMessage = false; wfProfileOut( $fname ); } } diff --git a/includes/Skin.php b/includes/Skin.php index 6bc29357fd..0e60b9f71b 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -893,7 +893,7 @@ END; if ( !$wgDisableCounters ) { $count = $wgLang->formatNum( $wgArticle->getCount() ); if ( $count ) { - $s = wfMsg( 'viewcount', $count ); + $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count ); } } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 25c4319256..24f0d2a5e1 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -308,7 +308,7 @@ class SkinTemplate extends Skin { if ( !$wgDisableCounters ) { $viewcount = $wgLang->formatNum( $wgArticle->getCount() ); if ( $viewcount ) { - $tpl->set('viewcount', wfMsg( "viewcount", $viewcount )); + $tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) ); } else { $tpl->set('viewcount', false); } diff --git a/includes/SpecialUserlogout.php b/includes/SpecialUserlogout.php index 4b8927890b..f3fcbc4f9e 100644 --- a/includes/SpecialUserlogout.php +++ b/includes/SpecialUserlogout.php @@ -18,7 +18,7 @@ function wfSpecialUserlogout() { wfRunHooks('UserLogoutComplete', array(&$wgUser)); $wgOut->setRobotpolicy( 'noindex,nofollow' ); - $wgOut->addWikiText( wfMsg( 'logouttext' ) ); + $wgOut->addHTML( wfMsgExt( 'logouttext', array( 'parse' ) ) ); $wgOut->returnToMain(); } diff --git a/languages/Messages.php b/languages/Messages.php index eddfbf7ecf..0c44f21cab 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -211,7 +211,7 @@ parent class in order maintain consistency across languages. 'redirectedfrom' => '(Redirected from $1)', 'redirectpagesub' => 'Redirect page', 'lastmodified' => 'This page was last modified $1.', -'viewcount' => 'This page has been accessed $1 times.', +'viewcount' => 'This page has been accessed {{plural:$1|one time|$1 times}}.', 'copyright' => 'Content is available under $1.', 'protectedpage' => 'Protected page', 'administrators' => 'Project:Administrators', diff --git a/languages/MessagesFi.php b/languages/MessagesFi.php index 95bc7f5188..3642a02400 100644 --- a/languages/MessagesFi.php +++ b/languages/MessagesFi.php @@ -175,7 +175,7 @@ 'redirectedfrom' => 'Uudelleenohjattu sivulta $1', 'redirectpagesub' => 'Uudelleenohjaussivu', 'lastmodified' => 'Sivua on viimeksi muutettu $1.', -'viewcount' => 'Tämä sivu on näytetty $1 kertaa.', +'viewcount' => 'Tämä sivu on näytetty {{PLURAL:$1|yhden kerran|$1 kertaa}}.', 'copyright' => 'Sisältö on käytettävissä lisenssillä $1.', 'poweredby' => '{{GRAMMAR:genitive|{{SITENAME}}}} tarjoaa [http://www.mediawiki.org/ MediaWiki], avoimen lähdekoodin ohjelmisto.', 'printsubtitle' => '(Lähde: {{SERVER}})', -- 2.20.1