r74159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74158‎ | r74159 | r74160 >
Date:21:45, 2 October 2010
Author:platonides
Status:old (Comments)
Tags:
Comment:
Do not use ForContent messages for the Special page messages.
Note however that messages which end up in the talk page use the content one, as do those that appear in the comments form (for parser cache).
Modified paths:
  • /trunk/extensions/ArticleComments/ArticleComments.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleComments/ArticleComments.php
@@ -305,27 +305,30 @@
306306 # Perform validation checks on supplied fields
307307 $messages = array();
308308
309 - if ( !$wgRequest->wasPosted() )
310 - $messages[] = wfMsgForContent( 'article-comments-not-posted' );
 309+ if ( !$wgRequest->wasPosted() ) {
 310+ $messages[] = wfMsg( 'article-comments-not-posted' );
 311+ }
311312
312313 if ( $titleText === '' || !$title ) {
313 - $messages[] = wfMsgForContent(
314 - 'article-comments-invalid-field', wfMsgForContent( 'article-comments-title-string' ), $titleText );
 314+ $messages[] = wfMsg( 'article-comments-invalid-field', wfMsgForContent( 'article-comments-title-string' ), $titleText );
315315 }
316316
317 - if ( !$commenterName ) $messages[] = wfMsgForContent(
318 - 'article-comments-required-field', wfMsgForContent( 'article-comments-name-string' ) );
 317+ if ( !$commenterName ) {
 318+ $messages[] = wfMsg( 'article-comments-required-field', wfMsgForContent( 'article-comments-name-string' ) );
 319+ }
