Gettext support for .desktop files

Bug #3697 reported by Zygmunt Krynicki
8
Affects Status Importance Assigned to Milestone
pyxdg (Ubuntu)
Medium
Martin Pitt
Jaunty
Medium
Martin Pitt

Bug Description

Gettext support is badly needed.

Related branches

Revision history for this message
Zygmunt Krynicki (zyga) wrote : Debdiff against pyxdg_0.15-0ubuntu2.dsc to support gettext

This patch adds gettext support.

Zygmunt Krynicki (zyga)
Changed in pyxdg:
assignee: nobody → mvo
Revision history for this message
Martin Pitt (pitti) wrote :

Some beautification proposals:

++ self.gettext_domain = self.get('X-Gettext-Domain') or None

should be

++ self.gettext_domain = self.get('X-Gettext-Domain')

(hash.get() already returns None by default if the key doesn't exist).

+- value = self.content[group][self.__addLocale(key, group)]
++ if self.gettext_domain:
++ value = gettext.dgettext(self.gettext_domain, self.content[group][key]) or self.content[group][self.__addLocale(key, group)]
++ else:
++ value = self.content[group][self.__addLocale(key, group)]

looks a bit overcomplicated and wrong; dgettext() certainly never returns None? So the 'or' in the then clause does not make sense. Instead, self.content[group][self.__addLocale(key, group)] should be used if dgettext() just returns the initial argument (i. e. untranslated).

Revision history for this message
Zygmunt Krynicki (zyga) wrote : Improved patch

This patch will only use the X-Ubuntu-Gettext-Domain key from [Desktop Entry] sections.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Martin, any comment on the new patch?

Revision history for this message
Martin Pitt (pitti) wrote :

Looks sane enough, but I didn't test it.

Michael Vogt (mvo)
Changed in pyxdg:
status: Unconfirmed → Confirmed
Matt Zimmerman (mdz)
Changed in pyxdg:
assignee: mvo → pitti
Revision history for this message
Martin Pitt (pitti) wrote :

 pyxdg (0.15-1ubuntu4) dapper; urgency=low
 .
   * Add debian/patches/gettext-support.patch: Apply forgotten patch from
     Zygmunt Krynicki to get language pack support for .desktop files also in
     gnome-app-install. Closes: LP#3697

I made the patch a little more robust to protect against exceptions from gettext. Works fine now. Thanks!

Changed in pyxdg:
status: Confirmed → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Reopening, since the latest glib now made some behaviour changes which need to be mirrored in pyxdg. In particular, it needs to prefer inline translations over gettext ones now. (See http://bugzilla.gnome.org/show_bug.cgi?id=569829)

Changed in pyxdg:
status: Fix Released → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package pyxdg - 0.15-1.1ubuntu5

---------------
pyxdg (0.15-1.1ubuntu5) jaunty; urgency=low

  * gettext-support.patch: Update to corresponding changes in glib:
    - Prefer inline translations over gettext ones.
    - Prefer X-GNOME-Gettext-Domain over X-Ubuntu-Gettext-Domain.
    - LP: #3697

 -- Martin Pitt <email address hidden> Wed, 04 Mar 2009 19:24:18 +0100

Changed in pyxdg:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.