use string.format instead of old style (%) formatting
This commit is contained in:
@@ -11,15 +11,15 @@ class GuiMixin(object):
|
||||
# Requires: self.proto, self.device
|
||||
|
||||
messages = {
|
||||
3: _("Confirm the transaction output on your %s device"),
|
||||
4: _("Confirm internal entropy on your %s device to begin"),
|
||||
5: _("Write down the seed word shown on your %s"),
|
||||
6: _("Confirm on your %s that you want to wipe it clean"),
|
||||
7: _("Confirm on your %s device the message to sign"),
|
||||
3: _("Confirm the transaction output on your {} device"),
|
||||
4: _("Confirm internal entropy on your {} device to begin"),
|
||||
5: _("Write down the seed word shown on your {}"),
|
||||
6: _("Confirm on your {} that you want to wipe it clean"),
|
||||
7: _("Confirm on your {} device the message to sign"),
|
||||
8: _("Confirm the total amount spent and the transaction fee on your "
|
||||
"%s device"),
|
||||
10: _("Confirm wallet address on your %s device"),
|
||||
'default': _("Check your %s device to continue"),
|
||||
"{} device"),
|
||||
10: _("Confirm wallet address on your {} device"),
|
||||
'default': _("Check your {} device to continue"),
|
||||
}
|
||||
|
||||
def callback_Failure(self, msg):
|
||||
@@ -38,18 +38,18 @@ class GuiMixin(object):
|
||||
message = self.msg
|
||||
if not message:
|
||||
message = self.messages.get(msg.code, self.messages['default'])
|
||||
self.handler.show_message(message % self.device, self.cancel)
|
||||
self.handler.show_message(message.format(self.device), self.cancel)
|
||||
return self.proto.ButtonAck()
|
||||
|
||||
def callback_PinMatrixRequest(self, msg):
|
||||
if msg.type == 2:
|
||||
msg = _("Enter a new PIN for your %s:")
|
||||
msg = _("Enter a new PIN for your {}:")
|
||||
elif msg.type == 3:
|
||||
msg = (_("Re-enter the new PIN for your %s.\n\n"
|
||||
msg = (_("Re-enter the new PIN for your {}.\n\n"
|
||||
"NOTE: the positions of the numbers have changed!"))
|
||||
else:
|
||||
msg = _("Enter your current %s PIN:")
|
||||
pin = self.handler.get_pin(msg % self.device)
|
||||
msg = _("Enter your current {} PIN:")
|
||||
pin = self.handler.get_pin(msg.format(self.device))
|
||||
if not pin:
|
||||
return self.proto.Cancel()
|
||||
return self.proto.PinMatrixAck(pin=pin)
|
||||
@@ -57,9 +57,9 @@ class GuiMixin(object):
|
||||
def callback_PassphraseRequest(self, req):
|
||||
if self.creating_wallet:
|
||||
msg = _("Enter a passphrase to generate this wallet. Each time "
|
||||
"you use this wallet your %s will prompt you for the "
|
||||
"you use this wallet your {} will prompt you for the "
|
||||
"passphrase. If you forget the passphrase you cannot "
|
||||
"access the bitcoins in the wallet.") % self.device
|
||||
"access the bitcoins in the wallet.").format(self.device)
|
||||
else:
|
||||
msg = _("Enter the passphrase to unlock this wallet:")
|
||||
passphrase = self.handler.get_passphrase(msg, self.creating_wallet)
|
||||
@@ -70,8 +70,8 @@ class GuiMixin(object):
|
||||
|
||||
def callback_WordRequest(self, msg):
|
||||
self.step += 1
|
||||
msg = _("Step %d/24. Enter seed word as explained on "
|
||||
"your %s:") % (self.step, self.device)
|
||||
msg = _("Step {}/24. Enter seed word as explained on "
|
||||
"your {}:").format(self.step, self.device)
|
||||
word = self.handler.get_word(msg)
|
||||
# Unfortunately the device can't handle self.proto.Cancel()
|
||||
return self.proto.WordAck(word=word)
|
||||
@@ -155,27 +155,27 @@ class KeepKeyClientBase(GuiMixin, PrintError):
|
||||
|
||||
def toggle_passphrase(self):
|
||||
if self.features.passphrase_protection:
|
||||
self.msg = _("Confirm on your %s device to disable passphrases")
|
||||
self.msg = _("Confirm on your {} device to disable passphrases")
|
||||
else:
|
||||
self.msg = _("Confirm on your %s device to enable passphrases")
|
||||
self.msg = _("Confirm on your {} device to enable passphrases")
|
||||
enabled = not self.features.passphrase_protection
|
||||
self.apply_settings(use_passphrase=enabled)
|
||||
|
||||
def change_label(self, label):
|
||||
self.msg = _("Confirm the new label on your %s device")
|
||||
self.msg = _("Confirm the new label on your {} device")
|
||||
self.apply_settings(label=label)
|
||||
|
||||
def change_homescreen(self, homescreen):
|
||||
self.msg = _("Confirm on your %s device to change your home screen")
|
||||
self.msg = _("Confirm on your {} device to change your home screen")
|
||||
self.apply_settings(homescreen=homescreen)
|
||||
|
||||
def set_pin(self, remove):
|
||||
if remove:
|
||||
self.msg = _("Confirm on your %s device to disable PIN protection")
|
||||
self.msg = _("Confirm on your {} device to disable PIN protection")
|
||||
elif self.features.pin_protection:
|
||||
self.msg = _("Confirm on your %s device to change your PIN")
|
||||
self.msg = _("Confirm on your {} device to change your PIN")
|
||||
else:
|
||||
self.msg = _("Confirm on your %s device to set a PIN")
|
||||
self.msg = _("Confirm on your {} device to set a PIN")
|
||||
self.change_pin(remove)
|
||||
|
||||
def clear_session(self):
|
||||
|
||||
@@ -30,7 +30,7 @@ class KeepKeyCompatibleKeyStore(Hardware_KeyStore):
|
||||
return self.plugin.get_client(self, force_pair)
|
||||
|
||||
def decrypt_message(self, sequence, message, password):
|
||||
raise RuntimeError(_('Encryption and decryption are not implemented by %s') % self.device)
|
||||
raise RuntimeError(_('Encryption and decryption are not implemented by {}').format(self.device))
|
||||
|
||||
def sign_message(self, sequence, message, password):
|
||||
client = self.get_client()
|
||||
@@ -119,9 +119,9 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
|
||||
return None
|
||||
|
||||
if not client.atleast_version(*self.minimum_firmware):
|
||||
msg = (_('Outdated %s firmware for device labelled %s. Please '
|
||||
'download the updated firmware from %s') %
|
||||
(self.device, client.label(), self.firmware_URL))
|
||||
msg = (_('Outdated {} firmware for device labelled {}. Please '
|
||||
'download the updated firmware from {}')
|
||||
.format(self.device, client.label(), self.firmware_URL))
|
||||
self.print_error(msg)
|
||||
handler.show_error(msg)
|
||||
return None
|
||||
@@ -143,14 +143,14 @@ class KeepKeyCompatiblePlugin(HW_PluginBase):
|
||||
|
||||
def initialize_device(self, device_id, wizard, handler):
|
||||
# Initialization method
|
||||
msg = _("Choose how you want to initialize your %s.\n\n"
|
||||
msg = _("Choose how you want to initialize your {}.\n\n"
|
||||
"The first two methods are secure as no secret information "
|
||||
"is entered into your computer.\n\n"
|
||||
"For the last two methods you input secrets on your keyboard "
|
||||
"and upload them to your %s, and so you should "
|
||||
"and upload them to your {}, and so you should "
|
||||
"only do those on a computer you know to be trustworthy "
|
||||
"and free of malware."
|
||||
) % (self.device, self.device)
|
||||
).format(self.device, self.device)
|
||||
choices = [
|
||||
# Must be short as QT doesn't word-wrap radio button text
|
||||
(TIM_NEW, _("Let the device generate a completely new seed randomly")),
|
||||
|
||||
@@ -194,7 +194,7 @@ class QtPlugin(QtPluginBase):
|
||||
if type(keystore) == self.keystore_class and len(addrs) == 1:
|
||||
def show_address():
|
||||
keystore.thread.add(partial(self.show_address, wallet, addrs[0]))
|
||||
menu.addAction(_("Show on %s") % self.device, show_address)
|
||||
menu.addAction(_("Show on {}").format(self.device), show_address)
|
||||
|
||||
def show_settings_dialog(self, window, keystore):
|
||||
device_id = self.choose_device(window, keystore)
|
||||
@@ -227,7 +227,7 @@ class QtPlugin(QtPluginBase):
|
||||
bg = QButtonGroup()
|
||||
for i, count in enumerate([12, 18, 24]):
|
||||
rb = QRadioButton(gb)
|
||||
rb.setText(_("%d words") % count)
|
||||
rb.setText(_("{} words").format(count))
|
||||
bg.addButton(rb)
|
||||
bg.setId(rb, i)
|
||||
hbox1.addWidget(rb)
|
||||
@@ -292,7 +292,7 @@ class SettingsDialog(WindowModalDialog):
|
||||
their PIN.'''
|
||||
|
||||
def __init__(self, window, plugin, keystore, device_id):
|
||||
title = _("%s Settings") % plugin.device
|
||||
title = _("{} Settings").format(plugin.device)
|
||||
super(SettingsDialog, self).__init__(window, title)
|
||||
self.setMaximumWidth(540)
|
||||
|
||||
@@ -457,9 +457,9 @@ class SettingsDialog(WindowModalDialog):
|
||||
settings_glayout = QGridLayout()
|
||||
|
||||
# Settings tab - Label
|
||||
label_msg = QLabel(_("Name this %s. If you have mutiple devices "
|
||||
label_msg = QLabel(_("Name this {}. If you have mutiple devices "
|
||||
"their labels help distinguish them.")
|
||||
% plugin.device)
|
||||
.format(plugin.device))
|
||||
label_msg.setWordWrap(True)
|
||||
label_label = QLabel(_("Device Label"))
|
||||
label_edit = QLineEdit()
|
||||
@@ -482,7 +482,7 @@ class SettingsDialog(WindowModalDialog):
|
||||
pin_msg = QLabel(_("PIN protection is strongly recommended. "
|
||||
"A PIN is your only protection against someone "
|
||||
"stealing your bitcoins if they obtain physical "
|
||||
"access to your %s.") % plugin.device)
|
||||
"access to your {}.").format(plugin.device))
|
||||
pin_msg.setWordWrap(True)
|
||||
pin_msg.setStyleSheet("color: red")
|
||||
settings_glayout.addWidget(pin_msg, 3, 1, 1, -1)
|
||||
@@ -497,8 +497,8 @@ class SettingsDialog(WindowModalDialog):
|
||||
homescreen_clear_button.clicked.connect(clear_homescreen)
|
||||
homescreen_msg = QLabel(_("You can set the homescreen on your "
|
||||
"device to personalize it. You must "
|
||||
"choose a %d x %d monochrome black and "
|
||||
"white image.") % (hs_rows, hs_cols))
|
||||
"choose a {} x {} monochrome black and "
|
||||
"white image.").format(hs_rows, hs_cols))
|
||||
homescreen_msg.setWordWrap(True)
|
||||
settings_glayout.addWidget(homescreen_label, 4, 0)
|
||||
settings_glayout.addWidget(homescreen_change_button, 4, 1)
|
||||
@@ -541,7 +541,7 @@ class SettingsDialog(WindowModalDialog):
|
||||
clear_pin_button.clicked.connect(clear_pin)
|
||||
clear_pin_warning = QLabel(
|
||||
_("If you disable your PIN, anyone with physical access to your "
|
||||
"%s device can spend your bitcoins.") % plugin.device)
|
||||
"{} device can spend your bitcoins.").format(plugin.device))
|
||||
clear_pin_warning.setWordWrap(True)
|
||||
clear_pin_warning.setStyleSheet("color: red")
|
||||
advanced_glayout.addWidget(clear_pin_button, 0, 2)
|
||||
|
||||
Reference in New Issue
Block a user