2

This code gives me only English application name if .desktop file does not have "Name[*]" options (like in totem.desktop) but only "X-Ubuntu-Gettext-Domain: totem":

from gi.repository import Gio
app = Gio.app_info_get_default_for_type('video/x-flv', True)
print app.get_name()

This like code gives me proper result for vlc.desktop.

Ubuntu Dash shows proper localized names for all applications.

How do I get localized names of application in python?

Sorry for my English.

2 Answers 2

1

You'll need to get the value for X-Ubuntu-Gettext-Domain, and get the translation from that domain with something like gettext.dgettext(domain, app_name). Most app names aren't/shouldn't be translated, though.

2
  • Thanks! Should I get domain directly from .desktop files? Dec 7, 2012 at 17:59
  • Yes, it appears you'll have to load the .desktop file with the GKeyFile API directly to get the domain. I don't see any any API methods to do so in the app info APIs.
    – dobey
    Dec 7, 2012 at 18:07
1

I found the solution. This code works perfect:

from gi.repository import Gio
from xdg.DesktopEntry import DesktopEntry

app = Gio.app_info_get_default_for_type('video/x-flv', True)
filename = app.get_filename()
de = DesktopEntry(filename)

print de.getName()

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .