[Project_owners] Accessing locale strings

Pete sneakypete81 at gmail.com
Fri Jul 6 11:06:26 PDT 2007

I think I've stumbled across a solution: rather than using the DOM to
extract strings from a .properties file in the locale folder, use the

var gBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]

var mystrings =
var alertOneChange = mystrings.GetStringFromName("alertOneChange");

Thanks Eric - I had already tried the nsIWindowMediator trick, but no
luck for some reason.

The method getString is for working with string bundles:

...recommended in a number of extension localisation examples. It
looks like nsIStringBundleService is more flexible though, as it
doesn't rely on access to the DOM.

On 05/07/07, eric.jung at yahoo.com <eric.jung at yahoo.com> wrote:
> You could try using
> nsIWindowMediator.getMostRecentWindow("navigator:browser")
> to get the appropriate window. From that, you can get the document you seek.
> http://www.xulplanet.com/references/xpcomref/ifaces/nsIWindowMediator.html
> By the way, what does the method getString() do? I haven't seen that used on
> a w3c dom node.

More information about the Project_owners mailing list