i'm building ff extension, , i'm processing xhtml myself in order supporn subforms loading, have identify elements l10n attributes defined , add them string value. because l10n can't shared main code content scripts (because isn't simple json object), managed situation getting loaded keys values , defining "localized array bundle", this:
lstrings = ["step_title", ........ ]; (var = 0; < lstrings.length; i++) { bundle[lstrings[i]] = this.locale(lstrings[i]); } the thing is, have write here every entry in .properties files... so, know how access key values? tryed .tostring .tolocalstring , inspecting object, can't find way object capable of returning key collection.
do have better idea improvement?
var yourstringbundle = services.strings.createbundle('chrome://blah@jetpack/content/bootstrap.properties?' + math.random()); /* randomize uri 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 xpcwrappedobject see queryinterface (qi), let's try qi'ing nsipropertyelement var propel = prop.queryinterface(ci.nsipropertyelement); // doing console.log(propel) shows object has fields interest var key = propel.key; var str = propel.value; console.info(key, str); // there go } see comments learning. nice quesiton. learned more qi replying.
Comments
Post a Comment