i18n: translate a few untranslated strings and avoid early translate for pr_tooltips and pr_expiration_values
fixes #8689
This commit is contained in:
@@ -12,8 +12,7 @@ from PyQt5.QtWidgets import (QComboBox, QLabel, QVBoxLayout, QGridLayout, QLineE
|
||||
from electrum.bitcoin import is_address
|
||||
from electrum.i18n import _
|
||||
from electrum.util import InvoiceError
|
||||
from electrum.invoices import PR_DEFAULT_EXPIRATION_WHEN_CREATING
|
||||
from electrum.invoices import PR_EXPIRED, pr_expiration_values
|
||||
from electrum.invoices import pr_expiration_values
|
||||
from electrum.logging import Logger
|
||||
|
||||
from .amountedit import AmountEdit, BTCAmountEdit, SizedFreezableLineEdit
|
||||
@@ -177,7 +176,7 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
|
||||
|
||||
def update_expiry_text(self):
|
||||
expiry = self.config.WALLET_PAYREQ_EXPIRY_SECONDS
|
||||
text = pr_expiration_values[expiry]
|
||||
text = pr_expiration_values()[expiry]
|
||||
self.expiry_button.setText(text)
|
||||
|
||||
def expiry_dialog(self):
|
||||
@@ -192,7 +191,7 @@ class ReceiveTab(QWidget, MessageBoxMixin, Logger):
|
||||
_('For Lightning requests, payments will not be accepted after the expiration.'),
|
||||
])
|
||||
expiry = self.config.WALLET_PAYREQ_EXPIRY_SECONDS
|
||||
v = self.window.query_choice(msg, pr_expiration_values, title=_('Expiry'), default_choice=expiry)
|
||||
v = self.window.query_choice(msg, pr_expiration_values(), title=_('Expiry'), default_choice=expiry)
|
||||
if v is None:
|
||||
return
|
||||
self.config.WALLET_PAYREQ_EXPIRY_SECONDS = v
|
||||
|
||||
@@ -46,28 +46,34 @@ pr_color = {
|
||||
PR_UNCONFIRMED: (.9, .6, .3, 1),
|
||||
}
|
||||
|
||||
pr_tooltips = {
|
||||
PR_UNPAID:_('Unpaid'),
|
||||
PR_PAID:_('Paid'),
|
||||
PR_UNKNOWN:_('Unknown'),
|
||||
PR_EXPIRED:_('Expired'),
|
||||
PR_INFLIGHT:_('In progress'),
|
||||
PR_BROADCASTING:_('Broadcasting'),
|
||||
PR_BROADCAST:_('Broadcast successfully'),
|
||||
PR_FAILED:_('Failed'),
|
||||
PR_ROUTING: _('Computing route...'),
|
||||
PR_UNCONFIRMED: _('Unconfirmed'),
|
||||
}
|
||||
|
||||
def pr_tooltips():
|
||||
return {
|
||||
PR_UNPAID: _('Unpaid'),
|
||||
PR_PAID: _('Paid'),
|
||||
PR_UNKNOWN: _('Unknown'),
|
||||
PR_EXPIRED: _('Expired'),
|
||||
PR_INFLIGHT: _('In progress'),
|
||||
PR_BROADCASTING: _('Broadcasting'),
|
||||
PR_BROADCAST: _('Broadcast successfully'),
|
||||
PR_FAILED: _('Failed'),
|
||||
PR_ROUTING: _('Computing route...'),
|
||||
PR_UNCONFIRMED: _('Unconfirmed'),
|
||||
}
|
||||
|
||||
|
||||
def pr_expiration_values():
|
||||
return {
|
||||
0: _('Never'),
|
||||
10*60: _('10 minutes'),
|
||||
60*60: _('1 hour'),
|
||||
24*60*60: _('1 day'),
|
||||
7*24*60*60: _('1 week'),
|
||||
}
|
||||
|
||||
|
||||
PR_DEFAULT_EXPIRATION_WHEN_CREATING = 24*60*60 # 1 day
|
||||
pr_expiration_values = {
|
||||
0: _('Never'),
|
||||
10*60: _('10 minutes'),
|
||||
60*60: _('1 hour'),
|
||||
24*60*60: _('1 day'),
|
||||
7*24*60*60: _('1 week'),
|
||||
}
|
||||
assert PR_DEFAULT_EXPIRATION_WHEN_CREATING in pr_expiration_values
|
||||
assert PR_DEFAULT_EXPIRATION_WHEN_CREATING in pr_expiration_values()
|
||||
|
||||
|
||||
def _decode_outputs(outputs) -> Optional[List[PartialTxOutput]]:
|
||||
@@ -88,7 +94,6 @@ def _decode_outputs(outputs) -> Optional[List[PartialTxOutput]]:
|
||||
LN_EXPIRY_NEVER = 100 * 365 * 24 * 60 * 60 # 100 years
|
||||
|
||||
|
||||
|
||||
@attr.s
|
||||
class BaseInvoice(StoredObject):
|
||||
"""
|
||||
@@ -118,7 +123,6 @@ class BaseInvoice(StoredObject):
|
||||
bip70 = attr.ib(type=str, kw_only=True) # type: Optional[str]
|
||||
#bip70_requestor = attr.ib(type=str, kw_only=True) # type: Optional[str]
|
||||
|
||||
|
||||
def is_lightning(self) -> bool:
|
||||
raise NotImplementedError()
|
||||
|
||||
@@ -131,7 +135,7 @@ class BaseInvoice(StoredObject):
|
||||
raise NotImplementedError()
|
||||
|
||||
def get_status_str(self, status):
|
||||
status_str = pr_tooltips[status]
|
||||
status_str = pr_tooltips()[status]
|
||||
if status == PR_UNPAID:
|
||||
if self.exp > 0 and self.exp != LN_EXPIRY_NEVER:
|
||||
expiration = self.get_expiration_date()
|
||||
|
||||
@@ -3010,20 +3010,23 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
short_warning = None
|
||||
allow_send = True
|
||||
if feerate < self.relayfee() / 1000:
|
||||
long_warning = (
|
||||
_("This transaction requires a higher fee, or it will not be propagated by your current server.") + " "
|
||||
+ _("Try to raise your transaction fee, or use a server with a lower relay fee."))
|
||||
long_warning = ' '.join([
|
||||
_("This transaction requires a higher fee, or it will not be propagated by your current server."),
|
||||
_("Try to raise your transaction fee, or use a server with a lower relay fee.")
|
||||
])
|
||||
short_warning = _("below relay fee") + "!"
|
||||
allow_send = False
|
||||
elif fee_ratio >= FEE_RATIO_HIGH_WARNING:
|
||||
long_warning = (
|
||||
_("The fee for this transaction seems unusually high.")
|
||||
+ f' ({fee_ratio*100:.2f}% of amount)')
|
||||
long_warning = ' '.join([
|
||||
_("The fee for this transaction seems unusually high."),
|
||||
_("({}% of amount)").format(f'{fee_ratio*100:.2f}')
|
||||
])
|
||||
short_warning = _("high fee ratio") + "!"
|
||||
elif feerate > FEERATE_WARNING_HIGH_FEE / 1000:
|
||||
long_warning = (
|
||||
_("The fee for this transaction seems unusually high.")
|
||||
+ f' (feerate: {feerate:.2f} sat/byte)')
|
||||
long_warning = ' '.join([
|
||||
_("The fee for this transaction seems unusually high."),
|
||||
_("(feerate: {} sat/byte)").format(f'{feerate:.2f}')
|
||||
])
|
||||
short_warning = _("high fee rate") + "!"
|
||||
if long_warning is None:
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user