LangpacksDesktopfiles

Differences between revisions 5 and 13 (spanning 8 versions)
Revision 5 as of 2005-11-04 15:52:41
Size: 3584
Editor: 200_220_103_66-WIFI_HOTSPOTS
Comment:
Revision 13 as of 2005-11-05 22:46:05
Size: 5291
Editor: 209
Comment: minor cleanup
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
##(see the SpecSpec for an explanation)
Line 6: Line 5:
 * '''People''': MartinPittLead, CarlosPerelloMarinSecond, ZygmuntKrynicki
 * '''Contributors''':
 * '''Packages affected''': TBD
 * '''Contributors''': JordiMallach, MartinPitt, CarlosPerelloMarin, ZygmuntKrynicki
 * '''Packages affected''': intltool, libbonobo (?), glib, pyxdg, gnome-desktop (?)
Line 12: Line 10:
Some translatable files do not use gettext at runtime, but rather contain all translations in a single file, like .desktop and .server files. We want to find a robust and generic way to update these translations through Rosetta and language packs. Some translatable files do not use gettext at runtime, but rather contain all translations in a single file, like .desktop, .server and .directory files. We want to find a robust and generic way to update these translations through Rosetta and language packs.
Line 23: Line 21:
  The Gnome libraries that evaluates desktop/server/directory files should just use gettext() to translate entries since application's *.mo files already ship the translations.
