From c25b66812591365a76a76a23b548136ae7b2ed30 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Thu, 24 Mar 2022 09:43:51 +0530 Subject: [PATCH 01/12] merge bitcoin#16362: Add bilingual_str type --- src/Makefile.am | 1 + src/banman.cpp | 3 +- src/coinjoin/client.cpp | 67 +++++------ src/coinjoin/coinjoin.cpp | 45 ++++---- src/dash-cli.cpp | 4 +- src/dash-tx.cpp | 4 +- src/dash-wallet.cpp | 3 +- src/dashd.cpp | 2 + src/httprpc.cpp | 9 +- src/index/txindex.cpp | 5 +- src/init.cpp | 187 ++++++++++++++++--------------- src/masternode/sync.cpp | 7 +- src/net.cpp | 19 ++-- src/net_permissions.cpp | 9 +- src/qt/dash.cpp | 3 +- src/qt/main.cpp | 2 + src/qt/splashscreen.cpp | 5 +- src/test/util/setup_common.cpp | 1 + src/timedata.cpp | 3 +- src/txdb.cpp | 7 +- src/util/error.cpp | 6 +- src/util/system.cpp | 5 +- src/util/system.h | 12 -- src/util/translation.h | 42 +++++++ src/validation.cpp | 25 +++-- src/wallet/bdb.cpp | 5 +- src/wallet/init.cpp | 29 ++--- src/wallet/load.cpp | 11 +- src/wallet/rpcdump.cpp | 7 +- src/wallet/wallet.cpp | 119 ++++++++++---------- src/warnings.cpp | 10 +- test/lint/lint-format-strings.py | 2 +- 32 files changed, 362 insertions(+), 297 deletions(-) create mode 100644 src/util/translation.h diff --git a/src/Makefile.am b/src/Makefile.am index 9e5fa6cc56..eb84734abb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -311,6 +311,7 @@ BITCOIN_CORE_H = \ util/string.h \ util/time.h \ util/threadnames.h \ + util/translation.h \ util/vector.h \ util/url.h \ util/validation.h \ diff --git a/src/banman.cpp b/src/banman.cpp index 2445cb0963..a9ff1e39aa 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -9,12 +9,13 @@ #include #include #include +#include BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time) : m_client_interface(client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time) { - if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist...")); + if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist...").translated); int64_t n_start = GetTimeMillis(); m_is_dirty = false; diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index 2686ea6e34..6b8f426f05 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -309,7 +310,7 @@ std::string CCoinJoinClientSession::GetStatus(bool fWaitForBlock) const switch (nState) { case POOL_STATE_IDLE: - return strprintf(_("%s is idle."), gCoinJoinName); + return strprintf(_("%s is idle.").translated, gCoinJoinName); case POOL_STATE_QUEUE: if (nStatusMessageProgress % 70 <= 30) strSuffix = "."; @@ -317,23 +318,23 @@ std::string CCoinJoinClientSession::GetStatus(bool fWaitForBlock) const strSuffix = ".."; else strSuffix = "..."; - return strprintf(_("Submitted to masternode, waiting in queue %s"), strSuffix); + return strprintf(_("Submitted to masternode, waiting in queue %s").translated, strSuffix); case POOL_STATE_ACCEPTING_ENTRIES: return strAutoDenomResult; case POOL_STATE_SIGNING: if (nStatusMessageProgress % 70 <= 40) - return _("Found enough users, signing ..."); + return _("Found enough users, signing ...").translated; else if (nStatusMessageProgress % 70 <= 50) strSuffix = "."; else if (nStatusMessageProgress % 70 <= 60) strSuffix = ".."; else strSuffix = "..."; - return strprintf(_("Found enough users, signing ( waiting %s )"), strSuffix); + return strprintf(_("Found enough users, signing ( waiting %s )").translated, strSuffix); case POOL_STATE_ERROR: - return strprintf(_("%s request incomplete: %s"), gCoinJoinName, strLastMessage) + " " + _("Will retry..."); + return strprintf(_("%s request incomplete: %s").translated, gCoinJoinName, strLastMessage) + " " + _("Will retry...").translated; default: - return strprintf(_("Unknown state: id = %u"), nState); + return strprintf(_("Unknown state: id = %u").translated, nState); } } @@ -427,7 +428,7 @@ void CCoinJoinClientManager::CheckTimeout() LOCK(cs_deqsessions); for (auto& session : deqSessions) { if (session.CheckTimeout()) { - strAutoDenomResult = _("Session timed out."); + strAutoDenomResult = _("Session timed out.").translated; } } } @@ -511,7 +512,7 @@ void CCoinJoinClientSession::ProcessPoolStateUpdate(CCoinJoinStatusUpdate psssup } std::string strMessageTmp = CCoinJoin::GetMessageByID(psssup.nMessageID); - strAutoDenomResult = _("Masternode:") + " " + strMessageTmp; + strAutoDenomResult = _("Masternode:").translated + " " + strMessageTmp; switch (psssup.nStatusUpdate) { case STATUS_REJECTED: { @@ -699,7 +700,7 @@ bool CCoinJoinClientManager::CheckAutomaticBackup() switch (nWalletBackups) { case 0: LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- Automatic backups disabled, no mixing available.\n"); - strAutoDenomResult = _("Automatic backups disabled") + ", " + _("no mixing available."); + strAutoDenomResult = _("Automatic backups disabled").translated + ", " + _("no mixing available.").translated; StopMixing(); mixingWallet.nKeysLeftSinceAutoBackup = 0; // no backup, no "keys since last backup" return false; @@ -708,28 +709,28 @@ bool CCoinJoinClientManager::CheckAutomaticBackup() // There is no way to bring user attention in daemon mode, so we just update status and // keep spamming if debug is on. LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- ERROR! Failed to create automatic backup.\n"); - strAutoDenomResult = _("ERROR! Failed to create automatic backup") + ", " + _("see debug.log for details."); + strAutoDenomResult = _("ERROR! Failed to create automatic backup").translated + ", " + _("see debug.log for details.").translated; return false; case -2: // We were able to create automatic backup but keypool was not replenished because wallet is locked. // There is no way to bring user attention in daemon mode, so we just update status and // keep spamming if debug is on. LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- WARNING! Failed to create replenish keypool, please unlock your wallet to do so.\n"); - strAutoDenomResult = _("WARNING! Failed to replenish keypool, please unlock your wallet to do so.") + ", " + _("see debug.log for details."); + strAutoDenomResult = _("WARNING! Failed to replenish keypool, please unlock your wallet to do so.").translated + ", " + _("see debug.log for details.").translated; return false; } if (mixingWallet.nKeysLeftSinceAutoBackup < COINJOIN_KEYS_THRESHOLD_STOP) { // We should never get here via mixing itself but probably something else is still actively using keypool LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- Very low number of keys left: %d, no mixing available.\n", mixingWallet.nKeysLeftSinceAutoBackup); - strAutoDenomResult = strprintf(_("Very low number of keys left: %d") + ", " + _("no mixing available."), mixingWallet.nKeysLeftSinceAutoBackup); + strAutoDenomResult = strprintf(_("Very low number of keys left: %d").translated + ", " + _("no mixing available.").translated, mixingWallet.nKeysLeftSinceAutoBackup); // It's getting really dangerous, stop mixing StopMixing(); return false; } else if (mixingWallet.nKeysLeftSinceAutoBackup < COINJOIN_KEYS_THRESHOLD_WARNING) { // Low number of keys left, but it's still more or less safe to continue LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- Very low number of keys left: %d\n", mixingWallet.nKeysLeftSinceAutoBackup); - strAutoDenomResult = strprintf(_("Very low number of keys left: %d"), mixingWallet.nKeysLeftSinceAutoBackup); + strAutoDenomResult = strprintf(_("Very low number of keys left: %d").translated, mixingWallet.nKeysLeftSinceAutoBackup); if (fCreateAutoBackups) { LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- Trying to create new backup.\n"); @@ -744,7 +745,7 @@ bool CCoinJoinClientManager::CheckAutomaticBackup() if (!errorString.empty()) { // Things are really broken LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::CheckAutomaticBackup -- ERROR! Failed to create automatic backup: %s\n", errorString); - strAutoDenomResult = strprintf(_("ERROR! Failed to create automatic backup") + ": %s", errorString); + strAutoDenomResult = strprintf(_("ERROR! Failed to create automatic backup").translated + ": %s", errorString); return false; } } @@ -768,7 +769,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr if (nState != POOL_STATE_IDLE) return false; if (!masternodeSync.IsBlockchainSynced()) { - strAutoDenomResult = _("Can't mix while sync in progress."); + strAutoDenomResult = _("Can't mix while sync in progress.").translated; return false; } @@ -780,25 +781,25 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr LOCK2(cs_main, mixingWallet.cs_wallet); if (!fDryRun && mixingWallet.IsLocked(true)) { - strAutoDenomResult = _("Wallet is locked."); + strAutoDenomResult = _("Wallet is locked.").translated; return false; } if (GetEntriesCount() > 0) { - strAutoDenomResult = _("Mixing in progress..."); + strAutoDenomResult = _("Mixing in progress...").translated; return false; } TRY_LOCK(cs_coinjoin, lockDS); if (!lockDS) { - strAutoDenomResult = _("Lock is already in place."); + strAutoDenomResult = _("Lock is already in place.").translated; return false; } if (deterministicMNManager->GetListAtChainTip().GetValidMNsCount() == 0 && Params().NetworkIDString() != CBaseChainParams::REGTEST) { LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- No Masternodes detected\n"); - strAutoDenomResult = _("No Masternodes detected."); + strAutoDenomResult = _("No Masternodes detected.").translated; return false; } @@ -828,7 +829,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr // mixable balance is way too small if (nBalanceAnonymizable < nValueMin) { LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- Not enough funds to mix\n"); - strAutoDenomResult = _("Not enough funds to mix."); + strAutoDenomResult = _("Not enough funds to mix.").translated; return false; } @@ -890,7 +891,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr } if (nSessionID) { - strAutoDenomResult = _("Mixing in progress..."); + strAutoDenomResult = _("Mixing in progress...").translated; return false; } @@ -903,7 +904,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr // should be no unconfirmed denoms in non-multi-session mode if (!CCoinJoinClientOptions::IsMultiSessionEnabled() && nBalanceDenominatedUnconf > 0) { LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::DoAutomaticDenominating -- Found unconfirmed denominated outputs, will wait till they confirm to continue.\n"); - strAutoDenomResult = _("Found unconfirmed denominated outputs, will wait till they confirm to continue."); + strAutoDenomResult = _("Found unconfirmed denominated outputs, will wait till they confirm to continue.").translated; return false; } @@ -938,7 +939,7 @@ bool CCoinJoinClientSession::DoAutomaticDenominating(CConnman& connman, bool fDr // If we were unable to find/join an existing queue then start a new one. if (StartNewQueue(nBalanceNeedsAnonymized, connman)) return true; - strAutoDenomResult = _("No compatible Masternode found."); + strAutoDenomResult = _("No compatible Masternode found.").translated; return false; } @@ -948,12 +949,12 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(CConnman& connman, bool fDr if (!CCoinJoinClientOptions::IsEnabled() || !IsMixing()) return false; if (!masternodeSync.IsBlockchainSynced()) { - strAutoDenomResult = _("Can't mix while sync in progress."); + strAutoDenomResult = _("Can't mix while sync in progress.").translated; return false; } if (!fDryRun && mixingWallet.IsLocked(true)) { - strAutoDenomResult = _("Wallet is locked."); + strAutoDenomResult = _("Wallet is locked.").translated; return false; } @@ -979,7 +980,7 @@ bool CCoinJoinClientManager::DoAutomaticDenominating(CConnman& connman, bool fDr if (WaitForAnotherBlock()) { LogPrint(BCLog::COINJOIN, "CCoinJoinClientManager::DoAutomaticDenominating -- Last successful action was too recent\n"); - strAutoDenomResult = _("Last successful action was too recent."); + strAutoDenomResult = _("Last successful action was too recent.").translated; return false; } @@ -1090,10 +1091,10 @@ bool CCoinJoinClientSession::JoinExistingQueue(CAmount nBalanceNeedsAnonymized, nTimeLastSuccessfulStep = GetTime(); LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::JoinExistingQueue -- pending connection (from queue): nSessionDenom: %d (%s), addr=%s\n", nSessionDenom, CCoinJoin::DenominationToString(nSessionDenom), dmn->pdmnState->addr.ToString()); - strAutoDenomResult = _("Trying to connect..."); + strAutoDenomResult = _("Trying to connect...").translated; return true; } - strAutoDenomResult = _("Failed to find mixing queue to join"); + strAutoDenomResult = _("Failed to find mixing queue to join").translated; return false; } @@ -1111,7 +1112,7 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon if (!mixingWallet.SelectDenominatedAmounts(nBalanceNeedsAnonymized, setAmounts)) { // this should never happen LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::StartNewQueue -- Can't mix: no compatible inputs found!\n"); - strAutoDenomResult = _("Can't mix: no compatible inputs found!"); + strAutoDenomResult = _("Can't mix: no compatible inputs found!").translated; return false; } @@ -1121,7 +1122,7 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon if (!dmn) { LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::StartNewQueue -- Can't find random masternode!\n"); - strAutoDenomResult = _("Can't find random Masternode."); + strAutoDenomResult = _("Can't find random Masternode.").translated; return false; } @@ -1170,10 +1171,10 @@ bool CCoinJoinClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, CCon nTimeLastSuccessfulStep = GetTime(); LogPrint(BCLog::COINJOIN, "CCoinJoinClientSession::StartNewQueue -- pending connection, nSessionDenom: %d (%s), addr=%s\n", nSessionDenom, CCoinJoin::DenominationToString(nSessionDenom), dmn->pdmnState->addr.ToString()); - strAutoDenomResult = _("Trying to connect..."); + strAutoDenomResult = _("Trying to connect...").translated; return true; } - strAutoDenomResult = _("Failed to start a new mixing queue"); + strAutoDenomResult = _("Failed to start a new mixing queue").translated; return false; } @@ -1206,7 +1207,7 @@ void CCoinJoinClientManager::ProcessPendingDsaRequest(CConnman& connman) LOCK(cs_deqsessions); for (auto& session : deqSessions) { if (session.ProcessPendingDsaRequest(connman)) { - strAutoDenomResult = _("Mixing in progress..."); + strAutoDenomResult = _("Mixing in progress...").translated; } } } diff --git a/src/coinjoin/coinjoin.cpp b/src/coinjoin/coinjoin.cpp index c28b2666a8..706e6f0be4 100644 --- a/src/coinjoin/coinjoin.cpp +++ b/src/coinjoin/coinjoin.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -378,51 +379,51 @@ std::string CCoinJoin::GetMessageByID(PoolMessage nMessageID) { switch (nMessageID) { case ERR_ALREADY_HAVE: - return _("Already have that input."); + return _("Already have that input.").translated; case ERR_DENOM: - return _("No matching denominations found for mixing."); + return _("No matching denominations found for mixing.").translated; case ERR_ENTRIES_FULL: - return _("Entries are full."); + return _("Entries are full.").translated; case ERR_EXISTING_TX: - return _("Not compatible with existing transactions."); + return _("Not compatible with existing transactions.").translated; case ERR_FEES: - return _("Transaction fees are too high."); + return _("Transaction fees are too high.").translated; case ERR_INVALID_COLLATERAL: - return _("Collateral not valid."); + return _("Collateral not valid.").translated; case ERR_INVALID_INPUT: - return _("Input is not valid."); + return _("Input is not valid.").translated; case ERR_INVALID_SCRIPT: - return _("Invalid script detected."); + return _("Invalid script detected.").translated; case ERR_INVALID_TX: - return _("Transaction not valid."); + return _("Transaction not valid.").translated; case ERR_MAXIMUM: - return _("Entry exceeds maximum size."); + return _("Entry exceeds maximum size.").translated; case ERR_MN_LIST: - return _("Not in the Masternode list."); + return _("Not in the Masternode list.").translated; case ERR_MODE: - return _("Incompatible mode."); + return _("Incompatible mode.").translated; case ERR_QUEUE_FULL: - return _("Masternode queue is full."); + return _("Masternode queue is full.").translated; case ERR_RECENT: - return _("Last queue was created too recently."); + return _("Last queue was created too recently.").translated; case ERR_SESSION: - return _("Session not complete!"); + return _("Session not complete!").translated; case ERR_MISSING_TX: - return _("Missing input transaction information."); + return _("Missing input transaction information.").translated; case ERR_VERSION: - return _("Incompatible version."); + return _("Incompatible version.").translated; case MSG_NOERR: - return _("No errors detected."); + return _("No errors detected.").translated; case MSG_SUCCESS: - return _("Transaction created successfully."); + return _("Transaction created successfully.").translated; case MSG_ENTRIES_ADDED: - return _("Your entries added successfully."); + return _("Your entries added successfully.").translated; case ERR_SIZE_MISMATCH: - return _("Inputs vs outputs size mismatch."); + return _("Inputs vs outputs size mismatch.").translated; case ERR_NON_STANDARD_PUBKEY: case ERR_NOT_A_MN: default: - return _("Unknown response."); + return _("Unknown response.").translated; } } diff --git a/src/dash-cli.cpp b/src/dash-cli.cpp index cddc1eca49..db16ca9424 100644 --- a/src/dash-cli.cpp +++ b/src/dash-cli.cpp @@ -14,9 +14,11 @@ #include #include #include -#include #include +#include +#include +#include #include #include #include diff --git a/src/dash-tx.cpp b/src/dash-tx.cpp index e791cc81fe..5c6a1e15df 100644 --- a/src/dash-tx.cpp +++ b/src/dash-tx.cpp @@ -17,10 +17,12 @@ #include