https://bugzilla.wikimedia.org/show_bug.cgi?id=38280
Krinkle <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|i18n | Priority|Unprioritized |Lowest Summary|Gettings messages via |Implement mw.Api |JavaScript |convenience method for | |loading interface messages --- Comment #1 from Krinkle <[email protected]> 2012-07-20 04:01:04 UTC --- Changing bug to be a low-priority enhancement, because it is currently already possible. Just not with a single function call. * mw.messages is designed with dynamic loading in mind, this is used all the time whenever a module is loaded from the server through mw.loader. * mw.Api supports making your own queries, should we add a custom method for every single api method if the plain callee is straight forward with only 5 lines of code? * Aside from mw.Api, $.getJSON is also available with a few more lines of code. Example of how to do this directly: var api = new mw.Api(); api.get({ action: 'query', meta: 'allmessages', ammessages: msgKeys.join('|'), amlang: mw.config.get('wgUserLanguage') }).done( function (data) { if ( data && data.query && data.query.allmessages ) { $.each(data.query.allmessages, function (i, obj) { if (obj['*']) { mw.messages.set(obj.name, obj['*']); } }); } }); If you'd like to implement an mw.Api utility method to make this easier, you're welcome to provide a patch. A few pointers: * Provide a patch instead of a partial snippet of a file. Assuming you have a local checkout of the mediawiki/core.git repository. Use `git checkout -b js-api-messages`. Then make the local changes, then use `git diff` to see the patch. To store it in a file use `git diff > mw-bug-38280.patch` and attach it to this ticket. * Leave the mw.messages.set part out of it, so that the method is generally useful for getting messages. It would call the callback with an object containing key/value pairs. So that in consuming code it would look like this: -- dependencies => 'mediawiki.api.allmessages' var api = new mw.Api(); api.allmessages( ['monday', 'tuesday', 'friday'] ).done( mw.messages.set ); -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
