About Domains

A domain is a package's translation dictionary.


  • The gedit package's domain is gedit

  • GTK2.0's domain is gtk20

The domain defines the file name of the translation catalog that software can use to obtain translations. The catalog filename always ends with ".mo". For example, gedit's translation catalog is named:, and gtk20's is named

Tip: For most packages, the domain is defined in the source code's file.

Note: It is not always easy to find the domain for a translation you see in the user interface, although there are methods.

Locale Needed

However, the domain is not enough to obtain a translation at run time: the current locale is also needed.

This is obvious when you think about it: I need message "X" translated and the application (the domain) is "Y": the only missing piece is the language you want it translated into, therefore the locale is also needed.

So, retrieving a translation (at run time) requires:

  • The message to be translated
  • The domain
  • The locale

The locale is represented as system-wide environment variables. (Although, as noted elsewhere, you can override this in a command shell).

Gettext is the system that provides this run-time translation retrieval in Ubuntu.

Translation Catalogs

So, a package must install a translation catalog (a file) for each language into which it is translated. All of a package's translation catalogs are named the same:

How can that be? They are installed into locale-specific paths.

Note: In Ubuntu, packages that are in Main or Restricted do not install their own translation catalogs. These are installed by language packs, and their translations derive from upstream work plus any changes specifically made in Launchpad. More on this elsewhere.

For example, the Ubuntu French translation catalog for gedit is installed here:

  • /usr/share/locale-langpack/fr/LC_MESSAGES/

Its Chinese/Traditional translation catalog is installed here:

  • /usr/share/locale-langpack/zh_TW/LC_MESSAGES/

Can an App use another App's Domain?

Yes. Although normally one can't rely on this.

A package usually defines and uses its own unique translation domain, but the gettext system doesn't require this, and indeed there are domains that include translations for many common UI widgets, such as the gtk20 domain, which provides translations for stock GTK 2.0 widgets.

Thus, if you have French Ubuntu language packs installed, you can find this file: /usr/share/locale-langpack/fr/LC_MESSAGES/ This file contains translations for "OK", "Quit", and other stock GTK text.

Why can't one rely on this? Well, for gtk20, one can: it is always installed in Ubuntu by default for the user's language (although it is not installed for non-gnome Ubuntu Variants). However, even for Ubuntu, it is risky ("bad practice") for a package to use translations from another package's domain for two reasons:

  • One cannot be certain the other package will always be installed (without formally "depending" on it)
  • One cannot be certain it will always provide the translations it currently does. Translations are eliminated when no longer needed, thus there is no guarantee that today's translations will be available tomorrow.



UbuntuDevelopment/Internationalisation/InternationalizationPrimer/Domains (last edited 2010-08-11 17:27:53 by eth3)