mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
wallet: Translate [default wallet] string in progress messages
Noticed while reviewing #31287 (https://github.com/bitcoin/bitcoin/pull/31287#discussion_r1843809721) that the [default wallet] part of progress messages remains untranslated while the rest of the string is translated. Fix this in all places where Wallet::ShowProgress (which has a cancel button) and chain::showProgress (which doesn't have a cancel button) are called by making "default wallet" into a translated string. To minimize scope of this bugfix, this introduces a new wallet DisplayName() method which behaves differently than the existing GetDisplayName() method. The existing method will be cleaned up in the following commit.
This commit is contained in:
parent
712cab3a8f
commit
370abf849b
3 changed files with 11 additions and 4 deletions
|
@ -534,7 +534,7 @@ RPCHelpMan importwallet()
|
|||
|
||||
// Use uiInterface.ShowProgress instead of pwallet.ShowProgress because pwallet.ShowProgress has a cancel button tied to AbortRescan which
|
||||
// we don't want for this progress bar showing the import progress. uiInterface.ShowProgress does not have a cancel button.
|
||||
pwallet->chain().showProgress(strprintf("%s %s", pwallet->GetDisplayName(), _("Importing…")), 0, false); // show progress dialog in GUI
|
||||
pwallet->chain().showProgress(strprintf("[%s] %s", pwallet->DisplayName(), _("Importing…")), 0, false); // show progress dialog in GUI
|
||||
std::vector<std::tuple<CKey, int64_t, bool, std::string>> keys;
|
||||
std::vector<std::pair<CScript, int64_t>> scripts;
|
||||
while (file.good()) {
|
||||
|
|
|
@ -1903,7 +1903,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
|||
fast_rescan_filter ? "fast variant using block filters" : "slow variant inspecting all blocks");
|
||||
|
||||
fAbortRescan = false;
|
||||
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
|
||||
ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), 0); // show rescan progress in GUI as dialog or on splashscreen, if rescan required on startup (e.g. due to corruption)
|
||||
uint256 tip_hash = WITH_LOCK(cs_wallet, return GetLastBlockHash());
|
||||
uint256 end_hash = tip_hash;
|
||||
if (max_height) chain().findAncestorByHeight(tip_hash, *max_height, FoundBlock().hash(end_hash));
|
||||
|
@ -1918,7 +1918,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
|||
m_scanning_progress = 0;
|
||||
}
|
||||
if (block_height % 100 == 0 && progress_end - progress_begin > 0.0) {
|
||||
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
|
||||
ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
|
||||
}
|
||||
|
||||
bool next_interval = reserver.now() >= current_time + INTERVAL_TIME;
|
||||
|
@ -2015,7 +2015,7 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
|
|||
WalletLogPrintf("Scanning current mempool transactions.\n");
|
||||
WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this));
|
||||
}
|
||||
ShowProgress(strprintf("%s %s", GetDisplayName(), _("Rescanning…")), 100); // hide progress dialog in GUI
|
||||
ShowProgress(strprintf("[%s] %s", DisplayName(), _("Rescanning…")), 100); // hide progress dialog in GUI
|
||||
if (block_height && fAbortRescan) {
|
||||
WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", block_height, progress_current);
|
||||
result.status = ScanResult::USER_ABORT;
|
||||
|
|
|
@ -929,6 +929,13 @@ public:
|
|||
return strprintf("[%s]", wallet_name);
|
||||
};
|
||||
|
||||
/** Return wallet name for display, translating "default wallet" string if returned. */
|
||||
std::string DisplayName() const
|
||||
{
|
||||
std::string name{GetName()};
|
||||
return name.empty() ? _("default wallet") : name;
|
||||
};
|
||||
|
||||
/** Prepends the wallet name in logging output to ease debugging in multi-wallet use cases */
|
||||
template <typename... Params>
|
||||
void WalletLogPrintf(util::ConstevalFormatString<sizeof...(Params)> wallet_fmt, const Params&... params) const
|
||||
|
|
Loading…
Add table
Reference in a new issue