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.
Usage
The new usage rules are as follows:
- Replace
MY_EXTENSION_NAMESPACEwith the namespace of your extension’s files. e.g., if your files are atchrome://abcdefg/content/, then replaceMY_EXTENSION_NAMESPACEwithabcdefg. - Rename
MY_EXTENSION_STRINGSto something that won’t interfere with another extension. - The
_localesdirectory from your Chrome extension should be in thechrome/content/directory of your Firefox extension (or update my code to point to wherever you put it).
Advantages
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.
Leave a Reply