This is awesome. Thanks for "extensionizing" Neil's parser lib :-)
Alolita
On Aug 17, 2011, at 11:35 AM, Ian Baker ian@wikimedia.org wrote:
I took a little time last week and wrapped Neik K's parserPlus library into an extension. It implements a nice framework for grabbing localized message strings, with limited but very useful PEG-based wikitext parsing, all on the client-side. This is code that's been in use in UploadWizard for some time now, but the extension makes it available to other projects as well.
tl;dr:
- Enable the extension, it makes two functions available in your JS.
- string example: $( '.status' ).append( gM( 'mwe-upwiz-file-all-ok' ) );
- chainable jQuery example: $( '.status' ).msg( 'mwe-upwiz-file-all-ok' );
- It does lots more stuff, check the docs.
Why does this exist? In Neil's own words:
"In the course of writing UploadWizard, I started to rely on MwEmbed's message library, which had limited wikitext parsing. This was a great help to internationalization, and the PLURAL support was nice.
"MwEmbed was ultimately not accepted for integration into MediaWiki, so the ResourceLoader framework was invented to replace that. But we had little or no support for wikitext-parsed messages. Simple replacements were handled, but not complicated or nested parsing.
"Michael Dale and NeilK (that's me) wrote another class (MwMessage.js) to supply the needed features and some advanced ideas like dropping jQuery nodes right into message strings. But I felt that it was still a bit too hacky and had some annoying flaws. For every message, you needed to instantiate another parser. Also, parameters like $1 were replaced before the message was actually parsed, leading to some unnecessary convolutions and code repetition for the advanced jQuery-oriented features that Michael was exploiting heavily."
It's pretty cool. I can imagine this functionality being pulled into Core at some point, but for the moment the extension provides a low-impact way for the rest of us to take advantage of it. When it does get incorporated into core, code changes required in extensions should be very minimal.
Read more: http://www.mediawiki.org/wiki/Extension:JQueryMsg
-Ian _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l