# How do I get localized names of application in python?

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.

-

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.

-
Thanks! Should I get domain directly from .desktop files? –  Mystic-Mirage Dec 7 '12 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 '12 at 18:07

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()

-