diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py index 892d6ffa3..3a053373d 100644 --- a/electrum/gui/kivy/main_window.py +++ b/electrum/gui/kivy/main_window.py @@ -751,7 +751,7 @@ class ElectrumWindow(App, Logger, EventListener): self.show_error(_('Lightning is not enabled for this wallet')) return if not self.wallet.lnworker.channels and not self.wallet.lnworker.channel_backups: - warning = _(messages.MSG_LIGHTNING_WARNING) + warning = messages.MSG_LIGHTNING_WARNING d = Question(_('Do you want to create your first channel?') + '\n\n' + warning, self.open_channel_dialog_with_warning) d.open() diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py index aaefac03a..5c3a4a098 100644 --- a/electrum/gui/kivy/uix/dialogs/lightning_channels.py +++ b/electrum/gui/kivy/uix/dialogs/lightning_channels.py @@ -522,7 +522,7 @@ class ChannelDetailsPopup(Popup, Logger): choices=choices, key = min(choices.keys()), callback=self._close, - description=_(messages.MSG_REQUEST_FORCE_CLOSE), + description=messages.MSG_REQUEST_FORCE_CLOSE, keep_choice_order=True) dialog.open() diff --git a/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py b/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py index 3123b1ff6..e1b6c11c6 100644 --- a/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py +++ b/electrum/gui/kivy/uix/dialogs/lightning_open_channel.py @@ -233,7 +233,7 @@ class LightningOpenChannelDialog(Factory.Popup, Logger): self.maybe_show_funding_tx(chan, funding_tx) else: title = _('Save backup') - help_text = _(messages.MSG_CREATED_NON_RECOVERABLE_CHANNEL) + help_text = messages.MSG_CREATED_NON_RECOVERABLE_CHANNEL data = lnworker.export_channel_backup(chan.channel_id) popup = QRDialog( title, data, diff --git a/electrum/gui/kivy/uix/dialogs/settings.py b/electrum/gui/kivy/uix/dialogs/settings.py index b9fe39b3a..c5fc9da4b 100644 --- a/electrum/gui/kivy/uix/dialogs/settings.py +++ b/electrum/gui/kivy/uix/dialogs/settings.py @@ -94,7 +94,7 @@ Builder.load_string(''' status: _('Yes') if (app.use_recoverable_channels and not self.disabled) else _('No') title: _('Create recoverable channels') + ': ' + self.status description: _("Add channel recovery data to funding transaction.") - message: _(messages.MSG_RECOVERABLE_CHANNELS) + message: messages.MSG_RECOVERABLE_CHANNELS action: partial(root.boolean_dialog, 'use_recoverable_channels', _('Create recoverable channels'), self.message) CardSeparator SettingsItem: @@ -175,7 +175,7 @@ class SettingsDialog(Factory.Popup): self._unit_dialog.open() def routing_dialog(self, item, dt): - description = _(messages.MSG_HELP_TRAMPOLINE) + description = messages.MSG_HELP_TRAMPOLINE def cb(text): self.app.use_gossip = (text == 'Gossip') dialog = ChoiceDialog( diff --git a/electrum/gui/messages.py b/electrum/gui/messages.py index d4edfc0f0..810aa7ffb 100644 --- a/electrum/gui/messages.py +++ b/electrum/gui/messages.py @@ -1,62 +1,70 @@ -# note: qt and kivy use different i18n methods -# FIXME all these messages *cannot* be localized currently! +from electrum.i18n import _ + +# note: kivy uses its own i18n methods in order to allow changing the language at runtime. +# These strings use electrum.i18n directly, to be GUI-agnostic, so the language for these +# cannot be changed at runtime. def to_rtf(msg): return '\n'.join(['
' + x + '
' for x in msg.split('\n\n')]) -MSG_RECOVERABLE_CHANNELS = """ -Add extra data to your channel funding transactions, so that a static backup can be recovered from your seed. + +MSG_RECOVERABLE_CHANNELS = _( +"""Add extra data to your channel funding transactions, so that a static backup can be recovered from your seed. Note that static backups only allow you to request a force-close with the remote node. This assumes that the remote node is still online, did not lose its data, and accepts to force close the channel. -If this is enabled, other nodes cannot open a channel to you. Channel recovery data is encrypted, so that only your wallet can decrypt it. However, blockchain analysis will be able to tell that the transaction was probably created by Electrum. -""" +If this is enabled, other nodes cannot open a channel to you. Channel recovery data is encrypted, so that only your wallet can decrypt it. However, blockchain analysis will be able to tell that the transaction was probably created by Electrum.""" +) -MSG_CONFIG_INSTANT_SWAPS = """ -If this option is checked, your client will complete reverse swaps before the funding transaction is confirmed. +MSG_CONFIG_INSTANT_SWAPS = _( +"""If this option is checked, your client will complete reverse swaps before the funding transaction is confirmed. -Note you are at risk of losing the funds in the swap, if the funding transaction never confirms. -""" +Note you are at risk of losing the funds in the swap, if the funding transaction never confirms.""" +) -MSG_COOPERATIVE_CLOSE = """ -Your node will negotiate the transaction fee with the remote node. This method of closing the channel usually results in the lowest fees.""" +MSG_COOPERATIVE_CLOSE = _( +"""Your node will negotiate the transaction fee with the remote node. This method of closing the channel usually results in the lowest fees.""" +) -MSG_REQUEST_FORCE_CLOSE = """ -If you request a force-close, your node will pretend that it has lost its data and ask the remote node to broadcast their latest state. Doing so from time to time helps make sure that nodes are honest, because your node can punish them if they broadcast a revoked state.""" +MSG_REQUEST_FORCE_CLOSE = _( +"""If you request a force-close, your node will pretend that it has lost its data and ask the remote node to broadcast their latest state. Doing so from time to time helps make sure that nodes are honest, because your node can punish them if they broadcast a revoked state.""" +) -MSG_CREATED_NON_RECOVERABLE_CHANNEL = """ -The channel you created is not recoverable from seed. +MSG_CREATED_NON_RECOVERABLE_CHANNEL = _( +"""The channel you created is not recoverable from seed. To prevent fund losses, please save this backup on another device. -It may be imported in another Electrum wallet with the same seed. -""" +It may be imported in another Electrum wallet with the same seed.""" +) -MSG_LIGHTNING_EXPERIMENTAL_WARNING = """ -Lightning support in Electrum is experimental. Do not put large amounts in lightning channels. -""" +MSG_LIGHTNING_EXPERIMENTAL_WARNING = _( +"""Lightning support in Electrum is experimental. Do not put large amounts in lightning channels.""" +) -MSG_LIGHTNING_SCB_WARNING = """ -Electrum uses static channel backups. If you lose your wallet file, you will need to request your channel to be force-closed by the remote peer in order to recover your funds. This assumes that the remote peer is reachable, and has not lost its own data. -""" +MSG_LIGHTNING_SCB_WARNING = _( +"""Electrum uses static channel backups. If you lose your wallet file, you will need to request your channel to be force-closed by the remote peer in order to recover your funds. This assumes that the remote peer is reachable, and has not lost its own data.""" +) MSG_LIGHTNING_WARNING = MSG_LIGHTNING_EXPERIMENTAL_WARNING + MSG_LIGHTNING_SCB_WARNING -MSG_HELP_TRAMPOLINE = """ -Lightning payments require finding a path through the Lightning Network. You may use trampoline routing, or local routing (gossip). +MSG_HELP_TRAMPOLINE = _( +"""Lightning payments require finding a path through the Lightning Network. You may use trampoline routing, or local routing (gossip). -Downloading the network gossip uses quite some bandwidth and storage, and is not recommended on mobile devices. If you use trampoline, you can only open channels with trampoline nodes. -""" +Downloading the network gossip uses quite some bandwidth and storage, and is not recommended on mobile devices. If you use trampoline, you can only open channels with trampoline nodes.""" +) -MGS_CONFLICTING_BACKUP_INSTANCE = """ -Another instance of this wallet (same seed) has an open channel with the same remote node. If you create this channel, you will not be able to use both wallets at the same time. +MGS_CONFLICTING_BACKUP_INSTANCE = _( +"""Another instance of this wallet (same seed) has an open channel with the same remote node. If you create this channel, you will not be able to use both wallets at the same time. -Are you sure? -""" +Are you sure?""" +) -MSG_CAPITAL_GAINS = """ -This summary covers only on-chain transactions (no lightning!). Capital gains are computed by attaching an acquisition price to each UTXO in the wallet, and uses the order of blockchain events (not FIFO). -""" +MSG_CAPITAL_GAINS = _( +"""This summary covers only on-chain transactions (no lightning!). Capital gains are computed by attaching an acquisition price to each UTXO in the wallet, and uses the order of blockchain events (not FIFO).""" +) -MSG_NON_TRAMPOLINE_CHANNEL_FROZEN_WITHOUT_GOSSIP = """Trampoline routing is enabled, but this channel is with a non-trampoline node. +MSG_NON_TRAMPOLINE_CHANNEL_FROZEN_WITHOUT_GOSSIP = _( +"""Trampoline routing is enabled, but this channel is with a non-trampoline node. This channel may still be used for receiving, but it is frozen for sending. If you want to keep using this channel, you need to disable trampoline routing in your preferences.""" +) diff --git a/electrum/gui/qml/qechanneldetails.py b/electrum/gui/qml/qechanneldetails.py index 8340e2619..233a67731 100644 --- a/electrum/gui/qml/qechanneldetails.py +++ b/electrum/gui/qml/qechanneldetails.py @@ -172,7 +172,7 @@ class QEChannelDetails(QObject, QtEventListener): @pyqtProperty(str, notify=channelChanged) def messageForceClose(self, notify=channelChanged): - return _(messages.MSG_REQUEST_FORCE_CLOSE).strip() + return messages.MSG_REQUEST_FORCE_CLOSE.strip() @pyqtProperty(bool, notify=channelChanged) def isBackup(self): diff --git a/electrum/gui/qml/qechannelopener.py b/electrum/gui/qml/qechannelopener.py index 08d855764..833930ced 100644 --- a/electrum/gui/qml/qechannelopener.py +++ b/electrum/gui/qml/qechannelopener.py @@ -224,7 +224,7 @@ class QEChannelOpener(QObject, AuthMixin): #self.maybe_show_funding_tx(chan, funding_tx) #else: #title = _('Save backup') - #help_text = _(messages.MSG_CREATED_NON_RECOVERABLE_CHANNEL) + #help_text = messages.MSG_CREATED_NON_RECOVERABLE_CHANNEL #data = lnworker.export_channel_backup(chan.channel_id) #popup = QRDialog( #title, data, diff --git a/electrum/gui/qt/channels_list.py b/electrum/gui/qt/channels_list.py index e3fc3d416..acfc6523f 100644 --- a/electrum/gui/qt/channels_list.py +++ b/electrum/gui/qt/channels_list.py @@ -130,7 +130,7 @@ class ChannelsList(MyTreeView): def close_channel(self, channel_id): self.is_force_close = False msg = _('Cooperative close?') - msg += '\n' + _(messages.MSG_COOPERATIVE_CLOSE) + msg += '\n' + messages.MSG_COOPERATIVE_CLOSE if not self.main_window.question(msg): return coro = self.lnworker.close_channel(channel_id) @@ -185,7 +185,7 @@ class ChannelsList(MyTreeView): def request_force_close(self, channel_id): msg = _('Request force-close from remote peer?') - msg += '\n' + _(messages.MSG_REQUEST_FORCE_CLOSE) + msg += '\n' + messages.MSG_REQUEST_FORCE_CLOSE if not self.main_window.question(msg): return def task(): diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index a67420ce2..683944622 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -1275,7 +1275,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): lnworker = self.wallet.lnworker if not chan.has_onchain_backup(): data = lnworker.export_channel_backup(chan.channel_id) - help_text = _(messages.MSG_CREATED_NON_RECOVERABLE_CHANNEL) + help_text = messages.MSG_CREATED_NON_RECOVERABLE_CHANNEL help_text += '\n\n' + _('Alternatively, you can save a backup of your wallet file from the File menu') self.show_qrcode( data, _('Save channel backup'), @@ -1697,7 +1697,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): return lnworker = self.wallet.lnworker if not lnworker.channels and not lnworker.channel_backups: - msg = _('Do you want to create your first channel?') + '\n\n' + _(messages.MSG_LIGHTNING_WARNING) + msg = _('Do you want to create your first channel?') + '\n\n' + messages.MSG_LIGHTNING_WARNING if not self.question(msg): return d = NewChannelDialog(self, amount_sat, min_amount_sat) diff --git a/electrum/gui/qt/new_channel_dialog.py b/electrum/gui/qt/new_channel_dialog.py index 6eaf95fbe..36b589026 100644 --- a/electrum/gui/qt/new_channel_dialog.py +++ b/electrum/gui/qt/new_channel_dialog.py @@ -35,7 +35,7 @@ class NewChannelDialog(WindowModalDialog): self.min_amount_sat = min_amount_sat or MIN_FUNDING_SAT vbox = QVBoxLayout(self) toolbar, menu = create_toolbar_with_menu(self.config, '') - recov_tooltip = messages.to_rtf(_(messages.MSG_RECOVERABLE_CHANNELS)) + recov_tooltip = messages.to_rtf(messages.MSG_RECOVERABLE_CHANNELS) menu.addConfig( _("Create recoverable channels"), 'use_recoverable_channels', True, tooltip=recov_tooltip, diff --git a/electrum/gui/qt/settings_dialog.py b/electrum/gui/qt/settings_dialog.py index 6c4950a7b..4fa16734f 100644 --- a/electrum/gui/qt/settings_dialog.py +++ b/electrum/gui/qt/settings_dialog.py @@ -105,7 +105,7 @@ class SettingsDialog(QDialog, QtEventListener): nz.valueChanged.connect(on_nz) # lightning - help_trampoline = _(messages.MSG_HELP_TRAMPOLINE) + help_trampoline = messages.MSG_HELP_TRAMPOLINE trampoline_cb = QCheckBox(_("Use trampoline routing")) trampoline_cb.setToolTip(messages.to_rtf(help_trampoline)) trampoline_cb.setChecked(not bool(self.config.get('use_gossip', False)))