Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

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/overlay.properties" id="your-extension-strings" /> 
</stringbundleset>

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["@mozilla.org/intl/stringbundle;1"].getService(Ci.nsIStringBundleService);
let bundle = stringBundleService.createBundle("chrome://your_extension/locale/overlay.properties");
let str = bundle.GetStringFromName("propertyName");

see nsIStringBundleService

Document Tags and Contributors

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