i18n
- gettext support added in frontends - first draft of frontends french translation
This commit is contained in:
parent
4a293cdaa1
commit
e3ebafd8f3
1 changed files with 1701 additions and 196 deletions
|
|
@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
|
||||
from quick_frontend.quick_chat_list import QuickChatList
|
||||
from quick_frontend.quick_app import QuickApp
|
||||
from quick_frontend.quick_contact_list import QuickContactList
|
||||
from quick_frontend.quick_contact_management import QuickContactManagement
|
||||
import wx
|
||||
from chat import Chat
|
||||
from param import Param
|
||||
|
|
@ -32,10 +36,6 @@ import os.path
|
|||
import pdb
|
||||
from tools.jid import JID
|
||||
from logging import debug, info, error
|
||||
from quick_frontend.quick_chat_list import QuickChatList
|
||||
from quick_frontend.quick_contact_list import QuickContactList
|
||||
from quick_frontend.quick_app import QuickApp
|
||||
from quick_frontend.quick_contact_management import QuickContactManagement
|
||||
from cgi import escape
|
||||
import sys
|
||||
|
||||
|
|
@ -52,11 +52,11 @@ idREMOVE_CONTACT,\
|
|||
idSHOW_PROFILE,\
|
||||
idFIND_GATEWAYS = range(8)
|
||||
const_DEFAULT_GROUP = "Unclassed"
|
||||
const_STATUS = [("", "Online", None),
|
||||
("chat", "Free for chat", "green"),
|
||||
("away", "AFK", "brown"),
|
||||
("dnd", "DND", "red"),
|
||||
("xa", "Away", "red")]
|
||||
const_STATUS = [("", _("Online"), None),
|
||||
("chat", _("Free for chat"), "green"),
|
||||
("away", _("AFK"), "brown"),
|
||||
("dnd", _("DND"), "red"),
|
||||
("xa", _("Away"), "red")]
|
||||
|
||||
class ChatList(QuickChatList):
|
||||
"""This class manage the list of chat windows"""
|
||||
|
|
@ -90,7 +90,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
|||
return result
|
||||
|
||||
def replace(self, jid):
|
||||
debug("update %s" % jid)
|
||||
debug(_("update %s") % jid)
|
||||
if not self.__find_idx(jid):
|
||||
self.add(jid)
|
||||
else:
|
||||
|
|
@ -155,7 +155,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
|||
|
||||
def add(self, jid):
|
||||
"""add a contact to the list"""
|
||||
debug ("adding %s",jid)
|
||||
debug (_("adding %s"),jid)
|
||||
groups = self.CM.getAttr(jid, 'groups')
|
||||
if not groups:
|
||||
idx = self.Append(self.__presentItem(jid), jid)
|
||||
|
|
@ -174,7 +174,7 @@ class ContactList(wx.SimpleHtmlListBox, QuickContactList):
|
|||
|
||||
def remove(self, jid):
|
||||
"""remove a contact from the list"""
|
||||
debug ("removing %s",jid)
|
||||
debug (_("removing %s"),jid)
|
||||
list_idx = self.__find_idx(jid)
|
||||
list_idx.reverse() #we me make some deletions, we have to reverse the order
|
||||
for i in list_idx:
|
||||
|
|
@ -254,7 +254,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
#tray icon
|
||||
ticon = wx.Icon(IMAGE_DIR+'/crystal/tray_icon.xpm', wx.BITMAP_TYPE_XPM)
|
||||
self.tray_icon = wx.TaskBarIcon()
|
||||
self.tray_icon.SetIcon(ticon, "Wix jabber client")
|
||||
self.tray_icon.SetIcon(ticon, _("Wix jabber client"))
|
||||
wx.EVT_TASKBAR_LEFT_UP(self.tray_icon, self.onTrayClick)
|
||||
|
||||
|
||||
|
|
@ -283,24 +283,24 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
self.bridge.connect(profile_key)
|
||||
|
||||
def createMenus(self):
|
||||
info("Creating menus")
|
||||
info(_("Creating menus"))
|
||||
connectMenu = wx.Menu()
|
||||
connectMenu.Append(idCONNECT, "&Connect CTRL-c"," Connect to the server")
|
||||
connectMenu.Append(idDISCONNECT, "&Disconnect CTRL-d"," Disconnect from the server")
|
||||
connectMenu.Append(idPARAM,"&Parameters"," Configure the program")
|
||||
connectMenu.Append(idCONNECT, _("&Connect CTRL-c"),_(" Connect to the server"))
|
||||
connectMenu.Append(idDISCONNECT, _("&Disconnect CTRL-d"),_(" Disconnect from the server"))
|
||||
connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program"))
|
||||
connectMenu.AppendSeparator()
|
||||
connectMenu.Append(idEXIT,"E&xit"," Terminate the program")
|
||||
connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program"))
|
||||
contactMenu = wx.Menu()
|
||||
contactMenu.Append(idADD_CONTACT, "&Add contact"," Add a contact to your list")
|
||||
contactMenu.Append(idREMOVE_CONTACT, "&Remove contact"," Remove the selected contact from your list")
|
||||
contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list"))
|
||||
contactMenu.Append(idREMOVE_CONTACT, _("&Remove contact"),_(" Remove the selected contact from your list"))
|
||||
contactMenu.AppendSeparator()
|
||||
contactMenu.Append(idSHOW_PROFILE, "&Show profile", " Show contact's profile")
|
||||
contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile"))
|
||||
communicationMenu = wx.Menu()
|
||||
communicationMenu.Append(idFIND_GATEWAYS, "&Find Gateways"," Find gateways to legacy IM")
|
||||
communicationMenu.Append(idFIND_GATEWAYS, _("&Find Gateways"),_(" Find gateways to legacy IM"))
|
||||
self.menuBar = wx.MenuBar()
|
||||
self.menuBar.Append(connectMenu,"&General")
|
||||
self.menuBar.Append(contactMenu,"&Contacts")
|
||||
self.menuBar.Append(communicationMenu,"&Communication")
|
||||
self.menuBar.Append(connectMenu,_("&General"))
|
||||
self.menuBar.Append(contactMenu,_("&Contacts"))
|
||||
self.menuBar.Append(communicationMenu,_("&Communication"))
|
||||
self.SetMenuBar(self.menuBar)
|
||||
|
||||
#events
|
||||
|
|
@ -339,7 +339,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
flags = wx.YES_NO | wx.ICON_QUESTION
|
||||
else:
|
||||
flags = wx.OK | wx.ICON_INFORMATION
|
||||
error('unmanaged dialog type: %s', type)
|
||||
error(_('unmanaged dialog type: %s'), type)
|
||||
dlg = wx.MessageDialog(self, message, title, flags)
|
||||
answer = dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
|
@ -357,21 +357,21 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
|
||||
def askConfirmation(self, type, id, data):
|
||||
#TODO: refactor this in QuickApp
|
||||
debug ("Confirmation asked")
|
||||
debug (_("Confirmation asked"))
|
||||
answer_data={}
|
||||
if type == "FILE_TRANSFERT":
|
||||
debug ("File transfert confirmation asked")
|
||||
dlg = wx.MessageDialog(self, "The contact %s wants to send you the file %s\nDo you accept ?" % (data["from"], data["filename"]),
|
||||
'File Request',
|
||||
debug (_("File transfert confirmation asked"))
|
||||
dlg = wx.MessageDialog(self, _("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]},
|
||||
_('File Request'),
|
||||
wx.YES_NO | wx.ICON_QUESTION
|
||||
)
|
||||
answer=dlg.ShowModal()
|
||||
if answer==wx.ID_YES:
|
||||
filename = wx.FileSelector("Where do you want to save the file ?", flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
|
||||
filename = wx.FileSelector(_("Where do you want to save the file ?"), flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
|
||||
if filename:
|
||||
answer_data["dest_path"] = filename
|
||||
self.bridge.confirmationAnswer(id, True, answer_data)
|
||||
self.waitProgress(id, "File Transfer", "Copying %s" % os.path.basename(filename))
|
||||
self.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename))
|
||||
else:
|
||||
answer = wx.ID_NO
|
||||
if answer==wx.ID_NO:
|
||||
|
|
@ -380,9 +380,9 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
dlg.Destroy()
|
||||
|
||||
elif type == "YES/NO":
|
||||
debug ("Yes/No confirmation asked")
|
||||
debug (_("Yes/No confirmation asked"))
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Confirmation',
|
||||
_('Confirmation'),
|
||||
wx.YES_NO | wx.ICON_QUESTION
|
||||
)
|
||||
answer=dlg.ShowModal()
|
||||
|
|
@ -394,16 +394,16 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
dlg.Destroy()
|
||||
|
||||
def actionResult(self, type, id, data):
|
||||
debug ("actionResult: type = [%s] id = [%s] data = [%s]" % (type, id, data))
|
||||
debug (_("actionResult: type = [%(type)s] id = [%(id)s] data = [%(data)s]") % {'type':type, 'id':id, 'data':data})
|
||||
if not id in self.current_action_ids:
|
||||
debug ('unknown id, ignoring')
|
||||
debug (_('unknown id, ignoring'))
|
||||
return
|
||||
if type == "SUPPRESS":
|
||||
self.current_action_ids.remove(id)
|
||||
elif type == "SUCCESS":
|
||||
self.current_action_ids.remove(id)
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Success',
|
||||
_('Success'),
|
||||
wx.OK | wx.ICON_INFORMATION
|
||||
)
|
||||
dlg.ShowModal()
|
||||
|
|
@ -411,15 +411,15 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
elif type == "ERROR":
|
||||
self.current_action_ids.remove(id)
|
||||
dlg = wx.MessageDialog(self, data["message"],
|
||||
'Error',
|
||||
_('Error'),
|
||||
wx.OK | wx.ICON_ERROR
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
elif type == "FORM":
|
||||
self.current_action_ids.remove(id)
|
||||
debug ("Form received")
|
||||
form=Form(self, title='Registration', target = data['target'], type = data['type'], xml_data = data['xml'])
|
||||
debug (_("Form received"))
|
||||
form=Form(self, title=_('Registration'), target = data['target'], type = data['type'], xml_data = data['xml'])
|
||||
elif type == "RESULT":
|
||||
self.current_action_ids.remove(id)
|
||||
if self.current_action_ids_cb.has_key(id):
|
||||
|
|
@ -433,7 +433,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
del self.current_action_ids_cb[id]
|
||||
callback(data)
|
||||
else:
|
||||
error ("FIXME FIXME FIXME: type [%s] not implemented" % type)
|
||||
error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
|
@ -465,7 +465,7 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
### events ###
|
||||
|
||||
def onContactActivated(self, jid):
|
||||
debug ("onContactActivated: %s", jid)
|
||||
debug (_("onContactActivated: %s"), jid)
|
||||
if self.chat_wins[jid.short].IsShown():
|
||||
self.chat_wins[jid.short].Hide()
|
||||
else:
|
||||
|
|
@ -483,61 +483,61 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
self.bridge.setPresence(show=show, statuses={'default':status}) #FIXME: manage multilingual statuses
|
||||
|
||||
def onStatusChange(self, e):
|
||||
debug("Status change request")
|
||||
debug(_("Status change request"))
|
||||
self.__updateStatus()
|
||||
|
||||
def onParam(self, e):
|
||||
debug("Param request")
|
||||
debug(_("Param request"))
|
||||
param=Param(self)
|
||||
|
||||
def onExit(self, e):
|
||||
self.Close()
|
||||
|
||||
def onAddContact(self, e):
|
||||
debug("Add contact request")
|
||||
debug(_("Add contact request"))
|
||||
dlg = wx.TextEntryDialog(
|
||||
self, 'Please enter new contact JID',
|
||||
'Adding a contact', 'name@server.tld')
|
||||
self, _('Please enter new contact JID'),
|
||||
_('Adding a contact'), _('name@server.tld'))
|
||||
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
jid=JID(dlg.GetValue())
|
||||
if jid.is_valid():
|
||||
self.bridge.addContact(jid.short)
|
||||
else:
|
||||
error ("'%s' is an invalid JID !", jid)
|
||||
error (_("'%s' is an invalid JID !"), jid)
|
||||
#TODO: notice the user
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
def onRemoveContact(self, e):
|
||||
debug("Remove contact request")
|
||||
debug(_("Remove contact request"))
|
||||
target = self.contactList.getSelection()
|
||||
if not target:
|
||||
dlg = wx.MessageDialog(self, "You haven't selected any contact !",
|
||||
'Error',
|
||||
dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
|
||||
_('Error'),
|
||||
wx.OK | wx.ICON_ERROR
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
return
|
||||
|
||||
dlg = wx.MessageDialog(self, "Are you sure you want to delete %s from your roster list ?" % target.short,
|
||||
'Contact suppression',
|
||||
dlg = wx.MessageDialog(self, _("Are you sure you want to delete %s from your roster list ?") % target.short,
|
||||
_('Contact suppression'),
|
||||
wx.YES_NO | wx.ICON_QUESTION
|
||||
)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
info("Unsubscribing %s presence", target.short)
|
||||
info(_("Unsubscribing %s presence"), target.short)
|
||||
self.bridge.delContact(target.short)
|
||||
|
||||
dlg.Destroy()
|
||||
|
||||
def onShowProfile(self, e):
|
||||
debug("Show contact's profile request")
|
||||
debug(_("Show contact's profile request"))
|
||||
target = self.contactList.getSelection()
|
||||
if not target:
|
||||
dlg = wx.MessageDialog(self, "You haven't selected any contact !",
|
||||
'Error',
|
||||
dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
|
||||
_('Error'),
|
||||
wx.OK | wx.ICON_ERROR
|
||||
)
|
||||
dlg.ShowModal()
|
||||
|
|
@ -549,12 +549,12 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
|
||||
def onProfileReceived(self, data):
|
||||
"""Called when a profile is received"""
|
||||
debug ('Profile received: [%s]' % data)
|
||||
debug (_('Profile received: [%s]') % data)
|
||||
profile=Profile(self, data)
|
||||
|
||||
|
||||
def onFindGateways(self, e):
|
||||
debug("Find Gateways request")
|
||||
debug(_("Find Gateways request"))
|
||||
id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain)
|
||||
self.current_action_ids.add(id)
|
||||
self.current_action_ids_cb[id] = self.onGatewaysFound
|
||||
|
|
@ -566,11 +566,11 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
gatewayManager = GatewaysManager(self, data, server=target)
|
||||
|
||||
def onClose(self, e):
|
||||
info("Exiting...")
|
||||
info(_("Exiting..."))
|
||||
e.Skip()
|
||||
|
||||
def onTrayClick(self, e):
|
||||
debug("Tray Click")
|
||||
debug(_("Tray Click"))
|
||||
if self.IsShown():
|
||||
self.Hide()
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue