Instantbird 0.2 alpha 1 and addons!

Today is a very special day for us. We have a double release to announce!

First, the long awaited add-ons website is now ready for you to use. You will already find a lot of extensions on it since we took care of uploading more than 200 of them. Think about browsing the experimental add-ons, a lot of them are still marked as such. The add-ons website is at this address: https://addons.instantbird.org/.

And last, but not least, Instantbird 0.2 alpha 1 is now ready for you to try it! There’s a lot of new interesting stuff in this one. Here are some of them, read the release notes for more:

  • It is ready to be localized (and you can try an experimental French language pack),
  • Improved conversations: you can change conversation styles, smiley themes are now handled.
  • We implemented a ‘magic’ copy/paste feature that will allow you to have pretty quotes out of messages copied from Instantbird. Some bugs may still exist in this.
  • As usual, we took great care of stability issues, so Instantbird 0.2 alpha 1 is already more stable than 0.1.3.1 at this point, so don’t hesitate to give it a try!

You can download the alpha and read the release notes from here.

Instantbird 0.2 feature preview: conversations customization

In our roadmap we stated that for 0.2 we were going to improve the conversation window, and especially make it customizable. Let’s show you an overview of what we did.

Smileys

People are used to see little images like :-) in conversations instead of the plain text version :-). Testers of Instantbird 0.1.* have probably noticed that this feature was missing. No more.

Instantbird 0.2 supports smileys, and has a theme system for them. Creating a new smiley theme is easy: it is just a bunch of images and a file (JSON format) describing how to use them, bundled into an XPI file.

Message styles

Selecting a smiley theme is not enough for you to feel comfortable when looking at your conversations? Ok, we have more! We have borrowed the message style system of Adium to let you fully customize the way your conversations look.

An image is worth a thousand words so… I’m gonna give you a thousand of images. Ok, not really a thousand, but we took a few hundreds of screenshots to show how Instantbird is doing with the hundreds of Adium message styles downloadable from adiumxtra.com.

The compatibility is not perfect because there are some differences in the way Instantbird and Adium handle themes, and some Adium themes may use some webkit-specific features, but most themes look right.

This theme system is very flexible, and quite easy to learn. The technologies used (HTML, CSS, JavaScript) are well known by web-developers and web-designers. If you are not happy with the existing themes, go ahead an create your own. And don’t hesitate to let your creativity play with all the cool new developer features of Firefox 3.5.

Extensibility

The eye candy is cool but… I’m a developer, I want to create extensions and I want to be able to interact with the conversations! Don’t worry, we love you too. We added several new APIs for extension developers. It is now easy, for example, to change the way we filter incoming messages, modify the text before it is displayed (adding links for instance), and more coming!

Instantbird 0.2 Feature Preview: Localizability

As you may (or may not) know, we previously wrote that Instantbird 0.1.* was not localizable. The reason evoked for this was the use of gettext by libpurple, which is not compatible with the way XUL applications are localized. I’m going to give more details about the issue, and explain how we solved it for Instantbird 0.2.

Comparison of translation systems used by Mozilla and libpurple:

Inside libpurple, localizable strings are just marked by _("string"). For example, you can find this in the code:

description = _("Unknown error");

During the compilation, _() is expanded by the C preprocessor to a call to a gettext function. Gettext tools can analyze the source code, find all strings enclosed in _() markers, and produce a translation template. This template (a .pot file) is then handed to translators, who translate the strings and then provide a .po file for their language.

The translation system for XUL applications is quite different, here are 2 significant differences:

  • localizable strings are not directly in the source code. The source code uses unique identifiers, and these identifiers are used to find the actual string in the locale files.
  • the strings are spread across several localized files. Usually each window has its separate files, which makes it easy to decide at a later point that something will become an extension, and makes it easy to localize an extension like any other part of the application.

How do we deal with this in Instantbird?

Obviously, we don’t want Instantbird to use both of these localization systems, so one had to be removed. In Instantbird 0.1.*, we just removed gettext without replacing it. This means that the gettext _() macro was defined to something doing nothing, and the string used was just the one specified directly inside the source code.

For Instantbird 0.2, this is no longer acceptable, and we worked on a way to simulate the action of gettext, that is, hiding the 2 differences I’ve just explained.

Splitting the translation in different files wasn’t very difficult. Actually, gettext has a concept of packages that makes it possible to split the translation of an application into several packages, the feature is just unused by libpurple. With a little bit of build system tweaking, I finally got a translation file for the core of libpurple, and a separate translation file for each protocol plugin. This was needed so that libpurple protocol plugins packaged as extensions can be localized.

Creating a unique identifier for each localizable string was a bit more work. The solution we have settled on is:

  • Take the original string and remove all string formatters (words starting with %), hexadecimal numbers (words starting with 0x) and more generally, all non alphanumeric characters.
  • Remove all the whitespace in the remaining string, keep only the 7 first words, and convert to camel case.

At this point, we have an identifier for the original string, but it is not unique. Long strings that differ only at the end result in the same identifier, and strings that don’t contain any real word (‘%s:%s’ for instance) all result in an empty string. To disambiguate in these cases, and only in these cases, we append the 8 first characters of the hexadecimal MD5 hash of the original string to the identifier.

Now, how do we use this?

We have a .properties file for libpurple and one for each protocol plugin. When libpurple is compiled for Instantbird, the gettext macros are modified to point to some of our code instead of the gettext library. Our code uses the en-US string to build the identifier, and attempts to find it in the .properties file. If it isn’t found, it tries again with the identifier plus the 8 first characters of the MD5 hash of the string. If it still isn’t found, then it returns the en-US string as a fallback (and emits a warning in debug builds).

How do we make the .properties files for libpurple?

I wrote a python script that generates automatically the appropriate .properties files for the en-US language from the source code of libpurple. Additionnaly, it uses the various .po files of Pidgin to produce files that can be used as a base for localizing this part of Instantbird.

Does this mean I can start translating Instantbird into my own language?

No, not yet, but very soon! Once we are ready to accept contributions from translators, we will ask translators who volunteer to localize Instantbird to contact us so that we can provide them with these generated files.

An alpha build of Instantbird 0.2 will be available soon. We will provide an experimental French translation of this build (most people in our team are French, so French was the logical choice for testing all of this ourselves).