D-Bus service for Apertium

From Apertium
Revision as of 22:09, 7 March 2018 by Francis Tyers (talk | contribs)
Jump to navigation Jump to search

This page is out of date as a result of the migration to GitHub. Please update this page with new documentation and remove this warning. If you are unsure how to proceed, please contact the GitHub migration team.

D-Bus is a simple inter-process communication system. We are in the process of developing D-Bus services for Apertium which will make programmatic access to the Apertium tools easier. We have started developing simple D-Bus bindings for Apertium which allow for:

  • discovery of details of the current Apertium installation and,
  • translations via a programmatic interface.

The D-Bus bindings are needed for some of the tools, such as Apertium-view and Apertium-tolk.


  • apertium (>= 3.0.0)
  • python
  • dbus
  • python-dbus


The package is available from SVN in the apertium-dbus module. The process for installation is the standard:

$ svn co http://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium-dbus
$ ./autogen.sh
$ make 
$ make install

The current package is in the process of being ported to Python3, but should work. Do "svn up -r25849" if you want to get the last working Python2 version instead.

Check that it works

You can check that the bindings work by issuing the command:

dbus-send --print-reply --dest=org.apertium.info / org.apertium.Info.modes

This should return an array of strings of all the Apertium modes installed on your system. It should look something like

$ dbus-send --print-reply --dest=org.apertium.info / org.apertium.Info.modes 
method return sender=:1.567 -> dest=:1.599 reply_serial=2
   array [
      string "en-ca"
      string "ca-en"
      string "en-af"
      string "af-en"

To translate from the command line (assuming apertium-en-ca is installed), try e.g.

$ dbus-send --print-reply --dest=org.apertium.mode / org.apertium.Translate.translate string:en-ca dict:string:string:"mark_unknown","true" string:'My hoovercraft is full of eels'

If the above two commannds don't work, then it's quite possible that a Python error from our side snuck in. Try running info.py directly; that is

python info.py -p /usr/local

where the prefix for Apertium in the above example is /usr/local. If you get a Python error, please post the error on this page or post a bug report in our bug tracker. If the service starts up without errors, try executing

dbus-send --print-reply --dest=org.apertium.info / org.apertium.Info.modes

again. If there is no output, then open a new terminal and run


This neat utility shows you the activity on the D-Bus. Now try executing dbus-send --print-reply --dest=org.apertium.info / org.apertium.Info.modes again.

If you have no luck, come and talk to us in #apertium at irc.freenode.net

Installing into a prefix

This is unfinished
  • Do: mkdir -p <prefix>/share/dbus-1/services/
  • Make a session-local.conf file like it says here under "" Configuration Information"".
    • Change the <servicedir> element value to <prefix>/share/dbus-1/services/
  • Restart dbus. /etc/init.d/dbus restart
  • Log out and log back in again


Currently, Apertium offers two D-Bus services:

  • org.apertium.info has a single object /, which offers rudimentary information about the Apertium installation.
  • org.apertium.translate contains an object for each Apertium mode installed in the system.


If you make a change to any of the D-Bus configuration files, you will need to restart both the system-wide and session D-Bus daemons. The system-wide daemon can be restarted on a Debian/Ubuntu system with:

  • /etc/init.d/dbus restart

The only real way to restart your session deamon is to logout and log back in again. You will likely run into strange problems if you attempt to kill the session D-Bus daemon.

Filesystem layout

  • /usr/share/dbus-1/services/ — DBUS .service files.
  • /usr/share/apertium/dbus-1/ — Python code that actually does the service (info.py and mode.py)


There are some simple examples in various languages on the page D-Bus examples.

External links