After I posted my latest revision to some code for using Google Chrome locale files in Firefox extensions, Wladimir Palant pointed out some shortcomings with the code; I’ve made some changes to address these issues, and the new code is shown below.
The new usage rules are as follows:
MY_EXTENSION_NAMESPACEwith the namespace of your extension’s files. e.g., if your files are at
chrome://abcdefg/content/, then replace
MY_EXTENSION_STRINGSto something that won’t interfere with another extension.
_localesdirectory 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).
This code has four advantages over the previous versions:
- It’s a single code block that works with all recent versions of Firefox.
- You don’t need to include an additional library for file I/O.
- It fixes a bug in retrieving the proper locale code in Firefox on Linux.
- You don’t have to specify
<em:unpack>true</em:unpack>in your install.rdf in Firefox 4.
Thanks Wladimir for your input; this version is undoubtedly better than both previous versions. I can’t ensure that it’s the best possible solution, but it’s the best one that I’ve found so far.