Line 24: Line 24:
There are two ways how to achieve this goal: In the past we proposed the extension of the [http://standards.freedesktop.org/desktop-entry-spec/latest/ FreeDesktop standard] to support an additional field TranslationDomain, so that Gnome, KDE, and other implementations can find the matching .mo file at runtime to get additional translations from it. However, since this has been rejected upstream, we will use our own Ubuntu specific field for this.
Line 26: Line 26:
=== Parallel hierarchy ===

 * pkgstriptranslations will store .desktop and .server files in translation tarballs.
 * Rosetta will export a file that maps .desktop/.server file names to translation domains.
 * langpack-o-matic uses intltool/homebrew script to add new translations to those files.
 * We create a new package desktop-translations which ships files in parallel directory hierarchies /usr/share/applications-langpack/ and /usr/lib/bonobo/servers-langpack/; those files are preferred over the files in the original directory. It only requires very few changes to lookup files into these additional directories. We just have to make sure that the desktop backend that is responsible for that ignores files whose application is not installed.
    * desktop-translations can be updated after the release to provide new desktop files.

=== Switch to use gettext ===

The Gnome library that evaluates desktop/server files should just use gettext() to translate entries since application's *.mo files already ship the translations. Therefore we want to propose the extension of the [http://standards.freedesktop.org/desktop-entry-spec/latest/ FreeDesktop standard] to support an additional field TranslationDomain, so that Gnome, KDE, and other implementations can find the matching .mo file at runtime to get additional translations from it. Note that most upstream packages already use gettext to translate .desktop files at build time.

This could require some caching to speed up the process.
Note that most upstream packages already use gettext to translate .desktop files at build time. For this packages we only need to change intltool to put the translation domain into the destination files.
Line 42: Line 30:
A proposed domain key is: === .desktop/.directory file format ===
Line 44: Line 32:
{{{
X-Gettext-Domain
}}}
 * We will use the key `X-Ubuntu-Gettext-Domain` for storing the translation domain in .desktop-like files.
 * `intltool-merge --desktop-style` needs to put the translation domain into the destination file.
Line 48: Line 35:
=== Code === === .server file format ===
Line 50: Line 37:
pyxdg and libgnome-desktop are patched to support gettext:  * We will add a Ubuntu-specific attribute and add Ubuntu translations to the `<oaf_server>` tag (`ubuntu-gettext-domain`).
 * `intltool-merge --ba-style` needs to put the ubuntu-gettext-attribute in the <oaf_server> stanza in the destination file. This implies parsing XML.

=== gnome library changes ===

pyxdg and libgnome-desktop have patches to support gettext:
Line 53: Line 45:
 * https://launchpad.net/products/glib/+bug/3935
 
gnome-panel is moving to use glib's GKeyFile and libgnome-desktop's parser is being set as deprecated.
Glib is now patched and works fine. Current patch will only affect desktop files (identified by [Desktop Entry] group.
Line 54: Line 50:
=== Data preservation and migration === === KDE ===
Line 56: Line 52:
No data needs to be preserved when adding data to language packs. KConfig will need an i18n call to find the translation and fall back to the .desktop file if the .po does not contain a translation. i18n is done by KLocale and we will need to be careful not to create recursion between KConfig and KLocale.

KDE extracts .desktop files into .po files using createdesktop.pl (and supporting scripts in l10n/scripts in KDE's SVN). Use this script to generate .pot files that we will ship. We will modify this script to get it to add the gettext domain to the .desktop files.
Line 60: Line 58:
JorgeBernal: all the .desktop files are going to be in the language-packs? gnome-app-install currently extracts data from packages directly. If all the .desktop files are going to be in the language pack g-a-i can use it. I'm attending to the BOF, but I just wanted to note this to not forget it.  * Coordination with Xubuntu.
 * If performance becomes an issue, we need to think about adding pre-caching of the translations. However, Zygmunt did some tests which look promising: gettext() lookups do not impede runtime performance at all, just slow down the panel startup a bit.
 * SuSE uses one large .po file for this as operations such as loading the k-menu might be too slow with lots of smaller .po files.
Line 62: Line 62:
== BoF agenda and discussion == === Random ideas about performance improvements (for historical reasons) ===

 * Regenerating the desktop files at language postinst time does not work, since this does not take desktop files into account that are installed after the language pack installation.
 * apt hooks are not generic enough to support updating files when a new package is installed. There are no dpkg hooks, as they are considered evil. However, if dpkg hooks should be available at one day, they could be utilized for pregenerating translated files.
 * Modify postinst files with a debhelper hook which asks for updating translations in files.
 * Put make /usr/share/applications the secondary lookup location, primary location could be changed to /usr/share/applications-cache/ which could be a tarball extracted over ramdisk. Similar operation could be performed for default /usr/share/locale-langpack/$LANGUAGE to reduce the slowness of stat and open
 * Use a gettext daemon that maintains a lazy cache in /var/cache/gettext. The cache would be full after the first run. Each i18n update would invalidate the cache (either manually or automatically with some inotify magic)

Summary

Some translatable files do not use gettext at runtime, but rather contain all translations in a single file, like .desktop, .server and .directory files. We want to find a robust and generic way to update these translations through Rosetta and language packs.

Rationale

Currently the language packs contain only translations for desktop applications that use gettext. However, there are many more translatable items in Ubuntu. Our goal is to extract all translatable contents from application packages, import them into Rosetta, and ship them into language packs so that they can be updated after a release and benefit from Rosetta updates.

Scope and use cases

  • Sjoerd adds a Dutch translation to a menu entry of a Breezy application in Rosetta. Breezy users should get this new translation with the next language pack update.

Design

The Gnome libraries that evaluates desktop/server/directory files should just use gettext() to translate entries since application's *.mo files already ship the translations.

In the past we proposed the extension of the [http://standards.freedesktop.org/desktop-entry-spec/latest/ FreeDesktop standard] to support an additional field TranslationDomain, so that Gnome, KDE, and other implementations can find the matching .mo file at runtime to get additional translations from it. However, since this has been rejected upstream, we will use our own Ubuntu specific field for this.

Note that most upstream packages already use gettext to translate .desktop files at build time. For this packages we only need to change intltool to put the translation domain into the destination files.

Implementation

.desktop/.directory file format

  • We will use the key X-Ubuntu-Gettext-Domain for storing the translation domain in .desktop-like files.

  • intltool-merge --desktop-style needs to put the translation domain into the destination file.

.server file format

  • We will add a Ubuntu-specific attribute and add Ubuntu translations to the <oaf_server> tag (ubuntu-gettext-domain).

  • intltool-merge --ba-style needs to put the ubuntu-gettext-attribute in the <oaf_server> stanza in the destination file. This implies parsing XML.

gnome library changes

pyxdg and libgnome-desktop have patches to support gettext:

gnome-panel is moving to use glib's GKeyFile and libgnome-desktop's parser is being set as deprecated. Glib is now patched and works fine. Current patch will only affect desktop files (identified by [Desktop Entry] group.

KDE

KConfig will need an i18n call to find the translation and fall back to the .desktop file if the .po does not contain a translation. i18n is done by KLocale and we will need to be careful not to create recursion between KConfig and KLocale.

KDE extracts .desktop files into .po files using createdesktop.pl (and supporting scripts in l10n/scripts in KDE's SVN). Use this script to generate .pot files that we will ship. We will modify this script to get it to add the gettext domain to the .desktop files.

Outstanding issues

  • Coordination with Xubuntu.
  • If performance becomes an issue, we need to think about adding pre-caching of the translations. However, Zygmunt did some tests which look promising: gettext() lookups do not impede runtime performance at all, just slow down the panel startup a bit.
  • SuSE uses one large .po file for this as operations such as loading the k-menu might be too slow with lots of smaller .po files.

Random ideas about performance improvements (for historical reasons)

  • Regenerating the desktop files at language postinst time does not work, since this does not take desktop files into account that are installed after the language pack installation.
  • apt hooks are not generic enough to support updating files when a new package is installed. There are no dpkg hooks, as they are considered evil. However, if dpkg hooks should be available at one day, they could be utilized for pregenerating translated files.
  • Modify postinst files with a debhelper hook which asks for updating translations in files.
  • Put make /usr/share/applications the secondary lookup location, primary location could be changed to /usr/share/applications-cache/ which could be a tarball extracted over ramdisk. Similar operation could be performed for default /usr/share/locale-langpack/$LANGUAGE to reduce the slowness of stat and open
  • Use a gettext daemon that maintains a lazy cache in /var/cache/gettext. The cache would be full after the first run. Each i18n update would invalidate the cache (either manually or automatically with some inotify magic)

LangpacksDesktopfiles (last edited 2008-08-06 16:30:07 by localhost)