Browse Source

translations: add note that f-strings cannot be translated

and replace current usage
hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
9a88c13b3d
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/gui/kivy/uix/screens.py
  2. 2
      electrum/gui/qt/channels_list.py
  3. 8
      electrum/gui/qt/lightning_dialog.py
  4. 3
      electrum/i18n.py
  5. 2
      electrum/lnworker.py

4
electrum/gui/kivy/uix/screens.py

@ -404,7 +404,7 @@ class SendScreen(CScreen):
self.app.wallet.delete_invoice(key)
self.update()
n = len(invoices)
d = Question(_(f'Delete {n} invoices?'), callback)
d = Question(_('Delete {} invoices?').format(n), callback)
d.open()
@ -522,7 +522,7 @@ class ReceiveScreen(CScreen):
self.app.wallet.delete_request(key)
self.update()
n = len(requests)
d = Question(_(f'Delete {n} requests?'), callback)
d = Question(_('Delete {} requests?').format(n), callback)
d.open()

2
electrum/gui/qt/channels_list.py

@ -108,7 +108,7 @@ class ChannelsList(MyTreeView):
chan = self.lnworker.channels[channel_id]
to_self_delay = chan.config[REMOTE].to_self_delay
msg = _('Force-close channel?') + '\n\n'\
+ _(f'Funds retrieved from this channel will not be available before {to_self_delay} blocks after forced closure.') + ' '\
+ _('Funds retrieved from this channel will not be available before {} blocks after forced closure.').format(to_self_delay) + ' '\
+ _('After that delay, funds will be sent to an address derived from your wallet seed.') + '\n\n'\
+ _('In the meantime, channel funds will not be recoverable from your seed, and might be lost if you lose your wallet.') + ' '\
+ _('To prevent that, you should have a backup of this channel on another device.')

8
electrum/gui/qt/lightning_dialog.py

@ -66,14 +66,14 @@ class LightningDialog(QDialog):
self.set_unknown_channels('', len(self.network.lngossip.unknown_ids))
def on_channel_db(self, event, num_nodes, num_channels, num_policies):
self.num_nodes.setText(_(f'{num_nodes} nodes'))
self.num_channels.setText(_(f'{num_channels} channels'))
self.num_nodes.setText(_('{} nodes').format(num_nodes))
self.num_channels.setText(_('{} channels').format(num_channels))
def set_num_peers(self, event, num_peers):
self.num_peers.setText(_(f'Connected to {num_peers} peers'))
self.num_peers.setText(_('Connected to {} peers').format(num_peers))
def set_unknown_channels(self, event, unknown):
self.status.setText(_(f'Requesting {unknown} channels...') if unknown else '')
self.status.setText(_('Requesting {} channels...').format(unknown) if unknown else '')
def is_hidden(self):
return self.isMinimized() or self.isHidden()

3
electrum/i18n.py

@ -30,6 +30,9 @@ LOCALE_DIR = os.path.join(os.path.dirname(__file__), 'locale')
language = gettext.translation('electrum', LOCALE_DIR, fallback=True)
# note: f-strings cannot be translated! see https://stackoverflow.com/q/49797658
# So this does not work: _(f"My name: {name}")
# instead use .format: _("My name: {}").format(name)
def _(x):
global language
return language.gettext(x)

2
electrum/lnworker.py

@ -819,7 +819,7 @@ class LNWallet(LNWorker):
if success:
break
else:
reason = _(f'Failed after {attempts} attempts')
reason = _('Failed after {} attempts').format(attempts)
self.network.trigger_callback('invoice_status', key)
if success:
self.network.trigger_callback('payment_succeeded', key)

Loading…
Cancel
Save