i18n phases 1+2: BAL translation layer and translatable texts
Phase 1: new bal/i18n.py, BAL's own gettext layer (domain "bal", catalogs read with plugin.read_file()). _() asks Electrum's catalog first, then BAL's, then returns the English source. The Qt plugin loads the catalog of Electrum's GUI language at start-up; the CLI stays English. Phase 2: every user-visible GUI text is now a whole, extractable sentence (Ruff INT rules enabled). Class-level texts are marked with N_() and translated when shown. Stored data stays language-neutral: the status history is written in English and translated for display, the calendar defaults follow the GUI language, and the history label and wallet labels are never translated because BAL uses them to recognise its transactions. No visible change apart from the double colon fixed in the will detail. See CHANGELOG entries 58 and 59 and PLAN_I18N.md.
This commit is contained in:
@@ -26,6 +26,7 @@ from ...core.checkalive import (
|
||||
resolve_guard_threshold,
|
||||
)
|
||||
from .common import (
|
||||
N_,
|
||||
OP_RETURN_PREFIX,
|
||||
AmountException,
|
||||
BalPlugin,
|
||||
@@ -282,12 +283,12 @@ class BalWindow:
|
||||
|
||||
def new_heir_dialog(self, heir_key=None):
|
||||
heir = self.heirs.get(heir_key)
|
||||
title = "New heir"
|
||||
title = _("New heir")
|
||||
if heir:
|
||||
title = f"Edit: {heir_key}"
|
||||
title = _("Edit: {}").format(heir_key)
|
||||
|
||||
d = BalDialog(
|
||||
self.window, self.bal_plugin, self.bal_plugin.get_window_title(_(title))
|
||||
self.window, self.bal_plugin, self.bal_plugin.get_window_title(title)
|
||||
)
|
||||
|
||||
vbox = QVBoxLayout(d)
|
||||
@@ -828,12 +829,12 @@ class BalWindow:
|
||||
except AmountException as e:
|
||||
self.show_warning(
|
||||
_(
|
||||
f"In the inheritance process, the entire wallet will always be fully emptied. Your settings require an adjustment of the amounts.{e}"
|
||||
)
|
||||
"In the inheritance process, the entire wallet will always be fully emptied. Your settings require an adjustment of the amounts.{}"
|
||||
).format(e)
|
||||
)
|
||||
except WillExecutorFeeTooHighException as e:
|
||||
self.show_error(
|
||||
_(f"Will-executor fee too high: {e}")
|
||||
_("Will-executor fee too high: {}").format(e)
|
||||
)
|
||||
return
|
||||
except CheckAliveError:
|
||||
@@ -919,27 +920,27 @@ class BalWindow:
|
||||
_logger.info("{}:{}".format(type(e), e))
|
||||
message = False
|
||||
if isinstance(e, HeirChangeException):
|
||||
message = "Heirs changed:"
|
||||
message = _("Heirs changed:")
|
||||
elif isinstance(e, WillExecutorNotPresent):
|
||||
message = "Will-Executor not present:"
|
||||
message = _("Will-Executor not present:")
|
||||
elif isinstance(e, WillexecutorChangeException):
|
||||
message = "Will-Executor changed"
|
||||
message = _("Will-Executor changed")
|
||||
elif isinstance(e, TxFeesChangedException):
|
||||
message = "Txfees are changed"
|
||||
message = _("Txfees are changed")
|
||||
elif isinstance(e, HeirNotFoundException):
|
||||
# Task #01b: replace the misleading "Heir not found" text.
|
||||
# This branch is most often hit because the delivery date
|
||||
# was anticipated, not because an heir is missing, so we use
|
||||
# a clear message that covers both the DATE and the HEIRS
|
||||
# cases (kept consistent with dialogs.py / the CHECK window).
|
||||
message = (
|
||||
message = _(
|
||||
"Found CHANGES to the DATE or the HEIRS,\n"
|
||||
"a NEW WILL must be prepared."
|
||||
)
|
||||
|
||||
if message:
|
||||
self.show_message(
|
||||
f"{_(message)}:\n {e}\n{_('will have to be built')}"
|
||||
"{}:\n {}\n{}".format(message, e, _("will have to be built"))
|
||||
)
|
||||
|
||||
_logger.info("build will")
|
||||
@@ -959,7 +960,7 @@ class BalWindow:
|
||||
self.invalidate_will()
|
||||
except NotCompleteWillException as e:
|
||||
self.show_error(
|
||||
"Error:{}\n {}".format(
|
||||
_("Error:{}\n {}").format(
|
||||
str(e),
|
||||
_("Please, check your heirs, locktime and threshold!"),
|
||||
)
|
||||
@@ -1019,7 +1020,9 @@ class BalWindow:
|
||||
except SerializationError as e:
|
||||
_logger.error("unable to deserialize the transaction")
|
||||
parent.show_critical(
|
||||
_("Electrum was unable to deserialize the transaction:") + "\n" + str(e)
|
||||
"{}\n{}".format(
|
||||
_("Electrum was unable to deserialize the transaction:"), e
|
||||
)
|
||||
)
|
||||
else:
|
||||
# Electrum's own TxDialog: keep it in front of the main window.
|
||||
@@ -1087,8 +1090,8 @@ class BalWindow:
|
||||
def get_message():
|
||||
msg = ""
|
||||
if signed:
|
||||
msg = _(f"signed: {signed}\n")
|
||||
return msg + _(f"signing: {tosign}")
|
||||
msg = _("signed: {}").format(signed) + "\n"
|
||||
return msg + _("signing: {}").format(tosign)
|
||||
|
||||
if txids is not None:
|
||||
targets = [
|
||||
@@ -1610,7 +1613,7 @@ class BalWindow:
|
||||
willexecutors = Willexecutors.get_willexecutor_transactions(willitems, force=force)
|
||||
|
||||
def getMsg(willexecutors):
|
||||
msg = "Broadcasting Transactions to Will-Executors:\n"
|
||||
msg = _("Broadcasting Transactions to Will-Executors:") + "\n"
|
||||
for url in willexecutors:
|
||||
msg += f"{url}:\t{willexecutors[url]['broadcast_status']}\n"
|
||||
return msg
|
||||
@@ -1664,8 +1667,8 @@ class BalWindow:
|
||||
if self.waiting_dialog._stopping:
|
||||
return
|
||||
self.waiting_dialog.update(
|
||||
"checking {} - {} : {}".format(
|
||||
willitems[wid].we["url"], wid, "Waiting"
|
||||
_("checking {} - {} : {}").format(
|
||||
willitems[wid].we["url"], wid, _("Waiting")
|
||||
)
|
||||
)
|
||||
w = willitems[wid]
|
||||
@@ -1673,7 +1676,7 @@ class BalWindow:
|
||||
Willexecutors.check_transaction(wid, w.we["url"])
|
||||
)
|
||||
self.waiting_dialog.update(
|
||||
"checked {} - {} : {}".format(
|
||||
_("checked {} - {} : {}").format(
|
||||
willitems[wid].we["url"],
|
||||
wid,
|
||||
willitems[wid].get_status("CHECKED"),
|
||||
@@ -2142,7 +2145,7 @@ class BalWindow:
|
||||
|
||||
# Simple, user-facing message shown when the download fails for any reason
|
||||
# (the technical cause is in the Electrum log).
|
||||
DOWNLOAD_FAILED_MESSAGE = (
|
||||
DOWNLOAD_FAILED_MESSAGE = N_(
|
||||
"Could not download the will-executors list.\n\n"
|
||||
"This is usually caused by your internet connection or a firewall, "
|
||||
"not by the plugin. Please check your connection (a VPN often helps) "
|
||||
@@ -2152,7 +2155,7 @@ class BalWindow:
|
||||
# Shown when the download fails while Electrum is connected through Tor:
|
||||
# the most common cause is a slow Tor connection, so guide the user
|
||||
# accordingly instead of the generic message above.
|
||||
DOWNLOAD_FAILED_TOR_MESSAGE = (
|
||||
DOWNLOAD_FAILED_TOR_MESSAGE = N_(
|
||||
"Could not download the will-executors list over Tor.\n\n"
|
||||
"Electrum is connected through Tor and the connection is taking too "
|
||||
"long. Your Tor connection may be slow. Please try again, or use a VPN "
|
||||
@@ -2225,27 +2228,27 @@ class BalWindow:
|
||||
if err.url and err.reason == "empty response":
|
||||
# Server reached but returned no data for this chain.
|
||||
self.show_warning(_(
|
||||
f"No active will-executor servers found for the "
|
||||
f"{err.chain} network.\n\n"
|
||||
f"The welist server at {err.url} responded but "
|
||||
f"returned no will-executors for this chain."
|
||||
))
|
||||
"No active will-executor servers found for the "
|
||||
"{chain} network.\n\n"
|
||||
"The welist server at {url} responded but "
|
||||
"returned no will-executors for this chain."
|
||||
).format(chain=err.chain, url=err.url))
|
||||
elif err.url:
|
||||
# Advanced mode with a non-empty error (network issue).
|
||||
self.show_warning(_(
|
||||
f"Could not reach the configured welist server.\n\n"
|
||||
f"Server: {err.url}\n"
|
||||
f"Error: {err.reason}\n\n"
|
||||
f"Please verify the welist server URL in the plugin "
|
||||
f"settings."
|
||||
))
|
||||
"Could not reach the configured welist server.\n\n"
|
||||
"Server: {url}\n"
|
||||
"Error: {reason}\n\n"
|
||||
"Please verify the welist server URL in the plugin "
|
||||
"settings."
|
||||
).format(url=err.url, reason=err.reason))
|
||||
else:
|
||||
# Basic mode: the server responded but has no data for this
|
||||
# chain.
|
||||
self.show_warning(_(
|
||||
f"No active will-executor found for the "
|
||||
f"{err.chain} network."
|
||||
))
|
||||
"No active will-executor found for the "
|
||||
"{chain} network."
|
||||
).format(chain=err.chain))
|
||||
else:
|
||||
# Tor-aware: a generic failure/timeout while on Tor is most
|
||||
# likely a slow Tor connection.
|
||||
|
||||
Reference in New Issue
Block a user