Have this problem:: I'm starting a function from a menuitem with
oncommand="myfunction();" and should access within that one the
xyz.properties eg. 'stringofinterest'.
For that I have defined within the same XUL :
<stringbundleset id="extraStringbundleset">
<stringbundle id="extraBundle"
src="chrome://xyz/locale/xyz.properties"/>
</stringbundleset>
The myFunction.js-file holds this:
const g_extraBundle = document.getElementById("extraBundle");
function myfunction(); {
var XXXX = g_extraBundle.getString('stringofinterest')
.... etc }
This generates the folowing error:
Fehler: g_extraBundle has no properties
Quelldatei: chrome://xyz/content/myFunction.js
Zeile: 71 {[the line with var XXXX=]}
Please help!
The script is executed before the document is loaded and thus the
getElementById fails. You want to set that in the onload handler of the
document.
Axel
In the meantime I tried this one .. but it also fails!
function extraFile () {
var extraService=
components.classes["@mozilla.org/intl/stringbundle;1"].
getService(Components.interfaces.nsIStringBundleService);
var extraServiceBundle =
extraService.createBundle("chrome://xyz/locale/xyz.properties");
var exportLabel = extraServiceBundle.GetStringFromName('exportDef');
// ... etc
}
Fehler: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)
[nsIStringBundle.GetStringFromName]
Quelldatei: chrome://xyz/content/extraFile.js
Zeile: xx ... the line with var exportLabel = ext....
Axel you wrote "You want to set that in the onload handler of the
document."
Just to make my intension clear:
I add some menuitems to the toolbar using a XUL .. that works fine.
After that -- due to the appl-requirement -- I have to change that
menuitem. For this I want to "reaccess" the stringbundle (xyz.properties
file).
Any further advice ? Please
Guenter
Post more context. It could be many things right now, from the
xyz.properties file not being registered correctly with the chrome,
syntax errors in that file.
Talking to :bs, stringbundles wait for the load once you get the string,
so I would assume it's one of the above.
You should try to load "chrome://xyz/locale/xyz.properties" directly, by
setting your thunderbird startpage to that and restart (thanks to :bc
for that, too).
Axel
Guenter
I doubt that I'll be able to do some debugging.
Axel