From b0c6aff72d9f9ff3a122267319ae2bcf85acfc0f Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Thu, 31 Jan 2008 14:38:12 +0000 Subject: [PATCH] * (bug 10365) Localization of Special:Version Extension descriptions can be localized by adding the new keyword 'descriptionmsg' to $wgExtensionCredits with a message name. See the Cite extension as example. Patches for other extensions will follow in the next days. --- RELEASE-NOTES | 2 +- includes/SpecialVersion.php | 96 +++++++++++++++++-------------- languages/messages/MessagesDe.php | 16 ++++++ languages/messages/MessagesEn.php | 16 ++++++ maintenance/language/messages.inc | 16 ++++++ 5 files changed, 103 insertions(+), 43 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1bbfd54b2f..b4f87b0e2f 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -147,7 +147,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN Both now accept namespace prefixes, handle 'Media:' and 'Special:' pages, and reject interwiki prefixes. PrefixSearch class centralizes this code, and the backend part can be overridden by the PrefixSearchBackend hook. - +* (bug 10365) Localization of Special:Version === Bug fixes in 1.12 === diff --git a/includes/SpecialVersion.php b/includes/SpecialVersion.php index 4d89859b83..9ca096dbdd 100644 --- a/includes/SpecialVersion.php +++ b/includes/SpecialVersion.php @@ -24,7 +24,8 @@ class SpecialVersion { * main() */ function execute() { - global $wgOut; + global $wgOut, $wgMessageCache; + $wgMessageCache->loadAllMessages(); $wgOut->addHTML( '
' ); $wgOut->addWikiText( @@ -96,16 +97,16 @@ class SpecialVersion { return ''; $extensionTypes = array( - 'specialpage' => 'Special pages', - 'parserhook' => 'Parser hooks', - 'variable' => 'Variables', - 'media' => 'Media handlers', - 'other' => 'Other', + 'specialpage' => wfMsg( 'version-specialpages' ), + 'parserhook' => wfMsg( 'version-parserhooks' ), + 'variable' => wfMsg( 'version-variables' ), + 'media' => wfMsg( 'version-mediahandlers' ), + 'other' => wfMsg( 'version-other' ), ); wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) ); - $out = "

Extensions

\n"; - $out .= Xml::openElement('table', array('id' => 'sv-ext') ); + $out = Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), wfMsg( 'version-extensions' ) ) . + Xml::openElement( 'table', array( 'id' => 'sv-ext' ) ); foreach ( $extensionTypes as $type => $text ) { if ( isset ( $wgExtensionCredits[$type] ) && count ( $wgExtensionCredits[$type] ) ) { @@ -115,35 +116,36 @@ class SpecialVersion { foreach ( $wgExtensionCredits[$type] as $extension ) { $out .= $this->formatCredits( - isset ( $extension['name'] ) ? $extension['name'] : '', - isset ( $extension['version'] ) ? $extension['version'] : null, - isset ( $extension['author'] ) ? $extension['author'] : '', - isset ( $extension['url'] ) ? $extension['url'] : null, - isset ( $extension['description'] ) ? $extension['description'] : '' + isset ( $extension['name'] ) ? $extension['name'] : '', + isset ( $extension['version'] ) ? $extension['version'] : null, + isset ( $extension['author'] ) ? $extension['author'] : '', + isset ( $extension['url'] ) ? $extension['url'] : null, + isset ( $extension['description'] ) ? $extension['description'] : '', + isset ( $extension['descriptionmsg'] ) ? $extension['descriptionmsg'] : '' ); } } } if ( count( $wgExtensionFunctions ) ) { - $out .= $this->openExtType('Extension functions'); + $out .= $this->openExtType( wfMsg( 'version-extension-functions' ) ); $out .= '' . $this->listToText( $wgExtensionFunctions ) . "\n"; } if ( $cnt = count( $tags = $wgParser->getTags() ) ) { for ( $i = 0; $i < $cnt; ++$i ) $tags[$i] = "<{$tags[$i]}>"; - $out .= $this->openExtType('Parser extension tags'); + $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ) ); $out .= '' . $this->listToText( $tags ). "\n"; } if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) { - $out .= $this->openExtType('Parser function hooks'); + $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ) ); $out .= '' . $this->listToText( $fhooks ) . "\n"; } if ( count( $wgSkinExtensionFunction ) ) { - $out .= $this->openExtType('Skin extension functions'); + $out .= $this->openExtType( wfMsg( 'version-skin-extension-functions' ) ); $out .= '' . $this->listToText( $wgSkinExtensionFunction ) . "\n"; } $out .= Xml::closeElement( 'table' ); @@ -162,21 +164,23 @@ class SpecialVersion { } } - function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) { - $ret = ''; - if ( isset( $url ) ) - $ret .= "[$url "; - $ret .= "''$name"; - if ( isset( $version ) ) - $ret .= " (version $version)"; - $ret .= "''"; - if ( isset( $url ) ) - $ret .= ']'; - $ret .= ''; - $ret .= "$description"; - $ret .= "" . $this->listToText( (array)$author ) . ""; - $ret .= ''; - return "$ret\n"; + function formatCredits( $name, $version = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) { + $extension = isset( $url ) ? "[$url $name]" : $name; + $version = isset( $version ) ? "(" . wfMsg( 'version-version' ) . " $version)" : ''; + + # Look for a localized description + if( isset( $descriptionMsg ) ) { + $msg = wfMsg( $descriptionMsg ); + if ( !wfEmptyMsg( $descriptionMsg, $msg ) && $msg != '' ) { + $description = $msg; + } + } + + return " + $extension $version + $description + " . $this->listToText( (array)$author ) . " + \n"; } /** @@ -189,12 +193,18 @@ class SpecialVersion { $myWgHooks = $wgHooks; ksort( $myWgHooks ); - $ret = "

Hooks

\n" - . Xml::openElement('table', array('id' => 'sv-hooks') ) - . "Hook nameSubscribed by\n"; + $ret = Xml::element( 'h2', array( 'id' => 'mw-version-hooks' ), wfMsg( 'version-hooks' ) ) . + Xml::openElement( 'table', array( 'id' => 'sv-hooks' ) ) . + " + " . wfMsg( 'version-hook-name' ) . " + " . wfMsg( 'version-hook-subscribedby' ) . " + \n"; - foreach ($myWgHooks as $hook => $hooks) - $ret .= "$hook" . $this->listToText( $hooks ) . "\n"; + foreach ( $myWgHooks as $hook => $hooks ) + $ret .= " + $hook + " . $this->listToText( $hooks ) . " + \n"; $ret .= Xml::closeElement( 'table' ); return $ret; @@ -235,20 +245,21 @@ class SpecialVersion { */ function listToText( $list ) { $cnt = count( $list ); - sort( $list ); - if ( $cnt == 1 ) { + if ( $cnt == 1 ) { // Enforce always returning a string return (string)$this->arrayToString( $list[0] ); - } elseif ( $cnt == 0 ) { + } elseif ( $cnt == 0 ) { return ''; } else { + sort( $list ); $t = array_slice( $list, 0, $cnt - 1 ); $one = array_map( array( &$this, 'arrayToString' ), $t ); $two = $this->arrayToString( $list[$cnt - 1] ); + $and = wfMsg( 'version-and' ); - return implode( ', ', $one ) . " and $two"; - } + return implode( ', ', $one ) . " $and $two"; + } } /** @@ -321,3 +332,4 @@ class SpecialVersion { /**#@-*/ + diff --git a/languages/messages/MessagesDe.php b/languages/messages/MessagesDe.php index 3a5d53f0d7..ce076340a4 100644 --- a/languages/messages/MessagesDe.php +++ b/languages/messages/MessagesDe.php @@ -2482,4 +2482,20 @@ Bitte bestätige, dass du diese Seite wirklich neu erstellen möchten.", # Core parser functions 'unknown_extension_tag' => 'Unbekannter Extension-Tag „$1“', +# Special:Version +'version-extensions' => 'Installierte Erweiterungen', +'version-specialpages' => 'Spezialseiten', +'version-parserhooks' => 'Parser-Hooks', +'version-variables' => 'Variablen', +'version-other' => 'Anderes', +'version-mediahandlers' => 'Medien-Handler', +'version-hooks' => "Schnittstellen ''(Hooks)''", +'version-extension-functions' => 'Funktionsaufrufe', +'version-parser-extensiontags' => "Parser-Erweiterungen ''(tags)''", +'version-parser-function-hooks' => 'Parser-Funktionen', +'version-skin-extension-functions' => 'Skin-Erweiterungs-Funktionen', +'version-hook-name' => 'Schnittstellenname', +'version-hook-subscribedby' => 'Aufruf von', +'version-and' => 'und', +'version-version' => 'Version', ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 07e0db39b9..1e3604a066 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -3135,4 +3135,20 @@ $1', # Core parser functions 'unknown_extension_tag' => 'Unknown extension tag "$1"', +# Special:Version +'version-extensions' => 'Installed extensions', +'version-specialpages' => 'Special pages', +'version-parserhooks' => 'Parser hooks', +'version-variables' => 'Variables', +'version-other' => 'Other', +'version-mediahandlers' => 'Media handlers', +'version-hooks' => 'Hooks', +'version-extension-functions' => 'Extension functions', +'version-parser-extensiontags' => 'Parser extension tags', +'version-parser-function-hooks' => 'Parser function hooks', +'version-skin-extension-functions' => 'Skin extension functions', +'version-hook-name' => 'Hook name', +'version-hook-subscribedby' => 'Subscribed by', +'version-and' => 'and', +'version-version' => 'Version', ); diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index d06d6715b0..2980512b21 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -2346,6 +2346,21 @@ $wgMessageStructure = array( 'CoreParserFunctions' => array( 'unknown_extension_tag', ), + 'version' => array( + 'version-extensions', + 'version-specialpages', + 'version-parserhooks', + 'version-variables', + 'version-other', + 'version-hooks', + 'version-extension-functions', + 'version-parser-extensiontags', + 'version-parser-function-hooks', + 'version-skin-extension-functions', + 'version-hook-name', + 'version-hook-subscribedby', + 'version-and', + ), ); /** Comments for each block */ $wgBlockComments = array( @@ -2521,6 +2536,7 @@ Variants for Chinese language", 'hebrew-dates' => 'Hebrew month names', 'signatures' => 'Signatures', 'CoreParserFunctions' => 'Core parser functions', + 'version' => 'Special:Version', ); /** Short comments for standalone messages */ -- 2.20.1