Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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()
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.