319320
320 - if ( ( $commenterURL != '' ) && !preg_match( "/^(" . wfUrlProtocols() . ')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) )
321 - $messages[] = wfMsgForContent(
322 - 'article-comments-invalid-field', wfMsgForContent( 'article-comments-url-string' ), $commenterURL );
 321+ if ( ( $commenterURL != '' ) && !preg_match( "/^(" . wfUrlProtocols() . ')' . Parser::EXT_LINK_URL_CLASS . '+$/', $commenterURL ) ) {
 322+ $messages[] = wfMsg( 'article-comments-invalid-field', wfMsgForContent( 'article-comments-url-string' ), $commenterURL );
 323+ }
323324
324 - if ( !$comment ) $messages[] = wfMsgForContent(
325 - 'article-comments-required-field', wfMsgForContent( 'article-comments-comment-string' ) );
 325+ if ( !$comment ) {
 326+ $messages[] = wfMsg('article-comments-required-field', wfMsg( 'article-comments-comment-string' ) );
 327+ }
 328+
326329 if ( !empty( $messages ) ) {
327 - $wgOut->setPageTitle( wfMsgForContent( 'article-comments-submission-failed' ) );
 330+ $wgOut->setPageTitle( wfMsg( 'article-comments-submission-failed' ) );
328331 $wikiText = "<div class='errorbox'>";
329 - $wikiText .= wfMsgForContent( 'article-comments-failure-reasons' ) . "\n\n";
 332+ $wikiText .= wfMsg( 'article-comments-failure-reasons' ) . "\n\n";
330333 foreach ( $messages as $message ) {
331334 $wikiText .= "* $message\n";
332335 }
@@ -341,10 +344,10 @@
342345
343346 # Check whether user is blocked from editing the talk page
344347 if ( $wgUser->isBlockedFrom( $talkTitle ) ) {
345 - $wgOut->setPageTitle( wfMsgForContent( 'article-comments-submission-failed' ) );
 348+ $wgOut->setPageTitle( wfMsg( 'article-comments-submission-failed' ) );
346349 $wikiText = "<div class='errorbox'>";
347 - $wikiText .= wfMsgForContent( 'article-comments-failure-reasons' ) . "\n\n";
348 - $wikiText .= '* ' . wfMsgForContent( 'article-comments-user-is-blocked', $talkTitle->getPrefixedText() ) . "\n";
 350+ $wikiText .= wfMsg( 'article-comments-failure-reasons' ) . "\n\n";
 351+ $wikiText .= '* ' . wfMsg( 'article-comments-user-is-blocked', $talkTitle->getPrefixedText() ) . "\n";
349352 $wgOut->addWikiText( $wikiText . "</div>" );
350353 return;
351354 }
@@ -379,7 +382,7 @@
380383 $wgOut->setPageTitle( wfMsgForContent( 'article-comments-submission-failed' ) );
381384 $wgOut->addWikiText(
382385 "<div class='errorbox'>" .
383 - wfMsgForContent( 'article-comments-no-comments', $title->getPrefixedText() ) .
 386+ wfMsg( 'article-comments-no-comments', $title->getPrefixedText() ) .
384387 "</div>"
385388 );
386389 return;
@@ -391,10 +394,10 @@
392395
393396 # If it's spam - it's gone!
394397 if ( $isspam ) {
395 - $wgOut->setPageTitle( wfMsgForContent( 'article-comments-submission-failed' ) );
 398+ $wgOut->setPageTitle( wfMsg( 'article-comments-submission-failed' ) );
396399 $wgOut->addWikiText(
397400 "<div class='errorbox'>" .
398 - wfMsgForContent( 'article-comments-no-spam' ) .
 401+ wfMsg( 'article-comments-no-spam' ) .
399402 "</div>"
400403 );
401404 return;
@@ -436,9 +439,9 @@
437440 $summary = wfMsgForContent( 'article-comments-summary', $commenterName );
438441 $talkArticle->doEdit( $talkContent, $summary );
439442
440 - $wgOut->setPageTitle( wfMsgForContent( 'article-comments-submission-succeeded' ) );
441 - $wgOut->addWikiText( wfMsgForContent( 'article-comments-submission-success', $title->getPrefixedText() ) );
442 - $wgOut->addWikiText( wfMsgForContent( 'article-comments-submission-view-all', $talkTitle->getPrefixedText() ) );
 443+ $wgOut->setPageTitle( wfMsg( 'article-comments-submission-succeeded' ) );
 444+ $wgOut->addWikiText( wfMsg( 'article-comments-submission-success', $title->getPrefixedText() ) );
 445+ $wgOut->addWikiText( wfMsg( 'article-comments-submission-view-all', $talkTitle->getPrefixedText() ) );
443446 }
444447
445448 /**

Comments

#Comment by Brion VIBBER (talk | contribs)   23:52, 2 October 2010

These look like they should be using the UI language for the sub-messages as well:

$messages[] = wfMsg( 'article-comments-invalid-field', wfMsgForContent( 'article-comments-title-string' ), $titleText );
$messages[] = wfMsg( 'article-comments-required-field', wfMsgForContent( 'article-comments-name-string' ) );
$messages[] = wfMsg( 'article-comments-invalid-field', wfMsgForContent( 'article-comments-url-string' ), $commenterURL );
#Comment by Platonides (talk | contribs)   00:02, 3 October 2010

I left them as ForContent on purpose because they refer to the -field messages on the form, being all of it in content language.

#Comment by Brion VIBBER (talk | contribs)   00:23, 3 October 2010

Hmm... however, that seems to be the only place those messages are used, and their text and casing is for inline words going into the sentence, not a raw-text reference to a label which might be in another language.

Would this be correct output on a french-language site viewed in English?

The titre provided DSFKLjrweljke$&#;3;3''34'3 is invalid.

They also don't all match up cleanly within a given language:

	'article-comments-url-field' => 'Website:',
	'article-comments-url-string' => 'URL',
#Comment by Platonides (talk | contribs)   18:10, 3 October 2010

That would point to the field called "Titre:"

It is in my book to properly have the form completely in the user language.

#Comment by 😂 (talk | contribs)   17:59, 13 September 2011

Ahem, thoughts?

Status & tagging log