r62197 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62196‎ | r62197 | r62198 >
Date:21:24, 9 February 2010
Author:dale
Status:deferred (Comments)
Tags:
Comment:
* bug 22453, adds support for arguments to be substituted into msgs. Enables the api to return PLURAL transforms.
Modified paths:
  • /branches/js2-work/phase3/includes/api/ApiQueryAllmessages.php (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/includes/api/ApiQueryAllmessages.php
@@ -80,8 +80,13 @@
8181 if($skip && $message === $params['from'])
8282 $skip = false;
8383 if(!$skip) {
 84+
8485 $a = array( 'name' => $message );
85 - $msg = wfMsgGetKey( $message, true, false, false );
 86+ if( isset( $params['arg'] ) && count( $params['arg'] ) != 0 ){
 87+ $msg = wfMsg( $message, $params['arg'] );
 88+ }else{
 89+ $msg = wfMsgGetKey( $message, true, false, false );
 90+ }
8691 if ( wfEmptyMsg( $message, $msg ) )
8792 $a['missing'] = '';
8893 else {
@@ -118,6 +123,9 @@
119124 'default'
120125 )
121126 ),
 127+ 'arg' => array(
 128+ ApiBase :: PARAM_ISMULTI => true
 129+ ),
122130 'filter' => array(),
123131 'lang' => null,
124132 'from' => null,
@@ -128,6 +136,7 @@
129137 return array (
130138 'messages' => 'Which messages to output. "*" means all messages',
131139 'prop' => 'Which properties to get',
 140+ 'arg' => 'Arguments to be substituted into msg',
132141 'filter' => 'Return only messages that contain this string',
133142 'lang' => 'Return messages in this language',
134143 'from' => 'Return messages starting at this message',

Follow-up revisions

RevisionCommit summaryAuthorDate
r62527Updated per r62197 #c5705 ( include enableparser param and support both msg a...dale16:50, 15 February 2010
r62532* helps address bug 22453, Enables the api to return PLURAL transforms....dale17:56, 15 February 2010

Comments

#Comment by Catrope (talk | contribs)   11:00, 10 February 2010

I have the sneaking suspicion that for a message that uses no parameter substitution but does use magic words, the following API calls will not return the same result:

http://localhost/w/api.php?action=query&meta=allmessages&ammessages=tagline

http://localhost/w/api.php?action=query&meta=allmessages&ammessages=tagline&amarg=foo

Could you test this? (I don't have a js2-work checkout handy.)

Also, this change can probably be applied to trunk directly (as it's generally useful beyond JS2) after we think of a nicer parameter name than 'arg' :)

#Comment by Mdale (talk | contribs)   16:01, 10 February 2010

yep it is different. "arg" invokes the parser for the msg text so it will do magic word substitution. (including plurals ) Is there a reason we don't want that?

arg is the short version of argument, similar to "param" for parameter, and "lang" for "languageKey" .. but I am open to suggestions... maybe parserarg ?... so that its clear that the msg goes through the parser and that your passing arguments into it?

Once we get that settled I will commit it to trunk ;)

#Comment by Catrope (talk | contribs)   16:06, 10 February 2010

I get why it's different, it's just non-obvious that passing &amarg invokes the magic word subst parser. There's no reason we don't want that, per se (it makes sense in most cases), but it should either be documented or there should be a way to substitute args without parsing magic words. Also, there should be a way to invoke magic word parsing without passing args.

I guess arg isn't that horrible after all considering lang, although I'd like it to be args instead for clarity.

#Comment by Mdale (talk | contribs)   17:13, 15 February 2010

oky updated in r62527 & r62528 . If that looks good to you I will put it in trunk as well.

Status & tagging log