Tuesday, May 31, 2005


Icons in the nl world

Eclipse 3.1 is going to support bidirectional languages (those that can type right to left as well as left to right such as Arabic). This means that for a lot of Eclipse applications you are going to want to provide alternative icons to those you ship (mostly those with a horizontal arrow or something like that).

First step is nl'ing your icon lookup. The Platform does this internally in a bunch of places by creating a URL and using the Runtime API to look it up. The secret is the $nl$ in your path - that tells the runtime to look in fragments as well.

Here is an example

String iconPath = "$nl$/icons/myicon.gif";

URL url = Platform.find( Platform.getBundle(MyPluginId), new Path(iconPath));

Image Descriptor descriptor = ImageDescriptor.createFromURL(url);

If you want to dig around more have a look at org.eclipse.ui.internal.util.BundleUtility to see how we do it.

If the icon reference is in your plugin.xml just make sure you have the $nl$ prefix on your path. We will handle this for you (and log us a bug if not!). Just make sure if you create your own extension point that it loads ImageDescriptors this way.

Second step is creating a fragment - icons are done the same way as message catalogs so no rocket science there.

Finally test it. You can switch orientation using the -dir rtl command line option or by specifying a bidirectional language using the -nl option (iw (Hebrew), ar (Arabic), fa (Farsi) or ur (Urdu)). Note we don't do this for free as a lot of users in these locales still want the left to right look.
Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?