r30349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30348‎ | r30349 | r30350 >
Date:14:38, 31 January 2008
Author:raymond
Status:old
Tags:
Comment:
* (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.
Modified paths:
  • /trunk/extensions/Cite/Cite.i18n.php (modified) (history)
  • /trunk/extensions/Cite/Cite.php (modified) (history)
  • /trunk/extensions/Cite/SpecialCite.i18n.php (modified) (history)
  • /trunk/extensions/Cite/SpecialCite.php (modified) (history)
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialVersion.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -2346,6 +2346,21 @@
23472347 'CoreParserFunctions' => array(
23482348 'unknown_extension_tag',
23492349 ),
 2350+ 'version' => array(
 2351+ 'version-extensions',
 2352+ 'version-specialpages',
 2353+ 'version-parserhooks',
 2354+ 'version-variables',
 2355+ 'version-other',
 2356+ 'version-hooks',
 2357+ 'version-extension-functions',
 2358+ 'version-parser-extensiontags',
 2359+ 'version-parser-function-hooks',
 2360+ 'version-skin-extension-functions',
 2361+ 'version-hook-name',
 2362+ 'version-hook-subscribedby',
 2363+ 'version-and',
 2364+ ),
23502365 );
23512366 /** Comments for each block */
23522367 $wgBlockComments = array(
@@ -2521,6 +2536,7 @@
25222537 'hebrew-dates' => 'Hebrew month names',
25232538 'signatures' => 'Signatures',
25242539 'CoreParserFunctions' => 'Core parser functions',
 2540+ 'version' => 'Special:Version',
25252541 );
25262542
25272543 /** Short comments for standalone messages */
Index: trunk/phase3/includes/SpecialVersion.php
@@ -24,7 +24,8 @@
2525 * main()
2626 */
2727 function execute() {
28 - global $wgOut;
 28+ global $wgOut, $wgMessageCache;
 29+ $wgMessageCache->loadAllMessages();
2930
3031 $wgOut->addHTML( '<div dir="ltr">' );
3132 $wgOut->addWikiText(
@@ -96,16 +97,16 @@
9798 return '';
9899
99100 $extensionTypes = array(
100 - 'specialpage' => 'Special pages',
101 - 'parserhook' => 'Parser hooks',
102 - 'variable' => 'Variables',
103 - 'media' => 'Media handlers',
104 - 'other' => 'Other',
 101+ 'specialpage' => wfMsg( 'version-specialpages' ),
 102+ 'parserhook' => wfMsg( 'version-parserhooks' ),
 103+ 'variable' => wfMsg( 'version-variables' ),
 104+ 'media' => wfMsg( 'version-mediahandlers' ),
 105+ 'other' => wfMsg( 'version-other' ),
105106 );
106107 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
107108
108 - $out = "<h2>Extensions</h2>\n";
109 - $out .= Xml::openElement('table', array('id' => 'sv-ext') );
 109+ $out = Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), wfMsg( 'version-extensions' ) ) .
 110+ Xml::openElement( 'table', array( 'id' => 'sv-ext' ) );
110111
111112 foreach ( $extensionTypes as $type => $text ) {
112113 if ( isset ( $wgExtensionCredits[$type] ) && count ( $wgExtensionCredits[$type] ) ) {
@@ -115,35 +116,36 @@
116117
117118 foreach ( $wgExtensionCredits[$type] as $extension ) {
118119 $out .= $this->formatCredits(
119 - isset ( $extension['name'] ) ? $extension['name'] : '',
120 - isset ( $extension['version'] ) ? $extension['version'] : null,
121 - isset ( $extension['author'] ) ? $extension['author'] : '',
122 - isset ( $extension['url'] ) ? $extension['url'] : null,
123 - isset ( $extension['description'] ) ? $extension['description'] : ''
 120+ isset ( $extension['name'] ) ? $extension['name'] : '',
 121+ isset ( $extension['version'] ) ? $extension['version'] : null,
 122+ isset ( $extension['author'] ) ? $extension['author'] : '',
 123+ isset ( $extension['url'] ) ? $extension['url'] : null,
 124+ isset ( $extension['description'] ) ? $extension['description'] : '',
 125+ isset ( $extension['descriptionmsg'] ) ? $extension['descriptionmsg'] : ''
124126 );
125127 }
126128 }
127129 }
128130
129131 if ( count( $wgExtensionFunctions ) ) {
130 - $out .= $this->openExtType('Extension functions');
 132+ $out .= $this->openExtType( wfMsg( 'version-extension-functions' ) );
131133 $out .= '<tr><td colspan="3">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n";
132134 }
133135
134136 if ( $cnt = count( $tags = $wgParser->getTags() ) ) {
135137 for ( $i = 0; $i < $cnt; ++$i )
136138 $tags[$i] = "&lt;{$tags[$i]}&gt;";
137 - $out .= $this->openExtType('Parser extension tags');
 139+ $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ) );
