"Krinkle" posted a comment on MediaWiki.r113644. URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/113644#c32093
Commit summary for MediaWiki.r113644: add locale global for handling languages and message function for the benefit of the phonegap app Krinkle's comment: JSON parsing from a string is indeed a modern API that isn't reliably available in a cross-browser environment. However it doesn't make sense to pass a JSON string to a browser. Browsers have javascript engines and JSON (JavaScript Object Notation) as a literal rather than a string is (naturally) supported in all javascript engines (even old ones (IE6..) and/or handicapped mobile javascript engines, its in the fundamentals of the language, it's even used in the return value visible in the diff above). Outputting <code>'var mwMobileFrontendData = ' . FormatJSON::encode( $frontendData ) . ';'</code> will be fine. Where <code>$frontendData</code> would be something like: <pre> $frotendData = array( 'messages' => array( 'expand-section' => .., ), 'config' => array( 'pageTitle' => .. , 'scriptPath' => .., ), ); </pre> Then from a javascript file you'd have something like: <pre> ( function ( mfData ) { var mf = { msg: function (key) { return mfData.messages[key]; } }; window.mwMobileFrontend = mf; }( mwMobileFrontendData ) ); </pre> Just a short example :) _______________________________________________ MediaWiki-CodeReview mailing list mediawiki-coderev...@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview