From c7358bdb84ab140dd121c49c3fbf0dfd7caf53f5 Mon Sep 17 00:00:00 2001 From: Gatien Bovyn Date: Thu, 13 Jun 2013 09:59:40 +0200 Subject: [PATCH] function _translate - lighter code replace QtGui.QApplication.translate with _translate --- src/bitmessageqt/__init__.py | 223 ++++++++++++++++++----------------- 1 file changed, 116 insertions(+), 107 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 08e2e93c..459745c7 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -4,6 +4,7 @@ except: pass try: + from PyQt4 import QtCore, QtGui from PyQt4.QtCore import * from PyQt4.QtGui import * except Exception as err: @@ -11,6 +12,14 @@ except Exception as err: print 'Error message:', err sys.exit() + +try: + _encoding = QtGui.QApplication.UnicodeUTF8 + def _translate(context, text): + return QtGui.QApplication.translate(context, text) +except AttributeError: + print 'Error message:', err + withMessagingMenu = False try: from gi.repository import MessagingMenu @@ -57,7 +66,7 @@ class MyForm(QtGui.QMainWindow): status, addressVersionNumber, streamNumber, hash = decodeAddress( addressInKeysFile) if addressVersionNumber == 1: - displayMsg = QtGui.QApplication.translate( + displayMsg = _translate( "MainWindow", "One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer supported. " + "May we delete it now?").arg(addressInKeysFile) reply = QtGui.QMessageBox.question( @@ -125,13 +134,13 @@ class MyForm(QtGui.QMainWindow): # Popup menu for the Inbox tab self.ui.inboxContextMenuToolbar = QtGui.QToolBar() # Actions - self.actionReply = self.ui.inboxContextMenuToolbar.addAction( - "Reply", self.on_action_InboxReply) - self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionReply = self.ui.inboxContextMenuToolbar.addAction(_translate( + "MainWindow", "Reply"), self.on_action_InboxReply) + self.actionAddSenderToAddressBook = self.ui.inboxContextMenuToolbar.addAction(_translate( "MainWindow", "Add sender to your Address Book"), self.on_action_InboxAddSenderToAddressBook) self.actionTrashInboxMessage = self.ui.inboxContextMenuToolbar.addAction( - QtGui.QApplication.translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash) - self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(QtGui.QApplication.translate( + _translate("MainWindow", "Move to Trash"), self.on_action_InboxTrash) + self.actionForceHtml = self.ui.inboxContextMenuToolbar.addAction(_translate( "MainWindow", "View HTML code as formatted text"), self.on_action_InboxMessageForceHtml) self.ui.tableWidgetInbox.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) @@ -148,15 +157,15 @@ class MyForm(QtGui.QMainWindow): # Popup menu for the Your Identities tab self.ui.addressContextMenuToolbar = QtGui.QToolBar() # Actions - self.actionNew = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionNew = self.ui.addressContextMenuToolbar.addAction(_translate( "MainWindow", "New"), self.on_action_YourIdentitiesNew) - self.actionEnable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionEnable = self.ui.addressContextMenuToolbar.addAction(_translate( "MainWindow", "Enable"), self.on_action_YourIdentitiesEnable) - self.actionDisable = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionDisable = self.ui.addressContextMenuToolbar.addAction(_translate( "MainWindow", "Disable"), self.on_action_YourIdentitiesDisable) - self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionClipboard = self.ui.addressContextMenuToolbar.addAction(_translate( "MainWindow", "Copy address to clipboard"), self.on_action_YourIdentitiesClipboard) - self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionSpecialAddressBehavior = self.ui.addressContextMenuToolbar.addAction(_translate( "MainWindow", "Special address behavior..."), self.on_action_SpecialAddressBehaviorDialog) self.ui.tableWidgetYourIdentities.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) @@ -174,13 +183,13 @@ class MyForm(QtGui.QMainWindow): # Popup menu for the Address Book page self.ui.addressBookContextMenuToolbar = QtGui.QToolBar() # Actions - self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionAddressBookSend = self.ui.addressBookContextMenuToolbar.addAction(_translate( "MainWindow", "Send message to this address"), self.on_action_AddressBookSend) - self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionAddressBookClipboard = self.ui.addressBookContextMenuToolbar.addAction(_translate( "MainWindow", "Copy address to clipboard"), self.on_action_AddressBookClipboard) - self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionAddressBookNew = self.ui.addressBookContextMenuToolbar.addAction(_translate( "MainWindow", "Add New Address"), self.on_action_AddressBookNew) - self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionAddressBookDelete = self.ui.addressBookContextMenuToolbar.addAction(_translate( "MainWindow", "Delete"), self.on_action_AddressBookDelete) self.ui.tableWidgetAddressBook.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) @@ -197,15 +206,15 @@ class MyForm(QtGui.QMainWindow): self.ui.subscriptionsContextMenuToolbar = QtGui.QToolBar() # Actions self.actionsubscriptionsNew = self.ui.subscriptionsContextMenuToolbar.addAction( - QtGui.QApplication.translate("MainWindow", "New"), self.on_action_SubscriptionsNew) + _translate("MainWindow", "New"), self.on_action_SubscriptionsNew) self.actionsubscriptionsDelete = self.ui.subscriptionsContextMenuToolbar.addAction( - QtGui.QApplication.translate("MainWindow", "Delete"), self.on_action_SubscriptionsDelete) + _translate("MainWindow", "Delete"), self.on_action_SubscriptionsDelete) self.actionsubscriptionsClipboard = self.ui.subscriptionsContextMenuToolbar.addAction( - QtGui.QApplication.translate("MainWindow", "Copy address to clipboard"), self.on_action_SubscriptionsClipboard) + _translate("MainWindow", "Copy address to clipboard"), self.on_action_SubscriptionsClipboard) self.actionsubscriptionsEnable = self.ui.subscriptionsContextMenuToolbar.addAction( - QtGui.QApplication.translate("MainWindow", "Enable"), self.on_action_SubscriptionsEnable) + _translate("MainWindow", "Enable"), self.on_action_SubscriptionsEnable) self.actionsubscriptionsDisable = self.ui.subscriptionsContextMenuToolbar.addAction( - QtGui.QApplication.translate("MainWindow", "Disable"), self.on_action_SubscriptionsDisable) + _translate("MainWindow", "Disable"), self.on_action_SubscriptionsDisable) self.ui.tableWidgetSubscriptions.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) self.connect(self.ui.tableWidgetSubscriptions, QtCore.SIGNAL( @@ -222,11 +231,11 @@ class MyForm(QtGui.QMainWindow): # Popup menu for the Sent page self.ui.sentContextMenuToolbar = QtGui.QToolBar() # Actions - self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionTrashSentMessage = self.ui.sentContextMenuToolbar.addAction(_translate( "MainWindow", "Move to Trash"), self.on_action_SentTrash) - self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionSentClipboard = self.ui.sentContextMenuToolbar.addAction(_translate( "MainWindow", "Copy destination address to clipboard"), self.on_action_SentClipboard) - self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionForceSend = self.ui.sentContextMenuToolbar.addAction(_translate( "MainWindow", "Force send"), self.on_action_ForceSend) self.ui.tableWidgetSent.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) @@ -239,15 +248,15 @@ class MyForm(QtGui.QMainWindow): # Popup menu for the Blacklist page self.ui.blacklistContextMenuToolbar = QtGui.QToolBar() # Actions - self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionBlacklistNew = self.ui.blacklistContextMenuToolbar.addAction(_translate( "MainWindow", "Add new entry"), self.on_action_BlacklistNew) - self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionBlacklistDelete = self.ui.blacklistContextMenuToolbar.addAction(_translate( "MainWindow", "Delete"), self.on_action_BlacklistDelete) - self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionBlacklistClipboard = self.ui.blacklistContextMenuToolbar.addAction(_translate( "MainWindow", "Copy address to clipboard"), self.on_action_BlacklistClipboard) - self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionBlacklistEnable = self.ui.blacklistContextMenuToolbar.addAction(_translate( "MainWindow", "Enable"), self.on_action_BlacklistEnable) - self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(QtGui.QApplication.translate( + self.actionBlacklistDisable = self.ui.blacklistContextMenuToolbar.addAction(_translate( "MainWindow", "Disable"), self.on_action_BlacklistDisable) self.ui.tableWidgetBlacklist.setContextMenuPolicy( QtCore.Qt.CustomContextMenu) @@ -449,37 +458,37 @@ class MyForm(QtGui.QMainWindow): QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) self.ui.tableWidgetSent.setItem(0, 2, newItem) if status == 'awaitingpubkey': - statusText = QtGui.QApplication.translate( + statusText = _translate( "MainWindow", "Waiting on their encryption key. Will request it again soon.") elif status == 'doingpowforpubkey': - statusText = QtGui.QApplication.translate( + statusText = _translate( "MainWindow", "Encryption key request queued.") elif status == 'msgqueued': - statusText = QtGui.QApplication.translate( + statusText = _translate( "MainWindow", "Queued.") elif status == 'msgsent': - statusText = QtGui.QApplication.translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg( + statusText = _translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg( unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(lastactiontime)))) elif status == 'doingmsgpow': - statusText = QtGui.QApplication.translate( + statusText = _translate( "MainWindow", "Need to do work to send message. Work is queued.") elif status == 'ackreceived': - statusText = QtGui.QApplication.translate("MainWindow", "Acknowledgement of the message received %1").arg( + statusText = _translate("MainWindow", "Acknowledgement of the message received %1").arg( unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) elif status == 'broadcastqueued': - statusText = QtGui.QApplication.translate( + statusText = _translate( "MainWindow", "Broadcast queued.") elif status == 'broadcastsent': - statusText = QtGui.QApplication.translate("MainWindow", "Broadcast on %1").arg(unicode(strftime( + statusText = _translate("MainWindow", "Broadcast on %1").arg(unicode(strftime( shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) elif status == 'toodifficult': - statusText = QtGui.QApplication.translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg( + statusText = _translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg( unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) elif status == 'forcepow': - statusText = QtGui.QApplication.translate( + statusText = _translate( "MainWindow", "Forced difficulty override. Send should start soon.") else: - statusText = QtGui.QApplication.translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(unicode( + statusText = _translate("MainWindow", "Unknown status: %1 %2").arg(status).arg(unicode( strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(lastactiontime))))) newItem = myTableWidgetItem(statusText) newItem.setToolTip(statusText) @@ -533,7 +542,7 @@ class MyForm(QtGui.QMainWindow): # self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) self.statusbar = self.statusBar() self.statusbar.insertPermanentWidget(0, self.ui.pushButtonStatusIcon) - self.ui.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup on %1").arg( + self.ui.labelStartupTime.setText(_translate("MainWindow", "Since startup on %1").arg( unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time())))))) self.numberOfMessagesProcessed = 0 self.numberOfBroadcastsProcessed = 0 @@ -680,7 +689,7 @@ class MyForm(QtGui.QMainWindow): m = QMenu() - self.actionStatus = QtGui.QAction(QtGui.QApplication.translate( + self.actionStatus = QtGui.QAction(_translate( "MainWindow", "Not Connected"), m, checkable=False) m.addAction(self.actionStatus) @@ -690,7 +699,7 @@ class MyForm(QtGui.QMainWindow): m.addAction(actionSeparator) # show bitmessage - self.actionShow = QtGui.QAction(QtGui.QApplication.translate( + self.actionShow = QtGui.QAction(_translate( "MainWindow", "Show Bitmessage"), m, checkable=True) self.actionShow.setChecked(not shared.config.getboolean( 'bitmessagesettings', 'startintray')) @@ -699,19 +708,19 @@ class MyForm(QtGui.QMainWindow): m.addAction(self.actionShow) # Send - actionSend = QtGui.QAction(QtGui.QApplication.translate( + actionSend = QtGui.QAction(_translate( "MainWindow", "Send"), m, checkable=False) actionSend.triggered.connect(self.appIndicatorSend) m.addAction(actionSend) # Subscribe - actionSubscribe = QtGui.QAction(QtGui.QApplication.translate( + actionSubscribe = QtGui.QAction(_translate( "MainWindow", "Subscribe"), m, checkable=False) actionSubscribe.triggered.connect(self.appIndicatorSubscribe) m.addAction(actionSubscribe) # Address book - actionAddressBook = QtGui.QAction(QtGui.QApplication.translate( + actionAddressBook = QtGui.QAction(_translate( "MainWindow", "Address Book"), m, checkable=False) actionAddressBook.triggered.connect(self.appIndicatorAddressBook) m.addAction(actionAddressBook) @@ -722,7 +731,7 @@ class MyForm(QtGui.QMainWindow): m.addAction(actionSeparator) # Quit - m.addAction(QtGui.QApplication.translate( + m.addAction(_translate( "MainWindow", "Quit"), self.quit) self.tray.setContextMenu(m) @@ -911,24 +920,24 @@ class MyForm(QtGui.QMainWindow): # may manage your keys by editing the keys.dat file stored in # the same directory as this program. It is important that you # back up this file.', QMessageBox.Ok) - reply = QtGui.QMessageBox.information(self, 'keys.dat?', QtGui.QApplication.translate( + reply = QtGui.QMessageBox.information(self, 'keys.dat?', _translate( "MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file."), QMessageBox.Ok) else: - QtGui.QMessageBox.information(self, 'keys.dat?', QtGui.QApplication.translate( + QtGui.QMessageBox.information(self, 'keys.dat?', _translate( "MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file.").arg(shared.appdata), QMessageBox.Ok) elif sys.platform == 'win32' or sys.platform == 'win64': if shared.appdata == '': - reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"), QtGui.QApplication.translate( + reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate( "MainWindow", "You may manage your keys by editing the keys.dat file stored in the same directory as this program. It is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) else: - reply = QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Open keys.dat?"), QtGui.QApplication.translate( + reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate( "MainWindow", "You may manage your keys by editing the keys.dat file stored in\n %1 \nIt is important that you back up this file. Would you like to open the file now? (Be sure to close Bitmessage before making any changes.)").arg(shared.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) if reply == QtGui.QMessageBox.Yes: self.openKeysFile() def click_actionDeleteAllTrashedMessages(self): - if QtGui.QMessageBox.question(self, QtGui.QApplication.translate("MainWindow", "Delete trash?"), QtGui.QApplication.translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: + if QtGui.QMessageBox.question(self, _translate("MainWindow", "Delete trash?"), _translate("MainWindow", "Are you sure you want to delete all trashed messages?"), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.No: return shared.sqlLock.acquire() shared.sqlSubmitQueue.put('deleteandvacuume') @@ -939,7 +948,7 @@ class MyForm(QtGui.QMainWindow): self) if self.regenerateAddressesDialogInstance.exec_(): if self.regenerateAddressesDialogInstance.ui.lineEditPassphrase.text() == "": - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "bad passphrase"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "bad passphrase"), _translate( "MainWindow", "You must type your passphrase. If you don\'t have one then this is not the form for you.")) else: streamNumberForAddress = int( @@ -984,17 +993,17 @@ class MyForm(QtGui.QMainWindow): def incrementNumberOfMessagesProcessed(self): self.numberOfMessagesProcessed += 1 - self.ui.labelMessageCount.setText(QtGui.QApplication.translate( + self.ui.labelMessageCount.setText(_translate( "MainWindow", "Processed %1 person-to-person messages.").arg(str(self.numberOfMessagesProcessed))) def incrementNumberOfBroadcastsProcessed(self): self.numberOfBroadcastsProcessed += 1 - self.ui.labelBroadcastCount.setText(QtGui.QApplication.translate( + self.ui.labelBroadcastCount.setText(_translate( "MainWindow", "Processed %1 broadcast messages.").arg(str(self.numberOfBroadcastsProcessed))) def incrementNumberOfPubkeysProcessed(self): self.numberOfPubkeysProcessed += 1 - self.ui.labelPubkeyCount.setText(QtGui.QApplication.translate( + self.ui.labelPubkeyCount.setText(_translate( "MainWindow", "Processed %1 public keys.").arg(str(self.numberOfPubkeysProcessed))) def updateNetworkStatusTab(self): @@ -1038,7 +1047,7 @@ class MyForm(QtGui.QMainWindow): newItem.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled ) self.ui.tableWidgetConnectionCount.setItem(0,1,newItem) totalNumberOfConnectionsFromAllStreams += connectionCount""" - self.ui.labelTotalConnections.setText(QtGui.QApplication.translate( + self.ui.labelTotalConnections.setText(_translate( "MainWindow", "Total Connections: %1").arg(str(len(shared.connectedHostsList)))) if len(shared.connectedHostsList) > 0 and shared.statusIconColor == 'red': # FYI: The 'singlelistener' thread sets the icon color to green when it receives an incoming connection, meaning that the user's firewall is configured correctly. self.setStatusIcon('yellow') @@ -1057,12 +1066,12 @@ class MyForm(QtGui.QMainWindow): shared.statusIconColor = 'red' # if the connection is lost then show a notification if self.connected: - self.notifierShow('Bitmessage', QtGui.QApplication.translate( + self.notifierShow('Bitmessage', _translate( "MainWindow", "Connection lost")) self.connected = False if self.actionStatus is not None: - self.actionStatus.setText(QtGui.QApplication.translate( + self.actionStatus.setText(_translate( "MainWindow", "Not Connected")) self.tray.setIcon(QtGui.QIcon( ":/newPrefix/images/can-icon-24px-red.png")) @@ -1074,12 +1083,12 @@ class MyForm(QtGui.QMainWindow): shared.statusIconColor = 'yellow' # if a new connection has been established then show a notification if not self.connected: - self.notifierShow('Bitmessage', QtGui.QApplication.translate( + self.notifierShow('Bitmessage', _translate( "MainWindow", "Connected")) self.connected = True if self.actionStatus is not None: - self.actionStatus.setText(QtGui.QApplication.translate( + self.actionStatus.setText(_translate( "MainWindow", "Connected")) self.tray.setIcon(QtGui.QIcon( ":/newPrefix/images/can-icon-24px-yellow.png")) @@ -1090,12 +1099,12 @@ class MyForm(QtGui.QMainWindow): QIcon(":/newPrefix/images/greenicon.png")) shared.statusIconColor = 'green' if not self.connected: - self.notifierShow('Bitmessage', QtGui.QApplication.translate( + self.notifierShow('Bitmessage', _translate( "MainWindow", "Connected")) self.connected = True if self.actionStatus is not None: - self.actionStatus.setText(QtGui.QApplication.translate( + self.actionStatus.setText(_translate( "MainWindow", "Connected")) self.tray.setIcon(QtGui.QIcon( ":/newPrefix/images/can-icon-24px-green.png")) @@ -1135,7 +1144,7 @@ class MyForm(QtGui.QMainWindow): def removeInboxRowByMsgid(self, msgid): # msgid and inventoryHash are the same thing for i in range(self.ui.tableWidgetInbox.rowCount()): if msgid == str(self.ui.tableWidgetInbox.item(i, 3).data(Qt.UserRole).toPyObject()): - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Message trashed")) self.ui.tableWidgetInbox.removeRow(i) break @@ -1269,28 +1278,28 @@ class MyForm(QtGui.QMainWindow): print 'Error: Could not decode', toAddress, ':', status shared.printLock.release() if status == 'missingbm': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: Bitmessage addresses start with BM- Please check %1").arg(toAddress)) elif status == 'checksumfailed': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: The address %1 is not typed or copied correctly. Please check it.").arg(toAddress)) elif status == 'invalidcharacters': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: The address %1 contains invalid characters. Please check it.").arg(toAddress)) elif status == 'versiontoohigh': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: The address version in %1 is too high. Either you need to upgrade your Bitmessage software or your acquaintance is being clever.").arg(toAddress)) elif status == 'ripetooshort': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: Some data encoded in the address %1 is too short. There might be something wrong with the software of your acquaintance.").arg(toAddress)) elif status == 'ripetoolong': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: Some data encoded in the address %1 is too long. There might be something wrong with the software of your acquaintance.").arg(toAddress)) else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: Something is wrong with the address %1.").arg(toAddress)) elif fromAddress == '': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.")) else: toAddress = addBMIfNotPresent(toAddress) @@ -1299,22 +1308,22 @@ class MyForm(QtGui.QMainWindow): # The toAddress is one owned by me. We cannot send # messages to ourselves without significant changes # to the codebase. - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Sending to your address"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "Sending to your address"), _translate( "MainWindow", "Error: One of the addresses to which you are sending a message, %1, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.").arg(toAddress)) continue except: pass if addressVersionNumber > 3 or addressVersionNumber <= 1: - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Address version number"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "Address version number"), _translate( "MainWindow", "Concerning the address %1, Bitmessage cannot understand address version numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(addressVersionNumber))) continue if streamNumber > 1 or streamNumber == 0: - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Stream number"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "Stream number"), _translate( "MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber))) continue self.statusBar().showMessage('') if shared.statusIconColor == 'red': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Warning: You are currently not connected. Bitmessage will do the work necessary to send the message but it won\'t send until you connect.")) ackdata = OpenSSL.rand(32) shared.sqlLock.acquire() @@ -1351,11 +1360,11 @@ class MyForm(QtGui.QMainWindow): self.ui.tabWidget.setCurrentIndex(2) self.ui.tableWidgetSent.setCurrentCell(0, 0) else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Your \'To\' field is empty.")) else: # User selected 'Broadcast' if fromAddress == '': - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: You must specify a From address. If you don\'t have one, go to the \'Your Identities\' tab.")) else: self.statusBar().showMessage('') @@ -1428,7 +1437,7 @@ class MyForm(QtGui.QMainWindow): time.sleep(0.1) self.statusBar().showMessage('') time.sleep(0.1) - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Right click one or more entries in your address book and select \'Send message to this address\'.")) def redrawLabelFrom(self, index): @@ -1621,10 +1630,10 @@ class MyForm(QtGui.QMainWindow): self.rerenderInboxFromLabels() self.rerenderSentToLabels() else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "The address you entered was invalid. Ignoring it.")) def click_pushButtonAddSubscription(self): @@ -1667,10 +1676,10 @@ class MyForm(QtGui.QMainWindow): self.rerenderInboxFromLabels() shared.reloadBroadcastSendersForWhichImWatching() else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: You cannot add the same address to your subsciptions twice. Perhaps rename the existing one if you want.")) else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "The address you entered was invalid. Ignoring it.")) def loadBlackWhiteList(self): @@ -1726,13 +1735,13 @@ class MyForm(QtGui.QMainWindow): shared.config.set('bitmessagesettings', 'startintray', str( self.settingsDialogInstance.ui.checkBoxStartInTray.isChecked())) if int(shared.config.get('bitmessagesettings', 'port')) != int(self.settingsDialogInstance.ui.lineEditTCPPort.text()): - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate( "MainWindow", "You must restart Bitmessage for the port number change to take effect.")) shared.config.set('bitmessagesettings', 'port', str( self.settingsDialogInstance.ui.lineEditTCPPort.text())) if shared.config.get('bitmessagesettings', 'socksproxytype') == 'none' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText())[0:5] == 'SOCKS': if shared.statusIconColor != 'red': - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Restart"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "Restart"), _translate( "MainWindow", "Bitmessage will use your proxy from now on but you may want to manually restart Bitmessage now to close existing connections.")) if shared.config.get('bitmessagesettings', 'socksproxytype')[0:5] == 'SOCKS' and str(self.settingsDialogInstance.ui.comboBoxProxyType.currentText()) == 'none': self.statusBar().showMessage('') @@ -1886,10 +1895,10 @@ class MyForm(QtGui.QMainWindow): shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: You cannot add the same address to your list twice. Perhaps rename the existing one if you want.")) else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "The address you entered was invalid. Ignoring it.")) def on_action_SpecialAddressBehaviorDialog(self): @@ -1942,11 +1951,11 @@ class MyForm(QtGui.QMainWindow): self.dialog.ui.newaddresslabel.text().toUtf8()), 1, "", self.dialog.ui.checkBoxEighteenByteRipe.isChecked())) else: if self.dialog.ui.lineEditPassphrase.text() != self.dialog.ui.lineEditPassphraseAgain.text(): - QMessageBox.about(self, QtGui.QApplication.translate("MainWindow", "Passphrase mismatch"), QtGui.QApplication.translate( + QMessageBox.about(self, _translate("MainWindow", "Passphrase mismatch"), _translate( "MainWindow", "The passphrase you entered twice doesn\'t match. Try again.")) elif self.dialog.ui.lineEditPassphrase.text() == "": - QMessageBox.about(self, QtGui.QApplication.translate( - "MainWindow", "Choose a passphrase"), QtGui.QApplication.translate("MainWindow", "You really do need a passphrase.")) + QMessageBox.about(self, _translate( + "MainWindow", "Choose a passphrase"), _translate("MainWindow", "You really do need a passphrase.")) else: streamNumberForAddress = 1 # this will eventually have to be replaced by logic to determine the most available stream number. # self.addressGenerator = addressGenerator() @@ -1973,7 +1982,7 @@ class MyForm(QtGui.QMainWindow): # unregister the messaging system if self.mmapp is not None: self.mmapp.unregister() - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "All done. Closing user interface...")) os._exit(0) @@ -2021,11 +2030,11 @@ class MyForm(QtGui.QMainWindow): if toAddressAtCurrentInboxRow == self.str_broadcast_subscribers: self.ui.labelFrom.setText('') elif not shared.config.has_section(toAddressAtCurrentInboxRow): - QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address is gone"), QtGui.QApplication.translate( + QtGui.QMessageBox.information(self, _translate("MainWindow", "Address is gone"), _translate( "MainWindow", "Bitmessage cannot find your address %1. Perhaps you removed it?").arg(toAddressAtCurrentInboxRow), QMessageBox.Ok) self.ui.labelFrom.setText('') elif not shared.config.getboolean(toAddressAtCurrentInboxRow, 'enabled'): - QtGui.QMessageBox.information(self, QtGui.QApplication.translate("MainWindow", "Address disabled"), QtGui.QApplication.translate( + QtGui.QMessageBox.information(self, _translate("MainWindow", "Address disabled"), _translate( "MainWindow", "Error: The address from which you are trying to send is disabled. You\'ll have to enable it on the \'Your Identities\' tab before using it."), QMessageBox.Ok) self.ui.labelFrom.setText('') else: @@ -2077,10 +2086,10 @@ class MyForm(QtGui.QMainWindow): shared.sqlLock.release() self.ui.tabWidget.setCurrentIndex(5) self.ui.tableWidgetAddressBook.setCurrentCell(0, 0) - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Entry added to the Address Book. Edit the label to your liking.")) else: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Error: You cannot add the same address to your address book twice. Try renaming the existing one if you want.")) # Send item on the Inbox tab to trash @@ -2098,7 +2107,7 @@ class MyForm(QtGui.QMainWindow): shared.sqlLock.release() self.ui.textEditInboxMessage.setText("") self.ui.tableWidgetInbox.removeRow(currentRow) - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.")) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('commit') @@ -2123,7 +2132,7 @@ class MyForm(QtGui.QMainWindow): shared.sqlLock.release() self.ui.textEditSentMessage.setPlainText("") self.ui.tableWidgetSent.removeRow(currentRow) - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "Moved items to trash. There is no user interface to view your trash, but it is still on disk if you are desperate to get it back.")) shared.sqlLock.acquire() shared.sqlSubmitQueue.put('commit') @@ -2217,7 +2226,7 @@ class MyForm(QtGui.QMainWindow): self.ui.lineEditTo.setText(str( self.ui.lineEditTo.text()) + '; ' + str(addressAtCurrentRow)) if listOfSelectedRows == {}: - self.statusBar().showMessage(QtGui.QApplication.translate( + self.statusBar().showMessage(_translate( "MainWindow", "No addresses selected.")) else: self.statusBar().showMessage('') @@ -2630,12 +2639,12 @@ class settingsDialog(QtGui.QDialog): self.ui.checkBoxStartOnLogon.setDisabled(True) self.ui.checkBoxMinimizeToTray.setDisabled(True) self.ui.checkBoxShowTrayNotifications.setDisabled(True) - self.ui.labelSettingsNote.setText(QtGui.QApplication.translate( + self.ui.labelSettingsNote.setText(_translate( "MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system.")) elif 'linux' in sys.platform: self.ui.checkBoxStartOnLogon.setDisabled(True) self.ui.checkBoxMinimizeToTray.setDisabled(True) - self.ui.labelSettingsNote.setText(QtGui.QApplication.translate( + self.ui.labelSettingsNote.setText(_translate( "MainWindow", "Options have been disabled because they either aren\'t applicable or because they haven\'t yet been implimented for your operating system.")) # On the Network settings tab: self.ui.lineEditTCPPort.setText(str( @@ -2753,26 +2762,26 @@ class NewSubscriptionDialog(QtGui.QDialog): def subscriptionAddressChanged(self, QString): status, a, b, c = decodeAddress(str(QString)) if status == 'missingbm': - self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( + self.ui.labelSubscriptionAddressCheck.setText(_translate( "MainWindow", "The address should start with ''BM-''")) elif status == 'checksumfailed': - self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( + self.ui.labelSubscriptionAddressCheck.setText(_translate( "MainWindow", "The address is not typed or copied correctly (the checksum failed).")) elif status == 'versiontoohigh': - self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( + self.ui.labelSubscriptionAddressCheck.setText(_translate( "MainWindow", "The version number of this address is higher than this software can support. Please upgrade Bitmessage.")) elif status == 'invalidcharacters': - self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( + self.ui.labelSubscriptionAddressCheck.setText(_translate( "MainWindow", "The address contains invalid characters.")) elif status == 'ripetooshort': - self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( + self.ui.labelSubscriptionAddressCheck.setText(_translate( "MainWindow", "Some data encoded in the address is too short.")) elif status == 'ripetoolong': - self.ui.labelSubscriptionAddressCheck.setText(QtGui.QApplication.translate( + self.ui.labelSubscriptionAddressCheck.setText(_translate( "MainWindow", "Some data encoded in the address is too long.")) elif status == 'success': self.ui.labelSubscriptionAddressCheck.setText( - QtGui.QApplication.translate("MainWindow", "Address is valid.")) + _translate("MainWindow", "Address is valid.")) class NewAddressDialog(QtGui.QDialog): @@ -2803,7 +2812,7 @@ class iconGlossaryDialog(QtGui.QDialog): self.ui = Ui_iconGlossaryDialog() self.ui.setupUi(self) self.parent = parent - self.ui.labelPortNumber.setText(QtGui.QApplication.translate( + self.ui.labelPortNumber.setText(_translate( "MainWindow", "You are using TCP port %1. (This can be changed in the settings).").arg(str(shared.config.getint('bitmessagesettings', 'port')))) QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))