138140 $out .= '<tr><td colspan="3">' . $this->listToText( $tags ). "</td></tr>\n";
139141 }
140142
141143 if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) {
142 - $out .= $this->openExtType('Parser function hooks');
 144+ $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ) );
143145 $out .= '<tr><td colspan="3">' . $this->listToText( $fhooks ) . "</td></tr>\n";
144146 }
145147
146148 if ( count( $wgSkinExtensionFunction ) ) {
147 - $out .= $this->openExtType('Skin extension functions');
 149+ $out .= $this->openExtType( wfMsg( 'version-skin-extension-functions' ) );
148150 $out .= '<tr><td colspan="3">' . $this->listToText( $wgSkinExtensionFunction ) . "</td></tr>\n";
149151 }
150152 $out .= Xml::closeElement( 'table' );
@@ -162,21 +164,23 @@
163165 }
164166 }
165167
166 - function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
167 - $ret = '<tr><td>';
168 - if ( isset( $url ) )
169 - $ret .= "[$url ";
170 - $ret .= "''$name";
171 - if ( isset( $version ) )
172 - $ret .= " (version $version)";
173 - $ret .= "''";
174 - if ( isset( $url ) )
175 - $ret .= ']';
176 - $ret .= '</td>';
177 - $ret .= "<td>$description</td>";
178 - $ret .= "<td>" . $this->listToText( (array)$author ) . "</td>";
179 - $ret .= '</tr>';
180 - return "$ret\n";
 168+ function formatCredits( $name, $version = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) {
 169+ $extension = isset( $url ) ? "[$url $name]" : $name;
 170+ $version = isset( $version ) ? "(" . wfMsg( 'version-version' ) . " $version)" : '';
 171+
 172+ # Look for a localized description
 173+ if( isset( $descriptionMsg ) ) {
 174+ $msg = wfMsg( $descriptionMsg );
 175+ if ( !wfEmptyMsg( $descriptionMsg, $msg ) && $msg != '' ) {
 176+ $description = $msg;
 177+ }
 178+ }
 179+
 180+ return "<tr>
 181+ <td><em>$extension $version</em></td>
 182+ <td>$description</td>
 183+ <td>" . $this->listToText( (array)$author ) . "</td>
 184+ </tr>\n";
181185 }
182186
183187 /**
@@ -189,12 +193,18 @@
190194 $myWgHooks = $wgHooks;
191195 ksort( $myWgHooks );
192196
193 - $ret = "<h2>Hooks</h2>\n"
194 - . Xml::openElement('table', array('id' => 'sv-hooks') )
195 - . "<tr><th>Hook name</th><th>Subscribed by</th></tr>\n";
 197+ $ret = Xml::element( 'h2', array( 'id' => 'mw-version-hooks' ), wfMsg( 'version-hooks' ) ) .
 198+ Xml::openElement( 'table', array( 'id' => 'sv-hooks' ) ) .
 199+ "<tr>
 200+ <th>" . wfMsg( 'version-hook-name' ) . "</th>
 201+ <th>" . wfMsg( 'version-hook-subscribedby' ) . "</th>
 202+ </tr>\n";
196203
197 - foreach ($myWgHooks as $hook => $hooks)
198 - $ret .= "<tr><td>$hook</td><td>" . $this->listToText( $hooks ) . "</td></tr>\n";
 204+ foreach ( $myWgHooks as $hook => $hooks )
 205+ $ret .= "<tr>
 206+ <td>$hook</td>
 207+ <td>" . $this->listToText( $hooks ) . "</td>
 208+ </tr>\n";
199209
200210 $ret .= Xml::closeElement( 'table' );
201211 return $ret;
@@ -235,20 +245,21 @@
236246 */
237247 function listToText( $list ) {
238248 $cnt = count( $list );
239 - sort( $list );
240249
241 - if ( $cnt == 1 ) {
 250+ if ( $cnt == 1 ) {
242251 // Enforce always returning a string
243252 return (string)$this->arrayToString( $list[0] );
244 - } elseif ( $cnt == 0 ) {
 253+ } elseif ( $cnt == 0 ) {
245254 return '';
246255 } else {
 256+ sort( $list );
247257 $t = array_slice( $list, 0, $cnt - 1 );
248258 $one = array_map( array( &$this, 'arrayToString' ), $t );
249259 $two = $this->arrayToString( $list[$cnt - 1] );
 260+ $and = wfMsg( 'version-and' );
250261
251 - return implode( ', ', $one ) . " and $two";
252 - }
 262+ return implode( ', ', $one ) . " $and $two";
 263+ }
253264 }
254265
255266 /**
@@ -321,3 +332,4 @@
322333
323334 /**#@-*/
324335
 336+
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3135,4 +3135,20 @@
31363136 # Core parser functions
31373137 'unknown_extension_tag' => 'Unknown extension tag "$1"',
31383138
 3139+# Special:Version
 3140+'version-extensions' => 'Installed extensions',
 3141+'version-specialpages' => 'Special pages',
 3142+'version-parserhooks' => 'Parser hooks',
 3143+'version-variables' => 'Variables',
 3144+'version-other' => 'Other',
 3145+'version-mediahandlers' => 'Media handlers',
 3146+'version-hooks' => 'Hooks',
 3147+'version-extension-functions' => 'Extension functions',
 3148+'version-parser-extensiontags' => 'Parser extension tags',
 3149+'version-parser-function-hooks' => 'Parser function hooks',
 3150+'version-skin-extension-functions' => 'Skin extension functions',
 3151+'version-hook-name' => 'Hook name',
 3152+'version-hook-subscribedby' => 'Subscribed by',
 3153+'version-and' => 'and',
 3154+'version-version' => 'Version',
