Update: Don’t use this code. Use this new version.
A few months ago, I posted a snippet of code that provides an API for using locale files from Google Chrome extensions in extensions for Firefox 3.6 and older. I’ve now added support for Firefox 4, and the updated code is shown below:
The same usage rules still apply:
- Replace “MY_EXTENSION_ID” with the ID of your extension.
- Rename “MY_EXTENSION_STRINGS” to something that won’t interfere with another extension.
- The _locales directory from your Chrome extension should be in the chrome/content/ directory of your Firefox extension (or update my code to point to wherever you put it).
- Include the excellent io.js library in your extension.
- NEW: For Firefox 4, you’ll need to specify <em:unpack>true</em:unpack> in your install.rdf.
I’ve been using this solution in ScribeFire in Firefox 3.5, 3.6, and 4.0 (and 5 and 6) for a while now with no complaints. Let me know if you implement this in your extension, and I’d love any feedback you have on the code or its performance.