using string bundles with JavaScript

For localization of text that gets displayed with JavaScript, there are multiple techniques. First, we could use <data>&some.text;</data> constructs (which don't get displayed in the UI), read their values from JS and use them for displaying. This isn't a very elegant solution though.
The normal solution for this situation is to use string bundles, which are saved in Java-style .properties files. String bundles can be accessed in two ways: First, they can be read by a XUL <stringbundle> element:

Sample XUL: openLocation.xul, calling some JS code

<?xml version="1.0"?>
<!DOCTYPE dialog SYSTEM "chrome://communicator/locale/openLocation.dtd">
<dialog id="openLocation" ... title="&caption.label;" onLoad="onLoad();">
<script type="application/x-javascript" src="chrome://communicator/content/openLocation.js"/>
<stringbundle id="openLocationBundle" src="chrome://communicator/locale/openLocation.properties"/>
...
        <menuitem value="0" id="currentWindow" label="&topWindow.label;"/>
...
</dialog>

Sample JavaScript: openLocation.js

...
function onLoad()
{
  dialog.main = document.getElementById("openLocation");
  dialog.openTopWindow = document.getElementById("currentWindow");
  dialog.bundle = document.getElementById("openLocationBundle");
  if (!browser) {
    // No browser supplied - we are calling from Composer
    // Change string to make more sense for Composer
    dialog.openTopWindow.setAttribute("label", dialog.bundle.getString("existingNavigatorWindow"));
    // change title to 'Open Location with Mozilla'
    dialog.open.setAttribute("title", dialog.bundle.getString("caption2.label"));
  }
}

Sample string bundle: openLocation.properties

existingNavigatorWindow=Existing Navigator window
caption2.label=Open Location with Mozilla