31393155 );
Index: trunk/phase3/languages/messages/MessagesDe.php
@@ -2482,4 +2482,20 @@
24832483 # Core parser functions
24842484 'unknown_extension_tag' => 'Unbekannter Extension-Tag „$1“',
24852485
 2486+# Special:Version
 2487+'version-extensions' => 'Installierte Erweiterungen',
 2488+'version-specialpages' => 'Spezialseiten',
 2489+'version-parserhooks' => 'Parser-Hooks',
 2490+'version-variables' => 'Variablen',
 2491+'version-other' => 'Anderes',
 2492+'version-mediahandlers' => 'Medien-Handler',
 2493+'version-hooks' => "Schnittstellen ''(Hooks)''",
 2494+'version-extension-functions' => 'Funktionsaufrufe',
 2495+'version-parser-extensiontags' => "Parser-Erweiterungen ''(tags)''",
 2496+'version-parser-function-hooks' => 'Parser-Funktionen',
 2497+'version-skin-extension-functions' => 'Skin-Erweiterungs-Funktionen',
 2498+'version-hook-name' => 'Schnittstellenname',
 2499+'version-hook-subscribedby' => 'Aufruf von',
 2500+'version-and' => 'und',
 2501+'version-version' => 'Version',
24862502 );
Index: trunk/phase3/RELEASE-NOTES
@@ -147,8 +147,8 @@
148148 Both now accept namespace prefixes, handle 'Media:' and 'Special:' pages,
149149 and reject interwiki prefixes. PrefixSearch class centralizes this code,
150150 and the backend part can be overridden by the PrefixSearchBackend hook.
 151+* (bug 10365) Localization of Special:Version
