MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See for all notifications.

Your Search Results

    Access StringBundle from Overlay

    Stringbundles are handy for localizing your project by removing all of your strings into a separate, easy to access text file. Unfortunately adding the bundles into Thunderbird isn't as easy as adding them to your XUL overlay. The most efficient way to append these strings is by attaching them to an existing stringbundleset as such:

    <stringbundleset id="stringbundleset">
      <stringbundle src="chrome://your_extension/locale/" id="your-extension-strings" /> 

    Now that your stringbundle is attached you can access it from JavaScript as follows:

    var str = document.getElementById("your-extension-strings"); //get the stringbundle object itself 
    str.getString("propertyName");                                 //get a string (and do something with it) 


    Alternative way

    let stringBundleService = Cc[";1"].getService(Ci.nsIStringBundleService);
    let bundle = stringBundleService.createBundle("chrome://your_extension/locale/");
    let str = bundle.GetStringFromName("propertyName");

    see nsIStringBundleService

    Document Tags and Contributors

    Contributors to this page: wbamberg, mozjonathan, jllogan
    Last updated by: wbamberg,
    Hide Sidebar