private void injectMessageBundles(Gadget gadget, Node scriptTag) throws GadgetException {
GadgetContext context = gadget.getContext();
MessageBundle bundle = messageBundleFactory.getBundle(
gadget.getSpec(), context.getLocale(), context.getIgnoreCache());
String msgs = bundle.toJSONString();
Text text = scriptTag.getOwnerDocument().createTextNode("gadgets.Prefs.setMessages_(");
text.appendData(msgs);
text.appendData(");");
scriptTag.appendChild(text);