151152
152 -
153153 === Bug fixes in 1.12 ===
154154
155155 * Subpages are now indexed for searching properly when using PostgreSQL
Index: trunk/extensions/Cite/Cite.i18n.php
@@ -8,10 +8,10 @@
99 $messages = array();
1010
1111 $messages['en'] = array(
 12+ 'cite_desc' => 'Adds <nowiki><ref[ name=id]></nowiki> and <nowiki><references/></nowiki> tags, for citations',
1213 /*
1314 Debug and errors
1415 */
15 -
1616 # Internal errors
1717 'cite_croak' => 'Cite croaked; $1: $2',
1818 'cite_error_key_str_invalid' => 'Internal error; invalid $str and/or $key. This should never occur.',
@@ -179,6 +179,7 @@
180180 * @author Raimond Spekking
181181 */
182182 $messages['de'] = array(
 183+ 'cite_desc' => 'Ergänzt für Quellennachweise die <nowiki><ref[ name=id]></nowiki> und <nowiki><references/></nowiki> Tags',
183184 'cite_croak' => 'Fehler im Referenz-System. $1: $2',
184185 'cite_error_key_str_invalid' => 'Interner Fehler: ungültiger $str und/oder $key. Dies sollte eigentlich gar nicht passieren können.',
185186 'cite_error_stack_invalid_input' => 'Interner Fehler: ungültiger „name“-stack. Dies sollte eigentlich gar nicht passieren können.',
Index: trunk/extensions/Cite/SpecialCite.i18n.php
@@ -8,6 +8,7 @@
99 $messages = array();
1010
1111 $messages['en'] = array(
 12+ 'cite_article_desc' => 'Adds a [[Special:Cite|citation]] special page & toolbox link',
1213 'cite_article_link' => 'Cite this page',
1314 'cite' => 'Cite',
1415 'cite_page' => 'Page:',
@@ -170,6 +171,7 @@
171172 );
172173
173174 $messages['de'] = array(
 175+ 'cite_article_desc' => 'Ergänzt die [[Special:Cite|Zitierhilfe]]-Spezialseite und einen Link im Kasten Werkzeuge',
174176 'cite_article_link' => 'Seite zitieren',
175177 'cite' => 'Zitierhilfe',
176178 'cite_page' => 'Seite:',
Index: trunk/extensions/Cite/Cite.php
@@ -21,8 +21,10 @@
2222 $wgExtensionFunctions[] = 'wfCite';
2323 $wgExtensionCredits['parserhook'][] = array(
2424 'name' => 'Cite',
 25+ 'version' => '2008-01-31',
2526 'author' => 'Ævar Arnfjörð Bjarmason',
26 - 'description' => 'Adds <nowiki><ref[ name=id]></nowiki> and <nowiki><references/></nowiki> tags, for citations',
 27+ 'description' => 'Adds <nowiki><ref[ name=id]></nowiki> and <nowiki><references/></nowiki> tags, for citations', // kept for b/c
 28+ 'descriptionmsg' => 'cite_desc',
2729 'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Cite.php'
2830 );
2931 $wgParserTestFiles[] = dirname( __FILE__ ) . "/citeParserTests.txt";
@@ -662,4 +664,3 @@
663665
664666 /**#@-*/
665667
666 -
Index: trunk/extensions/Cite/SpecialCite.php
@@ -15,9 +15,10 @@
1616
1717 $wgExtensionCredits['specialpage'][] = array(
1818 'name' => 'Cite',
19 - 'version' => '2008-01-09',
 19+ 'version' => '2008-01-31',
2020 'author' => 'Ævar Arnfjörð Bjarmason',
21 - 'description' => 'adds a [[Special:Cite|citation]] special page & toolbox link',
 21+ 'description' => 'adds a [[Special:Cite|citation]] special page & toolbox link', // kept for b/c
 22+ 'descriptionmsg' => 'cite_article_desc',
2223 'url' => 'http://www.mediawiki.org/wiki/Extension:Cite/Special:Cite.php'
2324 );
2425

Follow-up revisions

RevisionCommit summaryAuthorDate
r30351Tweak for r30349: Use existing message 'and' instead of introducing a new one...raymond16:29, 31 January 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r23471* (bug 10365) Localization of Special:Version...raymond10:19, 27 June 2007
r23581Merged revisions 23406-23580 via svnmerge from...david04:50, 30 June 2007

Status & tagging log