Ubuntu Development > Internationalization Guide > Packaging

Language Packs

General

Packages in main and restricted don't contain translations (*.mo) files themselves, they are stripped during the build on the Launchpad buildds and put into language-pack-* packages instead. This is done in an attempt to bundle the translations you're interested in and cut down the occupied space.

Translations/info.png

Once a package is promoted to main, it only needs to be rebuilt the first time after promotion so that pkgbinarymangler can strip the translations. After this, import to Launchpad Translations and export in language packs "will just happen"

Translation templates

For pkgstriptranslations (in the pkgbinarymangler package) to do the job right and translations to be imported into Launchpad, please make sure that your package in main or restricted generates a POT translation template during the build. It does not necessarily need to be shipped in the source or in the binary package. Generating it during the build is good enough.

Translations/warning.png

If your package does not generate a POT template on build, its translations will remain as Blocked in the Launchpad Translations import queue and will not be imported

The most common approaches are running either of the following in debian/rules:

Other translation files

Desktop Entries

Translations of desktop entries (.desktop files) are also stripped out and included in language packs.

Contrary to what other distros do (except currently OpenSUSE), the translations are not expected to be in the .desktop files themselves (static translations), but rather in the same .mo file of the application, from which they are then loaded at runtime. We do this in order to be able to translate them in Launchpad and to ship them in language packs, so that they can be edited and updated by Ubuntu translators.

The runtime loading is done by patches to patch glib and kdelibs, which recognises the the X-Ubuntu-Gettext-Domain additional key we add to all Ubuntu .desktop files and adds gettext support when loading them. Note that if the .desktop file already contains translations, these static translations will be preferred.

Adding the X-Ubuntu-Gettext-Domain= key is done during build time in the packaging either automatically with the package build system or (increasingly rarely) with patches.

Packaging Method

Method for adding key

KDE CDBS

kde.mk includes /usr/lib/kubuntu-desktop-i18n/kubuntu.mk which adds the key using the package name (or an environment variable specified in debian/rule)

KDE old CDBS

Older packages may will use /usr/share/cdbs/1/class/kde4.mk, which add the key, this is deprecated in favour of /usr/share/pkg-kde-tools/makefiles/1/cdbs/kde.mk

KDE Debhelper 7

/usr/share/pkg-kde-tools/makefiles/1/debhelper/kde.mk includes /usr/lib/kubuntu-desktop-i18n/debhelper/kubuntu.mk which adds the key based on the package name (or an environment variable)

GNOME CDBS

gnome.mk includes langpack.mk, the catalogue name comes from po/Makefile

GNOME Debhelper 7

TODO

GNOME Old

The .desktop files are patched directly e.g. transmission

For KDE the translations themselves are downloaded as part of the packaging process of the upstream kde-l10n-xx language packs.

The patch to glib is being submitted upstream (using the key X-GNOME-Gettext-Domain) but has not yet been accepted. The Ubuntu glib version supports both keys, it first checks for X-GNOME- and then X-Ubuntu-.

In summary, for packages in main we strip the translations out of the .desktop files, and glib/kdelibs carry a distro patch to load translations from the .mo file. They use the X-Ubuntu-Gettext-Domain key to figure out where to get the translation from.

Additional information:

Schema files

TODO

Additional information:

Policy files

$ for i in `ls /usr/share/polkit-1/actions/`; do dpkg -S $i; done

Interactive upgrade hooks

After certain upgrades (most notably upgrades between Ubuntu releases), there are follow-up actions which should be taken by the user. These are not logically part of the upgrade, but should be dealt with at some point after the upgrade is complete.

They take the form of helper scripts that can be called by the package's postinst script, and can be internationalized through language packs.

Here's an example showing how these can be internationalized:

_Name: The great UTF-8 Migration
Priority: Medium
Command: bc
Terminal: True
GettextDomain: hwdb-clinet
DisplayIf: shell-command
Title: Change the default title here
DontShowAfterReboot: False
_Description: 
 This command will convert your stuff into UTF-8.
 Use this command if you want a working gnome desktop and you
 feel the world should be a better place.

This is a notification description file as it should be put into a source package. NB the '_' prefix for fields that should be translated. For getting these strings into the package's PO template, you should add a stanza like this to po/POTFILES.in:

[type: gettext/rfc822deb] debian/utf8-migration.installnote

The file should be shipped in /usr/share/packagename and the package's postinst script should install it if the notification should be displayed. At that time it needs to remove the '_' prefixes:

install -d /var/lib/update-notifier/user.d/
sed 's/^_//' /usr/share/utf8-migration-tool/utf8-migration.installnote > /var/lib/update-notifier/user.d/utf8-migration

Verifying translation uploads

This information is intended to help package maintainers to optimize their packages, so that translation related files get automatically imported into Launchpad.

Testing the package locally

To test if your package conforms to the requirements of the import script in Launchpad, please do the following:

  1. Install the pkgbinarymangler package

  2. In /etc/pkgbinarymangler/striptranslations.conf set enable: to true

  3. Optionally, install any build dependencies: sudo apt-get build-dep $PKGNAME

  4. Build the package with debuild -uc -us -b

  5. You will find a <pkgname>-translations.tar.gz tarball along with the .deb package(s)

  6. Untar that tarball into a temporary directory
  7. Compare if the directory structure and the .pot and .po files conform to the requirements listed below

Guidelines

If the application uses gettext, like most GTK and GNU applications do:

Documentation

TODO:

Packages not using the Gettext format

Mozilla

OpenOffice.org


CategoryUbuntuDevelopment CategoryTranslations

UbuntuDevelopment/Internationalisation/Packaging (last edited 2010-08-03 18:00:26 by 0)