So I was running into the problem of localizing the messages for the add_media_wizard & mv_embed & associated libraries. So I have taken a first pass at witting the script server (that I had previously described) http://tinyurl.com/ae44vd Below is a description of how it works. the code is in the svn http://tinyurl.com/darmme ...
I think it would be good to consider wider usage or at least turning it on sometime soon so I can deploy the add_media_wizard as a multi-lingual gadget. I am happy to volunteer to write a basic patch for putting it in the root. MediaWiki folder. (since its another entry point I imagine it should go in the root)
I have put a copy of this desc on http://www.mediawiki.org/wiki/ScriptLoader ... let me know if there is a better place to put that on mediaWiki
== Primary Motivation: == We need a script server to package language text into javascript. When a user invokes a interface component say the add media wizard we don't want to pull the entire interface code base and all the messages at once. Instead we just want to grab enough to display the current interface interaction. Once the user click on some tab say the 'archive.org search' we then want to import the code to run the archive.org search and the localized messages specific to that interface component. In other words we don't want to package all the message text in the html output of the initial page because in their are lots of possible interface interactions from any given point of invoking the user interface.
== Secondary Benefits == If we are ruining all the javascript though a php script might as well group requests, minify; gzip; use the local file cache system; send headers to cache forever on the squids, and we make each javascript request unique based on svn version and avoid re-validate requests. All these combined do speed things up a good deal on the first time a user loads page.
== How to use== In your Global settings you add to the global wgJSAutoloadClasses variable something like for every javascript class you want to load. $wgJSAutoloadClasses['mv_embed'] = '/local/path/to/my/javascript/mv_embed.js';
then at the top of mv_embed.js you would put something like: loadGM({ "msg_key":"Fall-back text if script server is disabled" ... } note the json variable that you pass to loadGM has to be valid JSON (not javascript) or php will complain.
Then in your message file you put the normal msg key pairs: "msg_key":"My localized text",
Right now we only support basic $1 replace ... obviously things get tricky with contextual wiki-text type replacements. (don't use that in js messages)
Then you can modify your head javascript include: with something like: if( $wgEnableScriptLoader ){ $unique_req_param = SVN_VERSION $debug_param = ($mvgJSDebug) ? '&debug=true' : ''; $wgOut->addScript(... mvwScriptLoader.php?" .
"class=all_the_class_i_need_separated_by_commas" . '&urid=' .$unique_req_param . $debug_param . ""></script>" );
Note the use of a few config vars...here are the config vars:
===Configuration vars=== $wgEnableScriptLoader = true; //if the script loader should be used at all $mvgJSDebug=false; // if set to true will send raw, fresh un-minified, localized javascript $wgEnableScriptLoaderJsFile = true; //if you can use the script loader with js files based on the root script folder ie: ?file=/skin/common.js (rather than only js classes looked up with $wgEnableScriptLoader) $wgEnableScriptMinify = true;
peace, michael.