r78966 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78965‎ | r78966 | r78967 >
Date:15:27, 24 December 2010
Author:krinkle
Status:resolved (Comments)
Tags:
Comment:
Adding fallback for collapsible messages
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.makeCollapsible.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.makeCollapsible.js
@@ -76,10 +76,10 @@
7777
7878 // Use custom text or default ?
7979 if( !collapsetext || collapsetext == '' ){
80 - collapsetext = mw.msg( 'collapsible-collapse' );
 80+ collapsetext = mw.msg( 'collapsible-collapse', 'Collapse' );
8181 }
8282 if ( !expandtext || expandtext == '' ){
83 - expandtext = mw.msg( 'collapsible-expand' );
 83+ expandtext = mw.msg( 'collapsible-expand', 'Expand' );
8484 }
8585
8686 // Create toggle link with a space around the brackets ( [text] )

Follow-up revisions

RevisionCommit summaryAuthorDate
r83486removing fallback, not needed (messages are in-core and defined in Resources....krinkle21:17, 7 March 2011

Comments

#Comment by Hashar (talk | contribs)   18:00, 7 March 2011

Isn't it the role of mw.msg() to provide a sane fallback?

#Comment by Catrope (talk | contribs)   18:08, 7 March 2011

mw.msg() doesn't work this way, does it? You're passing in a parameter for $1-expansion, not a fallback parameter.

#Comment by Krinkle (talk | contribs)   21:18, 7 March 2011

mw.msg has a fallback that is similar to the way it is done in PHP, namely bracket keyname bracket.

ie. mw.msg( 'blablabla' ); returns the value of MediaWiki:blablabla from database, otherwise from file $messages['en']['blablabla'], or if none defined at all "<blablabla>".

The second argument overrides this last fallback, I overrode it since I didn't add the messages in the php definition yet at time of this commit (I was under the impression messages were only to be added via TranslateWiki, so I thought, since the daily localization update was just done, I had to wait for the next sync). Anyway, a few revisions after this one it was added properly so the fallaback is redundant now.

Fixed in r83486.

Status & tagging log