- gettext support added in frontends
- first draft of frontends french translation
This commit is contained in:
Goffi 2010-03-05 20:33:10 +11:00
commit e3ebafd8f3

View file

@ -24,6 +24,9 @@ from tools.jid import JID
from sat_bridge_frontend.DBus import DBusBridgeFrontend
import pdb
import gettext
gettext.install('sat_frontend', "../i18n", unicode=True)
class QuickApp():
"""This class contain the main methods needed for the frontend"""
@ -57,14 +60,14 @@ class QuickApp():
def plug_profile(self, profile_key='@DEFAULT@'):
"""Tell application which profile must be used"""
if self.single_profile and self.profiles:
error('There is already one profile plugged (we are in single profile mode) !')
error(_('There is already one profile plugged (we are in single profile mode) !'))
return
profile = self.bridge.getProfileName(profile_key)
if not profile:
error("The profile asked doesn't exist")
error(_("The profile asked doesn't exist"))
return
if self.profiles.has_key(profile):
warning("The profile is already plugged")
warning(_("The profile is already plugged"))
return
self.profiles[profile]={}
if self.single_profile:
@ -104,7 +107,7 @@ class QuickApp():
def unplug_profile(self, profile):
"""Tell the application to not follow anymore the profile"""
if not profile in self.profiles:
warning ("This profile is not plugged")
warning (_("This profile is not plugged"))
return
self.profiles.remove(profile)
@ -115,14 +118,14 @@ class QuickApp():
"""called when the connection is made"""
if not self.__check_profile(profile):
return
debug("Connected")
debug(_("Connected"))
self.setStatusOnline(True)
def disconnected(self, profile):
"""called when the connection is closed"""
if not self.__check_profile(profile):
return
debug("Disconnected")
debug(_("Disconnected"))
self.CM.clear()
self.contactList.clear_contacts()
self.setStatusOnline(False)
@ -150,9 +153,9 @@ class QuickApp():
if not self.__check_profile(profile):
return
print "check ok"
debug ("presence update for %s (show=%s, statuses=%s)", jabber_id, show, statuses);
debug (_("presence update for %(jid)s (show=%(show)s, statuses=%(statuses)s)") % {'jid':jabber_id, 'show':show, 'statuses':statuses});
from_jid=JID(jabber_id)
debug ("from_jid.short=%s whoami.short=%s", from_jid.short, self.profiles[profile]['whoami'].short)
debug ("from_jid.short=%(from_jid)s whoami.short=%(whoami)s" % {'from_jid':from_jid.short, 'whoami':self.profiles[profile]['whoami'].short})
if from_jid.short==self.profiles[profile]['whoami'].short:
if not type:
@ -171,7 +174,7 @@ class QuickApp():
#FIXME: must be moved in a plugin
if from_jid.short in self.profiles[profile]['watched'] and not from_jid.short in self.profiles[profile]['onlineContact']:
self.showAlert("Watched jid [%s] is connected !" % from_jid.short)
self.showAlert(_("Watched jid [%s] is connected !") % from_jid.short)
self.profiles[profile]['onlineContact'].add(from_jid) #FIXME onlineContact is useless with CM, must be removed
self.CM.add(from_jid)
@ -199,13 +202,13 @@ class QuickApp():
entity = JID(raw_jid)
if type=="subscribed":
# this is a subscription confirmation, we just have to inform user
self.showDialog("The contact %s has accepted your subscription" % entity.short, 'Subscription confirmation')
self.showDialog(_("The contact %s has accepted your subscription") % entity.short, _('Subscription confirmation'))
elif type=="unsubscribed":
# this is a subscription refusal, we just have to inform user
self.showDialog("The contact %s has refused your subscription" % entity.short, 'Subscription refusal', 'error')
self.showDialog(_("The contact %s has refused your subscription") % entity.short, _('Subscription refusal'), 'error')
elif type=="subscribe":
# this is a subscriptionn request, we have to ask for user confirmation
answer = self.showDialog("The contact %s wants to subscribe to your presence.\nDo you accept ?" % entity.short, 'Subscription confirmation', 'yes/no')
answer = self.showDialog(_("The contact %s wants to subscribe to your presence.\nDo you accept ?") % entity.short, _('Subscription confirmation'), 'yes/no')
if answer:
self.bridge.subscription("subscribed", entity.short)
else:
@ -220,9 +223,9 @@ class QuickApp():
def paramUpdate(self, name, value, namespace, profile):
if not self.__check_profile(profile):
return
debug("param update: [%s] %s = %s", namespace, name, value)
debug(_("param update: [%(namespace)s] %(name)s = %(value)s") % {'namespace':namespace, 'name':name, 'value':value})
if (namespace,name) == ("Connection", "JabberID"):
debug ("Changing ID to %s", value)
debug (_("Changing JID to %s"), value)
self.profiles[profile]['whoami']=JID(value)
elif (namespace,name) == ("Misc", "Watched"):
self.profiles[profile]['watched']=value.split()