Data Translations

Data Translations

  • mdo  DigitalBox
  •   System
  •   April 4, 2025

DataTranslations is a system in Haiku that manages the conversion of various file formats, particularly for images and text. 

These translators act as plugins that applications can use to import/export different formats seamlessly.

Let's review how to handle them from a user's point of view.

Usage

The default Data Translators installed in Haiku are included in the "haiku_datatranslators" package :

If you open the Preferences>DataTranslations application, you will see the complete list :

As you can see above, each Translator's settings can be modified.

Now what about installing a new translator on your system ?

For instance, if you want to handle the SVG image format, you will need to install the "nanosvgtranslator".

In a Terminal type :

pkgman install nanosvgtranslator

If you go back to the DataTranslations application, you will notice the addition of a new "SVG images" entry :

The setting which can be modified is the scale factor :)

DataTranslations is a powerful feature because every Haiku application which is using the BTranslatorRoster API will benefit from any new data translators installed.

It means that, if tomorrow a new image format is created, and if a developer is creating the corresponding data translator plugin under Haiku, any application created prior to this file format will be able to handle it !

Let's take an example about the SVG translator just installed before.

In a Terminal type :

translate /system/data/icons/haiku/apps/32/accessories-calculator.svg  /boot/home/Desktop/accessories-calculator.png 'PNG '

If you open the image on the desktop :

Yes !

The SVG image has been successfully converted to PNG.

If you would like to check if your favorite format is available for translation, you can type :

translate --list | grep JPEG

The above means that the JPEG format has a translator.

What about converting the previous PNG image to SVG ?

Let's check :

translate /boot/home/Desktop/accessories-calculator.png /boot/home/Desktop/accessories-calculator.svg 'SVG '

Even if the SVG translator has been installed, the conversion is only possible in one way, meaning from a vector image to a bitmap image.

BTranslatorRoster API

I've my favorite application which is handling the drag and drop of images.

Let's uninstall the SVG translator :

pkgman uninstall nanosvgtranslator

Now if I drag and drop an SVG icon into the application :

Well nothing happens.

Now let's install the SVG translator :

pkgman install nanosvgtranslator

Let's do a drag and drop again :

Perfect !

The SVG format is now fully handled in the application.

Moving forward

If you would like to identify the translators available, you can type in a Terminal:

pkgman search -a | grep translator

The advantages of DataTranslations is that :

  • Applications don’t need to implement their own format parsers
  • Any new translator can be added without modifying existing applications
  • Developers can easily use the BTranslatorRoster API to handle file formats within their apps

I hope you have found this article useful, and that you will think to use in the future native Haiku apps so you can enjoy the DataTranslations system :)


Powered by Bludit - Hosted by Planet Hoster
© 2025 Haiku Insider