Using nsISimpleEnumerator

Using nsISimpleEnumerator

  • <stringbundle>.strings
var enumerator = document.getElementById('aStringBundleID').strings;
var s = "";
while (enumerator.hasMoreElements()) {
  var property = enumerator.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
  s += property.key + ' = ' + property.value + ';\n';
}
alert(s);

Example using JavaScript 1.7 features

// creates a generator iterating over enum's values
function generatorFromSimpleEnumerator(enum, interface) {
  while (enum.hasMoreElements()) {
    yield enum.getNext().QueryInterface(interface);
  }
}
var b = document.getElementById("stringbundleset").firstChild
var props = generatorFromEnumerator(b.strings, Components.interfaces.nsIPropertyElement);
var s = "";
for (let property in props) {
  s += property.key + ' = ' + property.value + ';\n';
}
alert(s);

Document Tags and Contributors

Contributors to this page: Dolske, mcpherrinm, Ferric, Nickolay, Yanmorin
Last updated by: Dolske,