* (bug 10365) Localization of Special:Version
authorRaimond Spekking <raymond@users.mediawiki.org>
Thu, 31 Jan 2008 14:38:12 +0000 (14:38 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Thu, 31 Jan 2008 14:38:12 +0000 (14:38 +0000)
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
includes/SpecialVersion.php
languages/messages/MessagesDe.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 1bbfd54..b4f87b0 100644 (file)
@@ -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 ===
 
index 4d89859..9ca096d 100644 (file)
@@ -24,7 +24,8 @@ class SpecialVersion {
         * main()
         */
        function execute() {
-               global $wgOut;
+               global $wgOut, $wgMessageCache;
+               $wgMessageCache->loadAllMessages();
 
                $wgOut->addHTML( '<div dir="ltr">' );
                $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 = "<h2>Extensions</h2>\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 .= '<tr><td colspan="3">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n";
                }
 
                if ( $cnt = count( $tags = $wgParser->getTags() ) ) {
                        for ( $i = 0; $i < $cnt; ++$i )
                                $tags[$i] = "&lt;{$tags[$i]}&gt;";
-                       $out .= $this->openExtType('Parser extension tags');
+                       $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ) );
                        $out .= '<tr><td colspan="3">' . $this->listToText( $tags ). "</td></tr>\n";
                }
 
                if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) {
-                       $out .= $this->openExtType('Parser function hooks');
+                       $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ) );
                        $out .= '<tr><td colspan="3">' . $this->listToText( $fhooks ) . "</td></tr>\n";
                }
 
                if ( count( $wgSkinExtensionFunction ) ) {
-                       $out .= $this->openExtType('Skin extension functions');
+                       $out .= $this->openExtType( wfMsg( 'version-skin-extension-functions' ) );
                        $out .= '<tr><td colspan="3">' . $this->listToText( $wgSkinExtensionFunction ) . "</td></tr>\n";
                }
                $out .= Xml::closeElement( 'table' );
@@ -162,21 +164,23 @@ class SpecialVersion {
                }
        }
 
-       function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
-               $ret = '<tr><td>';
-               if ( isset( $url ) )
-                       $ret .= "[$url ";
-               $ret .= "''$name";
-               if ( isset( $version ) )
-                       $ret .= " (version $version)";
-               $ret .= "''";
-               if ( isset( $url ) )
-                       $ret .= ']';
-               $ret .= '</td>';
-               $ret .= "<td>$description</td>";
-               $ret .= "<td>" . $this->listToText( (array)$author ) . "</td>";
-               $ret .= '</tr>';
-               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 "<tr>
+                               <td><em>$extension $version</em></td>
+                               <td>$description</td>
+                               <td>" . $this->listToText( (array)$author ) . "</td>
+                       </tr>\n";
        }
 
        /**
@@ -189,12 +193,18 @@ class SpecialVersion {
                        $myWgHooks = $wgHooks;
                        ksort( $myWgHooks );
 
-                       $ret = "<h2>Hooks</h2>\n"
-                               . Xml::openElement('table', array('id' => 'sv-hooks') )
-                               . "<tr><th>Hook name</th><th>Subscribed by</th></tr>\n";
+                       $ret = Xml::element( 'h2', array( 'id' => 'mw-version-hooks' ), wfMsg( 'version-hooks' ) ) .
+                               Xml::openElement( 'table', array( 'id' => 'sv-hooks' ) ) .
+                               "<tr>
+                                       <th>" . wfMsg( 'version-hook-name' ) . "</th>
+                                       <th>" . wfMsg( 'version-hook-subscribedby' ) . "</th>
+                               </tr>\n";
 
-                       foreach ($myWgHooks as $hook => $hooks)
-                               $ret .= "<tr><td>$hook</td><td>" . $this->listToText( $hooks ) . "</td></tr>\n";
+                       foreach ( $myWgHooks as $hook => $hooks )
+                               $ret .= "<tr>
+                                               <td>$hook</td>
+                                               <td>" . $this->listToText( $hooks ) . "</td>
+                                       </tr>\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 {
 
 /**#@-*/
 
+
index 3a5d53f..ce07634 100644 (file)
@@ -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',
 );
index 07e0db3..1e3604a 100644 (file)
@@ -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',
 );
index d06d671..2980512 100644 (file)
@@ -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 */