Skip to content

Instantly share code, notes, and snippets.

@yajd
Last active August 29, 2015 14:25
Show Gist options
  • Save yajd/a990c50e55860186e3b0 to your computer and use it in GitHub Desktop.
Save yajd/a990c50e55860186e3b0 to your computer and use it in GitHub Desktop.
var yourStringBundle = Services.strings.createBundle('chrome://blah@jetpack/content/bootstrap.properties?' + Math.random()); /* Randomize URI to work around bug 719376 */
var props = yourStringBundle.getSimpleEnumeration();
// MDN says getSimpleEnumeration returns nsIPropertyElement // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIStringBundle#getSimpleEnumeration%28%29
while (props.hasMoreElements()) {
var prop = props.getNext();
// doing console.log(prop) says its an XPCWrappedObject but we see QueryInterface (QI), so let's try QI'ing to nsiPropertyElement
var propEl = prop.QueryInterface(Ci.nsIPropertyElement);
// doing console.log(propEl) shows the object has some fields that interest us
var key = propEl.key;
var str = propEl.value;
console.info(key, str); // there you go
}
@Noitidart
Copy link

del

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment