Subscribe to RSS Feed

Firebug 1.6 is slowly approaching a beta phase and one of the last features we have put in a18 is related to localization. Note that Firebug is currently using more than 500 strings in its UI and these are translated into approximately 40 languages.

Even if we are always planning a string freeze in order to give Firebug translators some time to process new strings, we often end up with a few unfinished locales.

This is a problem especially for DTD entities since missing entity causes fatal error and in case of Firebug - not loading the extension at all (XUL overlay is not loaded). The problem is not that critical if the missing string comes from a *.properties file, since these are scriptable and we can handle the missing-string-exception in Javascript. The only issue is what to display in the UI instead.

From these reasons we decided to do following:

  • Don't use DTD entities
  • Use en-US as fallback locale (for missing strings)

And as a bonus (!), these changes allowed to fix Issue 907: Option to use en-US locale instead of fx default locale

So, all you need to do to always use Firebug with en-US locale, is to set
preference to true. There is no UI in Firebug for this option and so, you need to use about:config (see all prefs in Firebug).

Do you think this should be available in Firebug->Options menu?

Read further, if you interested how we implemented that.

Don't use DTD entities

The trick in this this task was to move all strings from firebug.dtd file into file and do it for all existing translations (while encoding of all files is preserved). I used sed and the following script (thanks to Hector for his help!).

ls */firebug.dtd | sed "s/\(.*\).dtd/sed 's\/<\!ENTITY \\\(.*\\\) \"\\\(.*\\\)\">\/\\\1=\\\2\/g' \1.dtd >> \" | sh

The script transforms strings from */firebug.dtd files from this format:

<!ENTITY firebug.Help "Help">

into file format:


...and appends all at the end of the */ file (encodings preserved). If it's executed in the locale directory of your extension, it's done for all locales at once.

I am not a sed expert neither a shell expert, so take this script as it is and in case of questions use FAQ.

Use en-US as fallback locale

The trick in this case was to get the default (en-US) locale file even though Firefox uses different locale. You can quickly find out that URL of the locale is always the same and resolved dynamically using the default Firefox locale.

So for example:

chrome://firebug/locale/ using file from locale/en-US directory if Firefox is set to use en-US locale. In case of e.g. da-DK, the file is loaded from locale/da-DK directory.

Also, you can't use just:

chrome://firebug/locale/en-US/ // WRONG

This wouldn't be resolved to a file.


The correct way is to transform the chrome URL into file URL and replace the locale dir name with en-US (thanks John J. Barton for the idea!).

Here is an example how to do it.

var ioService = Cc[";1"]
var cr = Cc[";1"]
var sbs = Cc[";1"]

var uri = ioService.newURI(
    "chrome://firebug/locale/", "UTF-8", null);
var fileURI = cr.convertChromeURL(uri).spec;
var parts = fileURI.split("/");
parts[parts.length - 2] = "en-US";

var bundle = sbs.createBundle(parts.join("/"));

Now bundle implements nsIStringBundle and so, you can load strings from it using e.g. GetStringFromID().

Rss Commenti


  1. [...] Zobacz resztę artykułu: Software is hard | Firebug 1.6: Switch to the default locale [...]

    #1 Software is hard | Firebug 1.6: Switch to the default locale « switch
  2. [...] Software is hard | Firebug 1.6: Switch to the default locale [...]

    #2 Proposed federal rules target for-profit colleges
  3. Hm, you didn't have to resort to THAT. Folks at mozilla have had l10n-merge scripts for quite some time, you could just borrow them and make them a part of the release process.

    Regarding en-US. One could argue about what a default locale actually is – en-US or the one used by Firefox. IMHO, it's the latter. I think you could have just used extensions.firebug.useUSLocale instead...

    #3 RQ
  4. [...] Software is hard | Firebug 1.6: Switch to the default locale [...]

    #4 City boat ramp might move outside city | Express Cruiser Boat Building & Design
  5. [...] Option to use en-US locale [...]

    #5 Getfirebug Blog » Blog Archive » Firebug 1.6b1

Sorry, the comment form is closed at this time.