#!/usr/bin/env python
+import gettext
import gtk, gobject
import traceback
import time
# -----------------------------------------------------------------------
def __init__(self):
+ gettext.install('hermes','/opt/hermes/share/locale/')
WimpWorks.__init__(self, 'Hermes', version = '0.2.0', dbus_name = 'org.maemo.hermes')
self.set_background('background.png')
layout = wimpworks.HildonMainScreenLayout(offset = 0.8, container = self)
- layout.add_button('Retrieve', "Get contacts' missing info")
- layout.add_button('Refresh', "Update contacts' info")
+ layout.add_button(_('Retrieve'), _("Get contacts' missing info"))
+ layout.add_button(_('Refresh'), _("Update contacts' info"))
- self.add_menu_action("Accounts")
+ self.add_menu_action(_("Accounts"))
self.menu.show_all()
# -----------------------------------------------------------------------
def do_accounts(self, widget = None):
- dialog = gtk.Dialog('Accounts', self.main_window)
- dialog.add_button('Save', gtk.RESPONSE_OK)
+ dialog = gtk.Dialog(_('Accounts'), self.main_window)
+ dialog.add_button(_('Save'), gtk.RESPONSE_OK)
#pa = hildon.PannableArea()
#dialog.vbox.add(pa)
#pa.add(content)
#pa.set_size_request(600, 380)
- use_facebook = self.new_checkbox('Use Facebook', content)
+ use_facebook = self.new_checkbox(_('Use Facebook'), content)
use_facebook.set_active(self.get_use_facebook())
indent = self.new_indent(content)
- self.link_control(use_facebook, gtk.Label('Note: authentication via web page'), indent)
+ self.link_control(use_facebook, gtk.Label(_('Note: authentication via web page')), indent)
- fb_empty = self.link_control(use_facebook, self.new_checkbox('Create birthday-only contacts'), indent)
+ fb_empty = self.link_control(use_facebook, self.new_checkbox(_('Create birthday-only contacts')), indent)
fb_empty.set_active(self.get_create_empty())
- use_twitter = self.new_checkbox('Use Twitter', content)
+ use_twitter = self.new_checkbox(_('Use Twitter'), content)
use_twitter.set_active(self.get_use_twitter())
indent = self.new_indent(content)
- tw_user = self.link_control(use_twitter, self.new_input('Twitter username'), indent)
+ tw_user = self.link_control(use_twitter, self.new_input(_('Twitter username')), indent)
tw_user.set_text(self.get_twitter_credentials()[0])
- tw_pass = self.link_control(use_twitter, self.new_input('Twitter password', password = True), indent)
+ tw_pass = self.link_control(use_twitter, self.new_input(_('Twitter password'), password = True), indent)
tw_pass.set_text(self.get_twitter_credentials()[1])
dialog.show_all()
except urllib2.HTTPError, e:
traceback.print_exc()
if e.code == 401:
- gobject.idle_add(self.report_error, 'Authentication problem. Check credentials.', True)
+ gobject.idle_add(self.report_error, _('Authentication problem. Check credentials.'), True)
else:
- gobject.idle_add(self.report_error, 'Network connection error. Check connectivity.')
+ gobject.idle_add(self.report_error, _('Network connection error. Check connectivity.'))
except urllib2.URLError, e:
traceback.print_exc()
- gobject.idle_add(self.report_error, 'Network connection error. Check connectivity.')
+ gobject.idle_add(self.report_error, _('Network connection error. Check connectivity.'))
except Exception, e:
traceback.print_exc()
- gobject.idle_add(self.report_error, 'Something went wrong: ' + e.message)
+ gobject.idle_add(self.report_error, _('Something went wrong: ') + e.message)
# -----------------------------------------------------------------------
def open_summary(self, fb2c):
gobject.idle_add(self.main_window.set_property, 'sensitive', True)
- dialog = gtk.Dialog('Summary', self.main_window)
- dialog.add_button('Done', gtk.RESPONSE_OK)
+ dialog = gtk.Dialog(_('Summary'), self.main_window)
+ dialog.add_button(_('Done'), gtk.RESPONSE_OK)
button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL,
- title = 'Updated %d contacts' % (len(fb2c.updated)))
+ title = _('Updated %d contacts') % (len(fb2c.updated)))
button.connect('clicked', self.show_contacts, fb2c, fb2c.updated)
button.set_property('sensitive', len(fb2c.updated) > 0)
dialog.vbox.add(button)
button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL,
- title = 'Matched %d contacts' % (len(fb2c.matched)))
+ title = _('Matched %d contacts') % (len(fb2c.matched)))
button.connect('clicked', self.show_contacts, fb2c, fb2c.matched)
button.set_property('sensitive', len(fb2c.matched) > 0)
dialog.vbox.add(button)
button = hildon.Button(gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL,
- title = '%d contacts unmatched' % (len(fb2c.unmatched)))
+ title = _('%d contacts unmatched') % (len(fb2c.unmatched)))
button.connect('clicked', self.show_contacts, fb2c, fb2c.unmatched)
button.set_property('sensitive', len(fb2c.unmatched) > 0)
dialog.vbox.add(button)
def show_contacts(self, widget, fb2c, contacts):
view = contactview.ContactView(contacts)
- dialog = gtk.Dialog('Contacts', self.main_window)
+ dialog = gtk.Dialog(_('Contacts'), self.main_window)
view.connect('contact-activated', self.map_contact, fb2c)
dialog.vbox.add(view)
dialog.show_all()
view = mapcontact.MapContact(fb2c.friends, contact)
dialog = gtk.Dialog(contact.get_name(), self.main_window)
- dialog.add_button('Update', gtk.RESPONSE_OK)
+ dialog.add_button(_('Update'), gtk.RESPONSE_OK)
dialog.vbox.add(view)
dialog.show_all()
friend = view.get_selected_friend()
if friend:
if 'contact' in friend and friend['contact'] == contact:
- hildon.hildon_banner_show_information(self.main_window, '', "Removing existing mappings is not yet supported")
+ hildon.hildon_banner_show_information(self.main_window, '', _("Removing existing mappings is not yet supported"))
elif view.contact_mapped:
- hildon.hildon_banner_show_information(self.main_window, '', "Changing existing mappings is not yet supported")
+ hildon.hildon_banner_show_information(self.main_window, '', _("Changing existing mappings is not yet supported"))
else:
if fb2c.update_contact(contact, friend, False):
fb2c.addresses.commit_contact(contact)
# -----------------------------------------------------------------------
def need_auth(self, main = False):
if main:
- hildon.hildon_banner_show_information(self.main_window, '', "Need to authenticate with Facebook")
+ hildon.hildon_banner_show_information(self.main_window, '', _("Need to authenticate with Facebook"))
else:
gobject.idle_add(self.need_auth, True)
# -----------------------------------------------------------------------
def block_for_auth(self, main = False, lock = None):
if main:
- note = gtk.Dialog('Facebook authorisation', self.main_window)
- note.add_button("Validate", gtk.RESPONSE_OK)
- note.vbox.add(gtk.Label("\nPress 'Validate' once Facebook has\nbeen authenticated in web browser.\n"))
+ note = gtk.Dialog(_('Facebook authorisation'), self.main_window)
+ note.add_button(_("Validate"), gtk.RESPONSE_OK)
+ note.vbox.add(gtk.Label(_("\nPress 'Validate' once Facebook has\nbeen authenticated in web browser.\n")))
note.show_all()
result = note.run()
if main:
if i == 0:
self.progressbar = gtk.ProgressBar()
- self.progressnote = gtk.Dialog("Fetching friends' info", self.main_window)
+ self.progressnote = gtk.Dialog(_("Fetching friends' info"), self.main_window)
self.progressnote.vbox.add(self.progressbar)
hildon.hildon_gtk_window_set_progress_indicator(self.progressnote, 1)
elif i < j:
if i == 1:
- self.progressnote.set_title("Updating contacts")
+ self.progressnote.set_title(_("Updating contacts"))
hildon.hildon_gtk_window_set_progress_indicator(self.progressnote, 0)
self.progressbar.set_fraction(float(i) / float(j))