Last modified: 2014-02-14 10:54:50 UTC
If mw.loader.getState( 'mediawiki.jqueryMsg' ) is not 'ready', and I execute the code -------------------------------------------- mw.messages.set( { 'some-key': 'SomeText {{SomeTemplate}}.' } ); alert( mw.msg( 'some-key' ) ); -------------------------------------------- I get 'SomeText {{SomeTemplate}}.' as expected. But if I enable any gadget which loads the module 'mediawiki.jqueryMsg', and run the same code again, the result unexpectedly changes to 'some-key: Unknown operation "sometemplate"'. It should still be 'SomeText {{SomeTemplate}}.', because there is no magic word called 'SomeTemplate'
Templates are not currently supported in jQueryMsg, just magic words (the code uses the word 'template' to mean magic words). mw.msg is equivalent to mw.message(...).text() meaning the 'text' format/operation is being used. In the PHP parser's text mode, if a template exists, it is expanded into its wikitext. If it does not exist, it results in [[:Template:SomeTemplate]]. With the way jQueryMsg currently works, even checking if the template existed would require either: 1. Sending extra data down from ResourceLoader 2. Doing an API call from jQueryMsg Thus, for now I recommend you use: mw.message( 'some-key' ).plain() if you want the output 'SomeText {{SomeTemplate}}.' for this kind of thing. The 'plain' format does not try to expand {{ }} blocks, just $1, $2 replacement.
Undoing my title change
Change 113307 had a related patch set uploaded by Bartosz Dziewoński: mediawiki.jqueryMsg: Don't throw parse errors in the user's face https://gerrit.wikimedia.org/r/113307
The above patch sorta kinda addresses this by hiding the user-visible error messages.