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/"/>
        <menuitem value="0" id="currentWindow" label="&topWindow.label;"/>

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'"title", dialog.bundle.getString("caption2.label"));

Sample string bundle:

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