More fixes for l10n #981

Closed
g1itch wants to merge 5 commits from l10n into v0.6
9 changed files with 249 additions and 119 deletions

View File

@ -9,7 +9,7 @@ except Exception as err:
logger.critical(logmsg, exc_info=True) logger.critical(logmsg, exc_info=True)
sys.exit() sys.exit()
from tr import _translate from tr import _translate, _codec
from addresses import decodeAddress, addBMIfNotPresent from addresses import decodeAddress, addBMIfNotPresent
import shared import shared
from bitmessageui import Ui_MainWindow from bitmessageui import Ui_MainWindow
@ -585,8 +585,10 @@ class MyForm(settingsmixin.SMainWindow):
addressInKeysFile) addressInKeysFile)
if addressVersionNumber == 1: if addressVersionNumber == 1:
displayMsg = _translate( displayMsg = _translate(
"MainWindow", "One of your addresses, %1, is an old version 1 address. Version 1 addresses are no longer supported. " "MainWindow",
+ "May we delete it now?").arg(addressInKeysFile) "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( reply = QtGui.QMessageBox.question(
self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) self, 'Message', displayMsg, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
@ -816,16 +818,17 @@ class MyForm(settingsmixin.SMainWindow):
stylesheet = "" stylesheet = ""
if numberOfHours < 48: if numberOfHours < 48:
self.ui.labelHumanFriendlyTTLDescription.setText( self.ui.labelHumanFriendlyTTLDescription.setText(_translate(
_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfHours) + "MainWindow", "%n hour(s), not recommended for chans",
", " + None, _codec, numberOfHours
_translate("MainWindow", "not recommended for chans", None, QtCore.QCoreApplication.CodecForTr) ))
)
stylesheet = "QLabel { color : red; }" stylesheet = "QLabel { color : red; }"
font.setBold(True) font.setBold(True)
else: else:
numberOfDays = int(round(TTL / (24*60*60))) numberOfDays = int(round(TTL / (24*60*60)))
self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n day(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfDays)) self.ui.labelHumanFriendlyTTLDescription.setText(_translate(
"MainWindow", "%n day(s)", None, _codec, numberOfDays
))
font.setBold(False) font.setBold(False)
self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet) self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet)
self.ui.labelHumanFriendlyTTLDescription.setFont(font) self.ui.labelHumanFriendlyTTLDescription.setFont(font)
@ -1068,8 +1071,10 @@ class MyForm(settingsmixin.SMainWindow):
statusText = _translate( statusText = _translate(
"MainWindow", "Forced difficulty override. Send should start soon.") "MainWindow", "Forced difficulty override. Send should start soon.")
else: else:
statusText = _translate("MainWindow", "Unknown status: %1 %2").arg(status).arg( statusText = _translate(
l10n.formatTimestamp(lastactiontime)) "MainWindow", "Unknown status: %1 %2").arg(
status, l10n.formatTimestamp(lastactiontime)
)
newItem = myTableWidgetItem(statusText) newItem = myTableWidgetItem(statusText)
newItem.setToolTip(statusText) newItem.setToolTip(statusText)
newItem.setData(QtCore.Qt.UserRole, QtCore.QByteArray(ackdata)) newItem.setData(QtCore.Qt.UserRole, QtCore.QByteArray(ackdata))
@ -1143,7 +1148,8 @@ class MyForm(settingsmixin.SMainWindow):
tableWidget.horizontalHeader().setSortIndicator( tableWidget.horizontalHeader().setSortIndicator(
3, QtCore.Qt.DescendingOrder) 3, QtCore.Qt.DescendingOrder)
tableWidget.setSortingEnabled(True) tableWidget.setSortingEnabled(True)
tableWidget.horizontalHeaderItem(3).setText(_translate("MainWindow", "Sent", None)) tableWidget.horizontalHeaderItem(3).setText(
_translate("MainWindow", "Sent"))
tableWidget.setUpdatesEnabled(True) tableWidget.setUpdatesEnabled(True)
# Load messages from database file # Load messages from database file
@ -1177,7 +1183,8 @@ class MyForm(settingsmixin.SMainWindow):
3, QtCore.Qt.DescendingOrder) 3, QtCore.Qt.DescendingOrder)
tableWidget.setSortingEnabled(True) tableWidget.setSortingEnabled(True)
tableWidget.selectRow(0) tableWidget.selectRow(0)
tableWidget.horizontalHeaderItem(3).setText(_translate("MainWindow", "Received", None)) tableWidget.horizontalHeaderItem(3).setText(
_translate("MainWindow", "Received"))
tableWidget.setUpdatesEnabled(True) tableWidget.setUpdatesEnabled(True)
# create application indicator # create application indicator
@ -1453,19 +1460,50 @@ class MyForm(settingsmixin.SMainWindow):
# may manage your keys by editing the keys.dat file stored in # may manage your keys by editing the keys.dat file stored in
# the same directory as this program. It is important that you # the same directory as this program. It is important that you
# back up this file.', QMessageBox.Ok) # back up this file.', QMessageBox.Ok)
reply = QtGui.QMessageBox.information(self, 'keys.dat?', _translate( reply = QtGui.QMessageBox.information(
"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."), QtGui.QMessageBox.Ok) 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."),
QtGui.QMessageBox.Ok)
else: else:
QtGui.QMessageBox.information(self, 'keys.dat?', _translate( QtGui.QMessageBox.information(
"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(state.appdata), QtGui.QMessageBox.Ok) self, 'keys.dat?', _translate(
"MainWindow",
"You may manage your keys by editing the keys.dat"
" file stored in\n %1 \n"
"It is important that you back up this file."
).arg(state.appdata), QtGui.QMessageBox.Ok)
elif sys.platform == 'win32' or sys.platform == 'win64': elif sys.platform == 'win32' or sys.platform == 'win64':
_tr_open = _translate(
"MainWindow",
" Would you like to open the file now?"
" (Be sure to close Bitmessage before making"
" any changes.)",
"The second part of string begining with "
"\'You may manage your keys ...\' "
"Notice the leading space!"
)
if state.appdata == '': if state.appdata == '':
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate( reply = QtGui.QMessageBox.question(
"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) 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."
) + _tr_open, QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
else: else:
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Open keys.dat?"), _translate( reply = QtGui.QMessageBox.question(
"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(state.appdata), QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) self, _translate("MainWindow", "Open keys.dat?"),
_translate(
"MainWindow",
"You may manage your keys by editing the keys.dat"
" file stored in\n %1 \n"
"It is important that you back up this file."
).arg(state.appdata) + _tr_open,
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
shared.openKeysFile() shared.openKeysFile()
@ -1953,24 +1991,32 @@ class MyForm(settingsmixin.SMainWindow):
pass pass
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status) logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
_tr_wrong_soft = _translate(
"MainWindow",
"There might be something wrong with the software"
" of your acquaintance.",
"The second part of string begining with "
"\'Error: Some data encoded in the "
"recipient address...\'"
)
if status == 'missingbm': if status == 'missingbm':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Bitmessage addresses start with" "Error: Bitmessage addresses start with"
" BM- Please check the recipient address %1" " BM- Please check the recipient address %1"
).arg(toAddress)) ).arg(toAddress))
elif status == 'checksumfailed': elif status == 'checksumfailed':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: The recipient address %1 is not" "Error: The recipient address %1 is not"
" typed or copied correctly. Please check it." " typed or copied correctly. Please check it."
).arg(toAddress)) ).arg(toAddress))
elif status == 'invalidcharacters': elif status == 'invalidcharacters':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: The recipient address %1 contains" "Error: The recipient address %1 contains"
" invalid characters. Please check it." " invalid characters. Please check it."
).arg(toAddress)) ).arg(toAddress))
elif status == 'versiontoohigh': elif status == 'versiontoohigh':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
@ -1978,54 +2024,63 @@ class MyForm(settingsmixin.SMainWindow):
" %1 is too high. Either you need to upgrade" " %1 is too high. Either you need to upgrade"
" your Bitmessage software or your" " your Bitmessage software or your"
" acquaintance is being clever." " acquaintance is being clever."
).arg(toAddress)) ).arg(toAddress))
elif status == 'ripetooshort': elif status == 'ripetooshort':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Some data encoded in the recipient" "Error: Some data encoded in the recipient"
" address %1 is too short. There might be" " address %1 is too short. ").arg(toAddress) +
" something wrong with the software of" _tr_wrong_soft)
" your acquaintance."
).arg(toAddress))
elif status == 'ripetoolong': elif status == 'ripetoolong':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Some data encoded in the recipient" "Error: Some data encoded in the recipient"
" address %1 is too long. There might be" " address %1 is too long. ").arg(toAddress) +
" something wrong with the software of" _tr_wrong_soft)
" your acquaintance."
).arg(toAddress))
elif status == 'varintmalformed': elif status == 'varintmalformed':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Some data encoded in the recipient" "Error: Some data encoded in the recipient"
" address %1 is malformed. There might be" " address %1 is malformed. ").arg(toAddress) +
" something wrong with the software of" _tr_wrong_soft)
" your acquaintance."
).arg(toAddress))
else: else:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: Something is wrong with the" "Error: Something is wrong with the"
" recipient address %1." " recipient address %1."
).arg(toAddress)) ).arg(toAddress))
elif fromAddress == '': elif fromAddress == '':
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "MainWindow",
"Error: You must specify a From address. If you" "Error: You must specify a From address. If you"
" don\'t have one, go to the" " don\'t have one, go to the"
" \'Your Identities\' tab.") " \'Your Identities\' tab."))
)
else: else:
toAddress = addBMIfNotPresent(toAddress) toAddress = addBMIfNotPresent(toAddress)
if addressVersionNumber > 4 or addressVersionNumber <= 1: if addressVersionNumber > 4 or addressVersionNumber <= 1:
QtGui.QMessageBox.about(self, _translate("MainWindow", "Address version number"), _translate( QtGui.QMessageBox.about(
"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))) 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, str(addressVersionNumber)))
continue continue
if streamNumber > 1 or streamNumber == 0: if streamNumber > 1 or streamNumber == 0:
QtGui.QMessageBox.about(self, _translate("MainWindow", "Stream number"), _translate( QtGui.QMessageBox.about(
"MainWindow", "Concerning the address %1, Bitmessage cannot handle stream numbers of %2. Perhaps upgrade Bitmessage to the latest version.").arg(toAddress).arg(str(streamNumber))) 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, str(streamNumber)))
continue continue
self.statusbar.clearMessage() self.statusbar.clearMessage()
if shared.statusIconColor == 'red': if shared.statusIconColor == 'red':
@ -2699,21 +2754,48 @@ class MyForm(settingsmixin.SMainWindow):
waitForSync = False waitForSync = False
# C PoW currently doesn't support interrupting and OpenCL is untested # C PoW currently doesn't support interrupting and OpenCL is untested
if getPowType() == "python" and (powQueueSize() > 0 or PendingUpload().len() > 0): if getPowType() == "python" and (
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Proof of work pending"), powQueueSize() > 0 or PendingUpload().len() > 0
_translate("MainWindow", "%n object(s) pending proof of work", None, QtCore.QCoreApplication.CodecForTr, powQueueSize()) + ", " + ):
_translate("MainWindow", "%n object(s) waiting to be distributed", None, QtCore.QCoreApplication.CodecForTr, PendingUpload().len()) + "\n\n" + reply = QtGui.QMessageBox.question(
_translate("MainWindow", "Wait until these tasks finish?"), self, _translate("MainWindow", "Proof of work pending"),
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No|QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) _translate(
"MainWindow", "%n object(s) pending proof of work",
None, _codec, powQueueSize()) + ", " +
_translate(
"MainWindow", "%n object(s) waiting to be distributed",
None, _codec, PendingUpload().len()) + "\n\n" +
_translate("MainWindow", "Wait until these tasks finish?"),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
QtGui.QMessageBox.Cancel,
QtGui.QMessageBox.Cancel
)
if reply == QtGui.QMessageBox.No: if reply == QtGui.QMessageBox.No:
waitForPow = False waitForPow = False
elif reply == QtGui.QMessageBox.Cancel: elif reply == QtGui.QMessageBox.Cancel:
return return
_tr_if_quit = _translate(
"MainWindow",
" If you quit now, it may cause delivery delays."
" Wait until the synchronization finishes?",
"The second part of string begining with "
"\'Bitmessage hasn't synchronized (connected)...\' "
"Notice the leading space!"
)
if PendingDownloadQueue.totalSize() > 0: if PendingDownloadQueue.totalSize() > 0:
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Synchronisation pending"), reply = QtGui.QMessageBox.question(
_translate("MainWindow", "Bitmessage hasn't synchronised with the network, %n object(s) to be downloaded. If you quit now, it may cause delivery delays. Wait until the synchronisation finishes?", None, QtCore.QCoreApplication.CodecForTr, PendingDownloadQueue.totalSize()), self,
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No|QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) _translate("MainWindow", "Synchronization pending"),
_translate(
"MainWindow",
"Bitmessage hasn't synchronized with the network,"
" %n object(s) to be downloaded.",
None, _codec, PendingDownloadQueue.totalSize()
) + _tr_if_quit,
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
QtGui.QMessageBox.Cancel,
QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
waitForSync = True waitForSync = True
elif reply == QtGui.QMessageBox.Cancel: elif reply == QtGui.QMessageBox.Cancel:
@ -2721,11 +2803,19 @@ class MyForm(settingsmixin.SMainWindow):
else: else:
PendingDownloadQueue.stop() PendingDownloadQueue.stop()
if shared.statusIconColor == 'red' and not BMConfigParser().safeGetBoolean( if shared.statusIconColor == 'red' \
'bitmessagesettings', 'dontconnect'): and not BMConfigParser().safeGetBoolean(
reply = QtGui.QMessageBox.question(self, _translate("MainWindow", "Not connected"), 'bitmessagesettings', 'dontconnect'):
_translate("MainWindow", "Bitmessage isn't connected to the network. If you quit now, it may cause delivery delays. Wait until connected and the synchronisation finishes?"), reply = QtGui.QMessageBox.question(
QtGui.QMessageBox.Yes|QtGui.QMessageBox.No|QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Cancel) self,
_translate("MainWindow", "Not connected"),
_translate(
"MainWindow",
"Bitmessage isn't connected to the network."
) + _tr_if_quit,
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
QtGui.QMessageBox.Cancel,
QtGui.QMessageBox.Cancel)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:
waitForConnection = True waitForConnection = True
waitForSync = True waitForSync = True
@ -2749,7 +2839,7 @@ class MyForm(settingsmixin.SMainWindow):
# this probably will not work correctly, because there is a delay between the status icon turning red and inventory exchange, but it's better than nothing. # this probably will not work correctly, because there is a delay between the status icon turning red and inventory exchange, but it's better than nothing.
if waitForSync: if waitForSync:
self.updateStatusBar(_translate( self.updateStatusBar(_translate(
"MainWindow", "Waiting for finishing synchronisation...")) "MainWindow", "Waiting for finishing synchronization..."))
while PendingDownloadQueue.totalSize() > 0: while PendingDownloadQueue.totalSize() > 0:
time.sleep(0.5) time.sleep(0.5)
QtCore.QCoreApplication.processEvents( QtCore.QCoreApplication.processEvents(
@ -3884,18 +3974,22 @@ class MyForm(settingsmixin.SMainWindow):
self.popMenuInbox.addAction(self.actionReplyChan) self.popMenuInbox.addAction(self.actionReplyChan)
self.popMenuInbox.addAction(self.actionReply) self.popMenuInbox.addAction(self.actionReply)
self.popMenuInbox.addAction(self.actionAddSenderToAddressBook) self.popMenuInbox.addAction(self.actionAddSenderToAddressBook)
self.actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction( self.actionClipboardMessagelist = \
_translate("MainWindow", self.ui.inboxContextMenuToolbar.addAction(
"Copy subject to clipboard" if tableWidget.currentColumn() == 2 else "Copy address to clipboard" _translate("MainWindow", "Copy subject to clipboard")
), if tableWidget.currentColumn() == 2
self.on_action_ClipboardMessagelist) else _translate(
"MainWindow", "Copy address to clipboard"),
self.on_action_ClipboardMessagelist
)
self.popMenuInbox.addAction(self.actionClipboardMessagelist) self.popMenuInbox.addAction(self.actionClipboardMessagelist)
self.popMenuInbox.addSeparator() self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionAddSenderToBlackList) self.popMenuInbox.addAction(self.actionAddSenderToBlackList)
self.popMenuInbox.addSeparator() self.popMenuInbox.addSeparator()
self.popMenuInbox.addAction(self.actionSaveMessageAs) self.popMenuInbox.addAction(self.actionSaveMessageAs)
if currentFolder == "trash": if currentFolder == "trash":
self.popMenuInbox.addAction(self.actionUndeleteTrashedMessage) self.popMenuInbox.addAction(
self.actionUndeleteTrashedMessage)
else: else:
self.popMenuInbox.addAction(self.actionTrashInboxMessage) self.popMenuInbox.addAction(self.actionTrashInboxMessage)
self.popMenuInbox.exec_(tableWidget.mapToGlobal(point)) self.popMenuInbox.exec_(tableWidget.mapToGlobal(point))

View File

@ -755,7 +755,7 @@ class Ui_MainWindow(object):
self.actionExit.setText(_translate("MainWindow", "Quit", None)) self.actionExit.setText(_translate("MainWindow", "Quit", None))
self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q", None)) self.actionExit.setShortcut(_translate("MainWindow", "Ctrl+Q", None))
self.actionHelp.setText(_translate("MainWindow", "Help", None)) self.actionHelp.setText(_translate("MainWindow", "Help", None))
self.actionHelp.setShortcut(_translate("MainWindow", "F1", None)) self.actionHelp.setShortcut("F1")
self.actionSupport.setText(_translate("MainWindow", "Contact support", None)) self.actionSupport.setText(_translate("MainWindow", "Contact support", None))
self.actionAbout.setText(_translate("MainWindow", "About", None)) self.actionAbout.setText(_translate("MainWindow", "About", None))
self.actionSettings.setText(_translate("MainWindow", "Settings", None)) self.actionSettings.setText(_translate("MainWindow", "Settings", None))

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Bitmessage</string> <string notr="true">Bitmessage</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="2">

View File

@ -56,7 +56,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>@mailchuck.com</string> <string notr="true">@mailchuck.com</string>
</property> </property>
<property name="cursorPosition"> <property name="cursorPosition">
<number>0</number> <number>0</number>

View File

@ -17,7 +17,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelHelpURI"> <widget class="QLabel" name="labelHelpURI">
<property name="text"> <property name="text">
<string>&lt;a href=&quot;https://bitmessage.org/wiki/PyBitmessage_Help&quot;&gt;https://bitmessage.org/wiki/PyBitmessage_Help&lt;/a&gt;</string> <string notr="true">&lt;a href=&quot;https://bitmessage.org/wiki/PyBitmessage_Help&quot;&gt;https://bitmessage.org/wiki/PyBitmessage_Help&lt;/a&gt;</string>
</property> </property>
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>

View File

@ -1,8 +1,7 @@
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import time import time
import shared import shared
from tr import _translate, _codec
from tr import _translate
from inventory import Inventory, PendingDownloadQueue, PendingUpload from inventory import Inventory, PendingDownloadQueue, PendingUpload
import knownnodes import knownnodes
import l10n import l10n
@ -27,9 +26,7 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
header.setSortIndicator(0, QtCore.Qt.AscendingOrder) header.setSortIndicator(0, QtCore.Qt.AscendingOrder)
self.startup = time.localtime() self.startup = time.localtime()
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg(
l10n.formatTimestamp(self.startup)))
self.UISignalThread = UISignaler.get() self.UISignalThread = UISignaler.get()
QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL( QtCore.QObject.connect(self.UISignalThread, QtCore.SIGNAL(
"updateNumberOfMessagesProcessed()"), self.updateNumberOfMessagesProcessed) "updateNumberOfMessagesProcessed()"), self.updateNumberOfMessagesProcessed)
@ -54,33 +51,42 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
self.timer.stop() self.timer.stop()
def formatBytes(self, num): def formatBytes(self, num):
for x in [_translate("networkstatus", "byte(s)", None, QtCore.QCoreApplication.CodecForTr, num), "kB", "MB", "GB"]: for x in [_translate("networkstatus", "byte(s)", None, _codec, num),
_translate("networkstatus", "kB"),
_translate("networkstatus", "MB"),
_translate("networkstatus", "GB")]:
if num < 1000.0: if num < 1000.0:
return "%3.0f %s" % (num, x) return "%3.0f %s" % (num, x)
num /= 1000.0 num /= 1000.0
return "%3.0f %s" % (num, 'TB') return "%3.0f %s" % (num, _translate("networkstatus", "TB"))
def formatByteRate(self, num): def formatByteRate(self, num):
num /= 1000 num /= 1000
return "%4.0f kB" % num return "%4.0f" % num
def updateNumberOfObjectsToBeSynced(self): def updateNumberOfObjectsToBeSynced(self):
self.labelSyncStatus.setText(_translate("networkstatus", "Object(s) to be synced: %n", None, QtCore.QCoreApplication.CodecForTr, network.stats.pendingDownload() + network.stats.pendingUpload())) self.labelSyncStatus.setText(_translate(
"networkstatus", "Object(s) to be synced: %n", None, _codec,
network.stats.pendingDownload() + network.stats.pendingUpload()
))
def updateNumberOfMessagesProcessed(self): def updateNumberOfMessagesProcessed(self):
self.updateNumberOfObjectsToBeSynced() self.updateNumberOfObjectsToBeSynced()
self.labelMessageCount.setText(_translate( self.labelMessageCount.setText(_translate(
"networkstatus", "Processed %n person-to-person message(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfMessagesProcessed)) "networkstatus", "Processed %n person-to-person message(s).",
None, _codec, shared.numberOfMessagesProcessed))
def updateNumberOfBroadcastsProcessed(self): def updateNumberOfBroadcastsProcessed(self):
self.updateNumberOfObjectsToBeSynced() self.updateNumberOfObjectsToBeSynced()
self.labelBroadcastCount.setText(_translate( self.labelBroadcastCount.setText(_translate(
"networkstatus", "Processed %n broadcast message(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfBroadcastsProcessed)) "networkstatus", "Processed %n broadcast message(s).",
None, _codec, shared.numberOfBroadcastsProcessed))
def updateNumberOfPubkeysProcessed(self): def updateNumberOfPubkeysProcessed(self):
self.updateNumberOfObjectsToBeSynced() self.updateNumberOfObjectsToBeSynced()
self.labelPubkeyCount.setText(_translate( self.labelPubkeyCount.setText(_translate(
"networkstatus", "Processed %n public key(s).", None, QtCore.QCoreApplication.CodecForTr, shared.numberOfPubkeysProcessed)) "networkstatus", "Processed %n public key(s).",
None, _codec, shared.numberOfPubkeysProcessed))
def updateNumberOfBytes(self): def updateNumberOfBytes(self):
""" """
@ -88,9 +94,15 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
sent and received by 2. sent and received by 2.
""" """
self.labelBytesRecvCount.setText(_translate( self.labelBytesRecvCount.setText(_translate(
"networkstatus", "Down: %1/s Total: %2").arg(self.formatByteRate(network.stats.downloadSpeed()), self.formatBytes(network.stats.receivedBytes()))) "networkstatus", "Down: %1 kB/s Total: %2").arg(
self.formatByteRate(network.stats.downloadSpeed()),
self.formatBytes(network.stats.receivedBytes()))
)
self.labelBytesSentCount.setText(_translate( self.labelBytesSentCount.setText(_translate(
"networkstatus", "Up: %1/s Total: %2").arg(self.formatByteRate(network.stats.uploadSpeed()), self.formatBytes(network.stats.sentBytes()))) "networkstatus", "Up: %1 kB/s Total: %2").arg(
self.formatByteRate(network.stats.uploadSpeed()),
self.formatBytes(network.stats.sentBytes()))
)
def updateNetworkStatusTab(self, outbound, add, destination): def updateNetworkStatusTab(self, outbound, add, destination):
if outbound: if outbound:
@ -151,8 +163,9 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
self.tableWidgetConnectionCount.setUpdatesEnabled(True) self.tableWidgetConnectionCount.setUpdatesEnabled(True)
self.tableWidgetConnectionCount.setSortingEnabled(True) self.tableWidgetConnectionCount.setSortingEnabled(True)
self.labelTotalConnections.setText(_translate( self.labelTotalConnections.setText(_translate(
"networkstatus", "Total Connections: %1").arg(str(self.tableWidgetConnectionCount.rowCount()))) "networkstatus", "Total Connections: %1"
# 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. ).arg(str(self.tableWidgetConnectionCount.rowCount())))
# 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.
if self.tableWidgetConnectionCount.rowCount() and shared.statusIconColor == 'red': if self.tableWidgetConnectionCount.rowCount() and shared.statusIconColor == 'red':
self.window().setStatusIcon('yellow') self.window().setStatusIcon('yellow')
elif self.tableWidgetConnectionCount.rowCount() == 0 and shared.statusIconColor != "red": elif self.tableWidgetConnectionCount.rowCount() == 0 and shared.statusIconColor != "red":
@ -161,12 +174,14 @@ class NetworkStatus(QtGui.QWidget, RetranslateMixin):
# timer driven # timer driven
def runEveryTwoSeconds(self): def runEveryTwoSeconds(self):
self.labelLookupsPerSecond.setText(_translate( self.labelLookupsPerSecond.setText(_translate(
"networkstatus", "Inventory lookups per second: %1").arg(str(Inventory().numberOfInventoryLookupsPerformed/2))) "networkstatus", "Inventory lookups per second: %1"
).arg(str(Inventory().numberOfInventoryLookupsPerformed/2)))
Inventory().numberOfInventoryLookupsPerformed = 0 Inventory().numberOfInventoryLookupsPerformed = 0
self.updateNumberOfBytes() self.updateNumberOfBytes()
self.updateNumberOfObjectsToBeSynced() self.updateNumberOfObjectsToBeSynced()
def retranslateUi(self): def retranslateUi(self):
super(NetworkStatus, self).retranslateUi() super(NetworkStatus, self).retranslateUi()
self.labelStartupTime.setText(_translate("networkstatus", "Since startup on %1").arg( self.labelStartupTime.setText(_translate(
l10n.formatTimestamp(self.startup))) "networkstatus", "Since startup on %1"
).arg(l10n.formatTimestamp(self.startup)))

View File

@ -141,7 +141,7 @@
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>TLS</string> <string notr="true">TLS</string>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Connection encryption</string> <string>Connection encryption</string>
@ -182,7 +182,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>Since startup:</string> <string notr="true">Since startup:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>

View File

@ -150,7 +150,7 @@
</size> </size>
</property> </property>
<property name="text"> <property name="text">
<string>1</string> <string notr="true">1</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -1,39 +1,60 @@
import os import os
import textwrap
import shared import shared
# This is used so that the translateText function can be used when we are in daemon mode and not using any QT functions. _codec = None
# This is used so that the translateText function can be used
# when we are in daemon mode and not using any Qt functions.
class translateClass: class translateClass:
def __init__(self, context, text): def __init__(self, context, text):
self.context = context
self.text = text self.text = text
def arg(self,argument):
if '%' in self.text:
return translateClass(self.context, self.text.replace('%','',1)) # This doesn't actually do anything with the arguments because we don't have a UI in which to display this information anyway.
else:
return self.text
def _translate(context, text, disambiguation = None, encoding = None, n = None): def __str__(self):
return translateText(context, text, n) return unicode(self.text)
def translateText(context, text, n = None): def arg(self, *args):
# if args and '%' in self.text:
# try:
# ''.join(args)
# except TypeError:
# args = None
# self.text = self.text.replace('%', '', len(args) if args else 1)
# This doesn't actually do anything with the arguments because
# we don't have a UI in which to display this information anyway.
return self
def _translate(context, text, disambiguation=None, encoding=None, n=None):
return translateText(context, text, disambiguation, n)
def translateText(context, text, disambiguation=None, n=None):
try: try:
is_daemon = shared.thisapp.daemon is_daemon = shared.thisapp.daemon
except AttributeError: # inside the plugin except AttributeError: # inside the plugin
is_daemon = False is_daemon = False
if not is_daemon: if is_daemon:
try: return translateClass(context, text)
from PyQt4 import QtCore, QtGui
except Exception as err: try:
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon' from PyQt4 import QtCore, QtGui
print 'Error message:', err except Exception as err:
os._exit(0) print textwrap.dedent("""
if n is None: PyBitmessage requires PyQt unless you want to run it as a daemon
return QtGui.QApplication.translate(context, text) and interact with it using the API. You can download PyQt from
else: http://www.riverbankcomputing.com/software/pyqt/download
return QtGui.QApplication.translate(context, text, None, QtCore.QCoreApplication.CodecForTr, n) or by searching Google for 'PyQt Download'.
else: If you want to run in daemon mode, see
if '%' in text: https://bitmessage.org/wiki/Daemon
return translateClass(context, text.replace('%','',1)) """)
else: print 'Error message:', err
return text os._exit(0)
return QtGui.QApplication.translate(
context, text, disambiguation,
QtCore.QCoreApplication.CodecForTr, n
) if n is not None \
else QtGui.QApplication.translate(context, text, disambiguation)