Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

howto: access xyz.properties items

8 views
Skip to first unread message

neandr

unread,
Nov 12, 2006, 11:18:03 AM11/12/06
to
Sorry,
think this is (very) trivial
... but please help a starter in this world ;).

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!

Axel Hecht

unread,
Nov 13, 2006, 1:56:06 PM11/13/06
to

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

gNeandr

unread,
Nov 13, 2006, 2:57:55 PM11/13/06
to
Am 13.11.2006 19:56 schrieb »Axel Hecht«
Axel, thanks ... but as said with my first posting.

"please help a starter in this world ;)."

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

Axel Hecht

unread,
Nov 13, 2006, 3:46:50 PM11/13/06
to

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

gNeandr

unread,
Nov 13, 2006, 4:28:12 PM11/13/06
to
Am 13.11.2006 21:46 schrieb »Axel Hecht«
Axel,
thanks for the moment ... will came back with a more detailed post.
Or would it be possible to send you a private message with code whole
code? So you cold have a better look on what I'm doing?

Guenter

Axel Hecht

unread,
Nov 13, 2006, 11:22:43 PM11/13/06
to

I doubt that I'll be able to do some debugging.

Axel

0 new messages