Thread:MediaWiki talk:Gadget-ParserPlayground.js/Messages

I think you can use mw.messages.set( messages ); instead of this loop. See e.g. meta:User:Krinkle/1-17-allwikis/jsUpdater.js