clean-up in gui/qt/main_window.py: use string.format for translated strings, and some indentation

This commit is contained in:
SomberNight 2018-01-29 15:05:30 +01:00
parent c7b4ef82bc
commit 1bf54a0bc5

View file

@ -553,24 +553,24 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return return
self.print_error("Notifying GUI") self.print_error("Notifying GUI")
if len(self.tx_notifications) > 0: if len(self.tx_notifications) > 0:
# Combine the transactions if there are more then three # Combine the transactions if there are at least three
tx_amount = len(self.tx_notifications) num_txns = len(self.tx_notifications)
if(tx_amount >= 3): if num_txns >= 3:
total_amount = 0 total_amount = 0
for tx in self.tx_notifications: for tx in self.tx_notifications:
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx) is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
if(v > 0): if v > 0:
total_amount += v total_amount += v
self.notify(_("%(txs)s new transactions received: Total amount received in the new transactions %(amount)s") \ self.notify(_("{} new transactions received: Total amount received in the new transactions {}")
% { 'txs' : tx_amount, 'amount' : self.format_amount_and_units(total_amount)}) .format(num_txns, self.format_amount_and_units(total_amount)))
self.tx_notifications = [] self.tx_notifications = []
else: else:
for tx in self.tx_notifications: for tx in self.tx_notifications:
if tx: if tx:
self.tx_notifications.remove(tx) self.tx_notifications.remove(tx)
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx) is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
if(v > 0): if v > 0:
self.notify(_("New transaction received: %(amount)s") % { 'amount' : self.format_amount_and_units(v)}) self.notify(_("New transaction received: {}").format(self.format_amount_and_units(v)))
def notify(self, message): def notify(self, message):
if self.tray: if self.tray:
@ -698,7 +698,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
text = _("Synchronizing...") text = _("Synchronizing...")
icon = QIcon(":icons/status_waiting.png") icon = QIcon(":icons/status_waiting.png")
elif server_lag > 1: elif server_lag > 1:
text = _("Server is lagging (%d blocks)"%server_lag) text = _("Server is lagging ({} blocks)").format(server_lag)
icon = QIcon(":icons/status_lagging.png") icon = QIcon(":icons/status_lagging.png")
else: else:
c, u, x = self.wallet.get_balance() c, u, x = self.wallet.get_balance()
@ -1425,7 +1425,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
if self.payto_e.is_alias and self.payto_e.validated is False: if self.payto_e.is_alias and self.payto_e.validated is False:
alias = self.payto_e.toPlainText() alias = self.payto_e.toPlainText()
msg = _('WARNING: the alias "%s" could not be validated via an additional security check, DNSSEC, and thus may not be correct.'%alias) + '\n' msg = _('WARNING: the alias "{}" could not be validated via an additional '
'security check, DNSSEC, and thus may not be correct.').format(alias) + '\n'
msg += _('Do you wish to continue?') msg += _('Do you wish to continue?')
if not self.question(msg): if not self.question(msg):
return return
@ -1788,8 +1789,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return True return True
def delete_contacts(self, labels): def delete_contacts(self, labels):
if not self.question(_("Remove %s from your list of contacts?") if not self.question(_("Remove {} from your list of contacts?")
% " + ".join(labels)): .format(" + ".join(labels))):
return return
for label in labels: for label in labels:
self.contacts.pop(label) self.contacts.pop(label)