diff --git a/src/banman.cpp b/src/banman.cpp --- a/src/banman.cpp +++ b/src/banman.cpp @@ -17,7 +17,7 @@ m_ban_db(std::move(ban_file), chainparams), m_default_ban_time(default_ban_time) { if (m_client_interface) { - m_client_interface->InitMessage(_("Loading banlist...")); + m_client_interface->InitMessage(_("Loading banlist...").translated); } int64_t n_start = GetTimeMillis(); diff --git a/src/httprpc.cpp b/src/httprpc.cpp --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -408,7 +408,8 @@ // Same message as AbortNode. uiInterface.ThreadSafeMessageBox( _("Error: A fatal internal error occurred, see debug.log for " - "details"), + "details") + .translated, "", CClientUIInterface::MSG_ERROR); return false; } diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -137,9 +137,10 @@ } int64_t count = 0; - uiInterface.InitMessage(_("Upgrading txindex database")); + uiInterface.InitMessage(_("Upgrading txindex database").translated); LogPrintf("Upgrading txindex database... [0%%]\n"); - uiInterface.ShowProgress(_("Upgrading txindex database"), 0, true); + uiInterface.ShowProgress(_("Upgrading txindex database").translated, 0, + true); int report_done = 0; const size_t batch_size = 1 << 24; // 16 MiB @@ -177,7 +178,7 @@ (static_cast(*(txid.begin() + 1)) << 0); int percentage_done = (int)(high_nibble * 100.0 / 65536.0 + 0.5); - uiInterface.ShowProgress(_("Upgrading txindex database"), + uiInterface.ShowProgress(_("Upgrading txindex database").translated, percentage_done, true); if (report_done < percentage_done / 10) { LogPrintf("Upgrading txindex database... [%d%%]\n", diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -117,9 +117,9 @@ #endif return true; } else { - return InitError(strprintf(_("Unable to create the PID file '%s': %s"), - GetPidFile().string(), - std::strerror(errno))); + return InitError( + strprintf(_("Unable to create the PID file '%s': %s").translated, + GetPidFile().string(), std::strerror(errno))); } } @@ -159,7 +159,7 @@ return CCoinsViewBacked::GetCoin(outpoint, coin); } catch (const std::runtime_error &e) { uiInterface.ThreadSafeMessageBox( - _("Error reading from database, shutting down."), "", + _("Error reading from database, shutting down.").translated, "", CClientUIInterface::MSG_ERROR); LogPrintf("Error reading from database: %s\n", e.what()); // Starting the shutdown sequence and returning false to the caller @@ -1141,25 +1141,28 @@ ""; const std::string URL_WEBSITE = ""; - return CopyrightHolders( - strprintf(_("Copyright (C) %i-%i"), 2009, COPYRIGHT_YEAR) + - " ") + + return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, + COPYRIGHT_YEAR) + + " ") + "\n" + "\n" + strprintf(_("Please contribute if you find %s useful. " - "Visit %s for further information about the software."), + "Visit %s for further information about the software.") + .translated, PACKAGE_NAME, URL_WEBSITE) + "\n" + - strprintf(_("The source code is available from %s."), + strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) + - "\n" + "\n" + _("This is experimental software.") + "\n" + + "\n" + "\n" + _("This is experimental software.").translated + "\n" + strprintf(_("Distributed under the MIT software license, see the " - "accompanying file %s or %s"), + "accompanying file %s or %s") + .translated, "COPYING", "") + "\n" + "\n" + strprintf(_("This product includes software developed by the " "OpenSSL Project for use in the OpenSSL Toolkit %s and " "cryptographic software written by Eric Young and UPnP " - "software written by Thomas Bernard."), + "software written by Thomas Bernard.") + .translated, "") + "\n"; } @@ -1485,7 +1488,8 @@ static std::string ResolveErrMsg(const char *const optname, const std::string &strBind) { - return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind); + return strprintf(_("Cannot resolve -%s address: '%s'").translated, optname, + strBind); } /** @@ -1608,26 +1612,29 @@ std::string network = gArgs.GetChainName(); for (const auto &arg : gArgs.GetUnsuitableSectionOnlyArgs()) { return InitError(strprintf(_("Config setting for %s only applied on %s " - "network when in [%s] section."), + "network when in [%s] section.") + .translated, arg, network, network)); } // Warn if unrecognized section name are present in the config file. for (const auto §ion : gArgs.GetUnrecognizedSections()) { - InitWarning(strprintf("%s:%i " + _("Section [%s] is not recognized."), - section.m_file, section.m_line, section.m_name)); + InitWarning(strprintf( + "%s:%i " + _("Section [%s] is not recognized.").translated, + section.m_file, section.m_line, section.m_name)); } if (!fs::is_directory(GetBlocksDir())) { - return InitError( - strprintf(_("Specified blocks directory \"%s\" does not exist."), - gArgs.GetArg("-blocksdir", ""))); + return InitError(strprintf( + _("Specified blocks directory \"%s\" does not exist.").translated, + gArgs.GetArg("-blocksdir", ""))); } // if using block pruning, then disallow txindex if (gArgs.GetArg("-prune", 0)) { if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) { - return InitError(_("Prune mode is incompatible with -txindex.")); + return InitError( + _("Prune mode is incompatible with -txindex.").translated); } } @@ -1654,7 +1661,8 @@ nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + MAX_ADDNODE_CONNECTIONS); if (nFD < MIN_CORE_FILEDESCRIPTORS) { - return InitError(_("Not enough file descriptors available.")); + return InitError( + _("Not enough file descriptors available.").translated); } nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, @@ -1662,7 +1670,8 @@ if (nMaxConnections < nUserMaxConnections) { InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, " - "because of system limitations."), + "because of system limitations.") + .translated, nUserMaxConnections, nMaxConnections)); } @@ -1676,9 +1685,9 @@ [](std::string cat) { return cat == "0" || cat == "none"; })) { for (const auto &cat : categories) { if (!LogInstance().EnableCategory(cat)) { - InitWarning( - strprintf(_("Unsupported logging category %s=%s."), - "-debug", cat)); + InitWarning(strprintf( + _("Unsupported logging category %s=%s.").translated, + "-debug", cat)); } } } @@ -1687,8 +1696,9 @@ // Now remove the logging categories which were explicitly excluded for (const std::string &cat : gArgs.GetArgs("-debugexclude")) { if (!LogInstance().DisableCategory(cat)) { - InitWarning(strprintf(_("Unsupported logging category %s=%s."), - "-debugexclude", cat)); + InitWarning( + strprintf(_("Unsupported logging category %s=%s.").translated, + "-debugexclude", cat)); } } @@ -1749,8 +1759,9 @@ gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40; if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin) { - return InitError(strprintf(_("-maxmempool must be at least %d MB"), - std::ceil(nMempoolSizeMin / 1000000.0))); + return InitError( + strprintf(_("-maxmempool must be at least %d MB").translated, + std::ceil(nMempoolSizeMin / 1000000.0))); } // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency @@ -1769,7 +1780,8 @@ gArgs.GetArg("-excessiveblocksize", DEFAULT_MAX_BLOCK_SIZE); if (!config.SetMaxBlockSize(nProposedExcessiveBlockSize)) { return InitError( - _("Excessive block size must be > 1,000,000 bytes (1MB)")); + _("Excessive block size must be > 1,000,000 bytes (1MB)") + .translated); } // Check blockmaxsize does not exceed maximum accepted block size. @@ -1777,7 +1789,8 @@ gArgs.GetArg("-blockmaxsize", DEFAULT_MAX_GENERATED_BLOCK_SIZE); if (nProposedMaxGeneratedBlockSize > config.GetMaxBlockSize()) { auto msg = _("Max generated block size (blockmaxsize) cannot exceed " - "the excessive block size (excessiveblocksize)"); + "the excessive block size (excessiveblocksize)") + .translated; return InitError(msg); } @@ -1786,7 +1799,7 @@ int64_t nPruneArg = gArgs.GetArg("-prune", 0); if (nPruneArg < 0) { return InitError( - _("Prune cannot be configured with a negative value.")); + _("Prune cannot be configured with a negative value.").translated); } nPruneTarget = (uint64_t)nPruneArg * 1024 * 1024; if (nPruneArg == 1) { @@ -1799,8 +1812,9 @@ } else if (nPruneTarget) { if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) { return InitError( - strprintf(_("Prune configured below the minimum of %d MiB. " - "Please use a higher number."), + strprintf(_("Prune configured below the minimum of %d MiB. " + "Please use a higher number.") + .translated, MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); } LogPrintf("Prune configured to target %uMiB on disk for block and undo " @@ -1908,12 +1922,14 @@ fs::path datadir = GetDataDir(); if (!DirIsWritable(datadir)) { return InitError(strprintf( - _("Cannot write to data directory '%s'; check permissions."), + _("Cannot write to data directory '%s'; check permissions.") + .translated, datadir.string())); } if (!LockDirectory(datadir, ".lock", probeOnly)) { return InitError(strprintf(_("Cannot obtain a lock on data directory " - "%s. %s is probably already running."), + "%s. %s is probably already running.") + .translated, datadir.string(), PACKAGE_NAME)); } return true; @@ -1932,7 +1948,8 @@ // Sanity check if (!InitSanityCheck()) { return InitError(strprintf( - _("Initialization sanity check failed. %s is shutting down."), + _("Initialization sanity check failed. %s is shutting down.") + .translated, PACKAGE_NAME)); } @@ -1994,9 +2011,9 @@ LogPrintf("Config file: %s\n", config_file_path.string()); } else if (gArgs.IsArgSet("-conf")) { // Warn if no conf file exists at path provided by user - InitWarning( - strprintf(_("The specified config file %s does not exist\n"), - config_file_path.string())); + InitWarning(strprintf( + _("The specified config file %s does not exist\n").translated, + config_file_path.string())); } else { // Not categorizing as "Warning" because it's the default behavior LogPrintf("Config file: %s (not found, skipping)\n", @@ -2072,7 +2089,8 @@ uiInterface.InitMessage_connect(SetRPCWarmupStatus); if (!AppInitServers(config, httpRPCRequestProcessor)) { return InitError( - _("Unable to start HTTP server. See debug log for details.")); + _("Unable to start HTTP server. See debug log for details.") + .translated); } } @@ -2109,7 +2127,9 @@ for (const std::string &cmt : gArgs.GetArgs("-uacomment")) { if (cmt != SanitizeString(cmt, SAFE_CHARS_UA_COMMENT)) { return InitError(strprintf( - _("User Agent comment (%s) contains unsafe characters."), cmt)); + _("User Agent comment (%s) contains unsafe characters.") + .translated, + cmt)); } uacomments.push_back(cmt); } @@ -2118,7 +2138,8 @@ if (strSubVersion.size() > MAX_SUBVERSION_LENGTH) { return InitError(strprintf( _("Total length of network version string (%i) exceeds maximum " - "length (%i). Reduce the number or size of uacomments."), + "length (%i). Reduce the number or size of uacomments.") + .translated, strSubVersion.size(), MAX_SUBVERSION_LENGTH)); } @@ -2128,7 +2149,8 @@ enum Network net = ParseNetwork(snet); if (net == NET_UNROUTABLE) { return InitError(strprintf( - _("Unknown network specified in -onlynet: '%s'"), snet)); + _("Unknown network specified in -onlynet: '%s'").translated, + snet)); } nets.insert(net); } @@ -2155,13 +2177,15 @@ CService proxyAddr; if (!Lookup(proxyArg.c_str(), proxyAddr, 9050, fNameLookup)) { return InitError(strprintf( - _("Invalid -proxy address or hostname: '%s'"), proxyArg)); + _("Invalid -proxy address or hostname: '%s'").translated, + proxyArg)); } proxyType addrProxy = proxyType(proxyAddr, proxyRandomize); if (!addrProxy.IsValid()) { return InitError(strprintf( - _("Invalid -proxy address or hostname: '%s'"), proxyArg)); + _("Invalid -proxy address or hostname: '%s'").translated, + proxyArg)); } SetProxy(NET_IPV4, addrProxy); @@ -2186,12 +2210,14 @@ CService onionProxy; if (!Lookup(onionArg.c_str(), onionProxy, 9050, fNameLookup)) { return InitError(strprintf( - _("Invalid -onion address or hostname: '%s'"), onionArg)); + _("Invalid -onion address or hostname: '%s'").translated, + onionArg)); } proxyType addrOnion = proxyType(onionProxy, proxyRandomize); if (!addrOnion.IsValid()) { return InitError(strprintf( - _("Invalid -onion address or hostname: '%s'"), onionArg)); + _("Invalid -onion address or hostname: '%s'").translated, + onionArg)); } SetProxy(NET_ONION, addrOnion); SetReachable(NET_ONION, true); @@ -2282,7 +2308,7 @@ bool fReset = fReindex; std::string strLoadError; - uiInterface.InitMessage(_("Loading block index...")); + uiInterface.InitMessage(_("Loading block index...").translated); nStart = GetTimeMillis(); do { try { @@ -2313,7 +2339,7 @@ // From here on out fReindex and fReset mean something // different! if (!LoadBlockIndex(config)) { - strLoadError = _("Error loading block database"); + strLoadError = _("Error loading block database").translated; break; } @@ -2324,7 +2350,8 @@ !LookupBlockIndex( chainparams.GetConsensus().hashGenesisBlock)) { return InitError(_("Incorrect or no genesis block found. " - "Wrong datadir for network?")); + "Wrong datadir for network?") + .translated); } // Check for changed -prune state. What we are concerned about @@ -2334,7 +2361,8 @@ strLoadError = _("You need to rebuild the database using -reindex to " "go back to unpruned mode. This will redownload the " - "entire blockchain"); + "entire blockchain") + .translated; break; } @@ -2345,7 +2373,8 @@ // This is called again in ThreadImport after the reindex // completes. if (!fReindex && !LoadGenesisBlock(chainparams)) { - strLoadError = _("Error initializing block database"); + strLoadError = + _("Error initializing block database").translated; break; } @@ -2361,7 +2390,8 @@ // This is a no-op if we cleared the coinsviewdb with -reindex // or -reindex-chainstate if (!pcoinsdbview->Upgrade()) { - strLoadError = _("Error upgrading chainstate database"); + strLoadError = + _("Error upgrading chainstate database").translated; break; } @@ -2371,7 +2401,8 @@ pcoinsdbview.get())) { strLoadError = _("Unable to replay blocks. You will need to rebuild " - "the database using -reindex-chainstate."); + "the database using -reindex-chainstate.") + .translated; break; } @@ -2384,12 +2415,14 @@ // LoadChainTip sets ::ChainActive() based on pcoinsTip's // best block if (!LoadChainTip(config)) { - strLoadError = _("Error initializing block database"); + strLoadError = + _("Error initializing block database").translated; break; } assert(::ChainActive().Tip() != nullptr); - uiInterface.InitMessage(_("Verifying blocks...")); + uiInterface.InitMessage( + _("Verifying blocks...").translated); if (fHavePruned && gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS) > MIN_BLOCKS_TO_KEEP) { @@ -2403,12 +2436,14 @@ RPCNotifyBlockChange(true, tip); if (tip && tip->nTime > GetAdjustedTime() + MAX_FUTURE_BLOCK_TIME) { - strLoadError = _( - "The block database contains a block which appears " - "to be from the future. This may be due to your " - "computer's date and time being set incorrectly. " - "Only rebuild the block database if you are sure " - "that your computer's date and time are correct"); + strLoadError = + _("The block database contains a block which " + "appears to be from the future. This may be due " + "to your computer's date and time being set " + "incorrectly. Only rebuild the block database if " + "you are sure that your computer's date and time " + "are correct") + .translated; break; } @@ -2417,13 +2452,14 @@ gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL), gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) { - strLoadError = _("Corrupted block database detected"); + strLoadError = + _("Corrupted block database detected").translated; break; } } } catch (const std::exception &e) { LogPrintf("%s\n", e.what()); - strLoadError = _("Error opening block database"); + strLoadError = _("Error opening block database").translated; break; } @@ -2435,7 +2471,8 @@ if (!fReset) { bool fRet = uiInterface.ThreadSafeQuestion( strLoadError + ".\n\n" + - _("Do you want to rebuild the block database now?"), + _("Do you want to rebuild the block database now?") + .translated, strLoadError + ".\nPlease restart with -reindex or " "-reindex-chainstate to recover.", "", @@ -2491,20 +2528,20 @@ LogPrintf("Unsetting NODE_NETWORK on prune mode\n"); nLocalServices = ServiceFlags(nLocalServices & ~NODE_NETWORK); if (!fReindex) { - uiInterface.InitMessage(_("Pruning blockstore...")); + uiInterface.InitMessage(_("Pruning blockstore...").translated); ::ChainstateActive().PruneAndFlush(); } } // Step 11: import blocks if (!CheckDiskSpace(GetDataDir())) { - InitError( - strprintf(_("Error: Disk space is low for %s"), GetDataDir())); + InitError(strprintf(_("Error: Disk space is low for %s").translated, + GetDataDir())); return false; } if (!CheckDiskSpace(GetBlocksDir())) { - InitError( - strprintf(_("Error: Disk space is low for %s"), GetBlocksDir())); + InitError(strprintf(_("Error: Disk space is low for %s").translated, + GetBlocksDir())); return false; } @@ -2632,7 +2669,7 @@ // Step 13: finished SetRPCWarmupFinished(); - uiInterface.InitMessage(_("Done loading")); + uiInterface.InitMessage(_("Done loading").translated); for (const auto &client : interfaces.chain_clients) { client->start(scheduler); diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -2107,11 +2107,13 @@ int nErr = WSAGetLastError(); if (nErr == WSAEADDRINUSE) { strError = strprintf(_("Unable to bind to %s on this computer. %s " - "is probably already running."), + "is probably already running.") + .translated, addrBind.ToString(), PACKAGE_NAME); } else { strError = strprintf(_("Unable to bind to %s on this computer " - "(bind returned error %s)"), + "(bind returned error %s)") + .translated, addrBind.ToString(), NetworkErrorString(nErr)); } LogPrintf("%s\n", strError); @@ -2123,7 +2125,8 @@ // Listen for incoming connections if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR) { strError = strprintf(_("Error: Listening for incoming connections " - "failed (listen returned error %s)"), + "failed (listen returned error %s)") + .translated, NetworkErrorString(WSAGetLastError())); LogPrintf("%s\n", strError); CloseSocket(hListenSocket); @@ -2274,7 +2277,8 @@ if (clientInterface) { clientInterface->ThreadSafeMessageBox( _("Failed to listen on any port. Use -listen=0 if you want " - "this."), + "this.") + .translated, "", CClientUIInterface::MSG_ERROR); } return false; @@ -2285,7 +2289,7 @@ } if (clientInterface) { - clientInterface->InitMessage(_("Loading P2P addresses...")); + clientInterface->InitMessage(_("Loading P2P addresses...").translated); } // Load addresses from peers.dat int64_t nStart = GetTimeMillis(); @@ -2302,7 +2306,7 @@ } } - uiInterface.InitMessage(_("Starting network threads...")); + uiInterface.InitMessage(_("Starting network threads...").translated); fAddressesInitialized = true; @@ -2354,7 +2358,8 @@ if (clientInterface) { clientInterface->ThreadSafeMessageBox( _("Cannot provide specific connections and have addrman find " - "outgoing connections at the same."), + "outgoing connections at the same.") + .translated, "", CClientUIInterface::MSG_ERROR); } return false; diff --git a/src/net_permissions.cpp b/src/net_permissions.cpp --- a/src/net_permissions.cpp +++ b/src/net_permissions.cpp @@ -55,8 +55,8 @@ } else if (permission.length() == 0) { // Allow empty entries } else { - error = - strprintf(_("Invalid P2P permission: '%s'"), permission); + error = strprintf(_("Invalid P2P permission: '%s'").translated, + permission); return false; } } @@ -100,13 +100,14 @@ const std::string strBind = str.substr(offset); CService addrBind; if (!Lookup(strBind.c_str(), addrBind, 0, false)) { - error = strprintf(_("Cannot resolve -%s address: '%s'"), "whitebind", - strBind); + error = strprintf(_("Cannot resolve -%s address: '%s'").translated, + "whitebind", strBind); return false; } if (addrBind.GetPort() == 0) { - error = strprintf(_("Need to specify a port with -whitebind: '%s'"), - strBind); + error = strprintf( + _("Need to specify a port with -whitebind: '%s'").translated, + strBind); return false; } @@ -129,8 +130,8 @@ CSubNet subnet; LookupSubNet(net.c_str(), subnet); if (!subnet.IsValid()) { - error = - strprintf(_("Invalid netmask specified in -whitelist: '%s'"), net); + error = strprintf( + _("Invalid netmask specified in -whitelist: '%s'").translated, net); return false; } diff --git a/src/noui.cpp b/src/noui.cpp --- a/src/noui.cpp +++ b/src/noui.cpp @@ -30,13 +30,13 @@ // Check for usage of predefined caption switch (style) { case CClientUIInterface::MSG_ERROR: - strCaption += _("Error"); + strCaption += _("Error").translated; break; case CClientUIInterface::MSG_WARNING: - strCaption += _("Warning"); + strCaption += _("Warning").translated; break; case CClientUIInterface::MSG_INFORMATION: - strCaption += _("Information"); + strCaption += _("Information").translated; break; default: // Use supplied caption (can be empty) diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -188,11 +188,13 @@ static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible) { - InitMessage(splash, title + std::string("\n") + - (resume_possible - ? _("(press q to shutdown and continue later)") - : _("press q to shutdown")) + - strprintf("\n%d", nProgress) + "%"); + InitMessage( + splash, + title + std::string("\n") + + (resume_possible + ? _("(press q to shutdown and continue later)").translated + : _("press q to shutdown").translated) + + strprintf("\n%d", nProgress) + "%"); } #ifdef ENABLE_WALLET void SplashScreen::ConnectWallet(std::unique_ptr wallet) { diff --git a/src/timedata.cpp b/src/timedata.cpp --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -106,7 +106,8 @@ std::string strMessage = strprintf(_("Please check that your computer's date " "and time are correct! If your clock is " - "wrong, %s will not work properly."), + "wrong, %s will not work properly.") + .translated, PACKAGE_NAME); SetMiscWarning(strMessage); uiInterface.ThreadSafeMessageBox( diff --git a/src/txdb.cpp b/src/txdb.cpp --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -382,7 +382,7 @@ int64_t count = 0; LogPrintf("Upgrading utxo-set database...\n"); LogPrintfToBeContinued("[0%%]..."); - uiInterface.ShowProgress(_("Upgrading UTXO database"), 0, true); + uiInterface.ShowProgress(_("Upgrading UTXO database").translated, 0, true); size_t batch_size = 1 << 24; CDBBatch batch(db); int reportDone = 0; @@ -402,7 +402,7 @@ uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1); int percentageDone = (int)(high * 100.0 / 65536.0 + 0.5); - uiInterface.ShowProgress(_("Upgrading UTXO database"), + uiInterface.ShowProgress(_("Upgrading UTXO database").translated, percentageDone, true); if (reportDone < percentageDone / 10) { // report max. every 10% step diff --git a/src/util/error.cpp b/src/util/error.cpp --- a/src/util/error.cpp +++ b/src/util/error.cpp @@ -33,11 +33,11 @@ } std::string AmountHighWarn(const std::string &optname) { - return strprintf(_("%s is set very high!"), optname); + return strprintf(_("%s is set very high!").translated, optname); } std::string AmountErrMsg(const std::string &optname, const std::string &strValue) { - return strprintf(_("Invalid amount for -%s=: '%s'"), optname, - strValue); + return strprintf(_("Invalid amount for -%s=: '%s'").translated, + optname, strValue); } diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -1251,8 +1251,8 @@ } std::string CopyrightHolders(const std::string &strPrefix) { - return strPrefix + - strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION); + return strPrefix + strprintf(_(COPYRIGHT_HOLDERS).translated, + COPYRIGHT_HOLDERS_SUBSTITUTION); } // Obtain the application startup time (used for uptime calculation) diff --git a/src/util/translation.h b/src/util/translation.h --- a/src/util/translation.h +++ b/src/util/translation.h @@ -35,8 +35,9 @@ * Translation function. * If no translation function is set, simply return the input. */ -inline std::string _(const char *psz) { - return G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz; +inline bilingual_str _(const char *psz) { + return bilingual_str{psz, + G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz}; } #endif // BITCOIN_UTIL_TRANSLATION_H diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1266,6 +1266,7 @@ uiInterface.ThreadSafeMessageBox( userMessage.empty() ? _("Error: A fatal internal error occurred, see " "debug.log for details") + .translated : userMessage, "", CClientUIInterface::MSG_ERROR); StartShutdown(); @@ -2021,7 +2022,7 @@ // Depend on nMinDiskSpace to ensure we can write block index if (!CheckDiskSpace(GetBlocksDir())) { return AbortNode(state, "Disk space is low!", - _("Error: Disk space is low!")); + _("Error: Disk space is low!").translated); } // First make sure all block and undo data is flushed to disk. @@ -2070,7 +2071,7 @@ if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * pcoinsTip->GetCacheSize())) { return AbortNode(state, "Disk space is low!", - _("Error: Disk space is low!")); + _("Error: Disk space is low!").translated); } // Flush the chainstate (which may refer to block index @@ -3427,7 +3428,7 @@ BlockFileSeq().Allocate(pos, nAddSize, out_of_space); if (out_of_space) { return AbortNode("Disk space is low!", - _("Error: Disk space is low!")); + _("Error: Disk space is low!").translated); } if (bytes_allocated != 0 && fPruneMode) { fCheckForPruning = true; @@ -3453,7 +3454,7 @@ UndoFileSeq().Allocate(pos, nAddSize, out_of_space); if (out_of_space) { return AbortNode(state, "Disk space is low!", - _("Error: Disk space is low!")); + _("Error: Disk space is low!").translated); } if (bytes_allocated != 0 && fPruneMode) { fCheckForPruning = true; @@ -4631,7 +4632,7 @@ } CVerifyDB::CVerifyDB() { - uiInterface.ShowProgress(_("Verifying blocks..."), 0, false); + uiInterface.ShowProgress(_("Verifying blocks...").translated, 0, false); } CVerifyDB::~CVerifyDB() { @@ -4681,8 +4682,8 @@ reportDone = percentageDone / 10; } - uiInterface.ShowProgress(_("Verifying blocks..."), percentageDone, - false); + uiInterface.ShowProgress(_("Verifying blocks...").translated, + percentageDone, false); if (pindex->nHeight <= ::ChainActive().Height() - nCheckDepth) { break; } @@ -4768,7 +4769,7 @@ while (pindex != ::ChainActive().Tip()) { boost::this_thread::interruption_point(); uiInterface.ShowProgress( - _("Verifying blocks..."), + _("Verifying blocks...").translated, std::max( 1, std::min(99, 100 - (int)(((double)(::ChainActive().Height() - @@ -4849,7 +4850,7 @@ return error("ReplayBlocks(): unknown inconsistent state"); } - uiInterface.ShowProgress(_("Replaying blocks..."), 0, false); + uiInterface.ShowProgress(_("Replaying blocks...").translated, 0, false); LogPrintf("Replaying blocks\n"); // Old tip during the interrupted flush. diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -405,14 +405,16 @@ // Wallet file must be a plain filename without a directory if (walletFile != fs::basename(walletFile) + fs::extension(walletFile)) { - errorStr = strprintf(_("Wallet %s resides outside wallet directory %s"), - walletFile, walletDir.string()); + errorStr = strprintf( + _("Wallet %s resides outside wallet directory %s").translated, + walletFile, walletDir.string()); return false; } if (!env->Open(true /* retry */)) { errorStr = strprintf( - _("Error initializing wallet database environment %s!"), walletDir); + _("Error initializing wallet database environment %s!").translated, + walletDir); return false; } @@ -435,11 +437,13 @@ warningStr = strprintf( _("Warning: Wallet file corrupt, data salvaged! Original %s " "saved as %s in %s; if your balance or transactions are " - "incorrect you should restore from a backup."), + "incorrect you should restore from a backup.") + .translated, walletFile, backup_filename, walletDir); } if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL) { - errorStr = strprintf(_("%s corrupt, salvage failed"), walletFile); + errorStr = strprintf(_("%s corrupt, salvage failed").translated, + walletFile); return false; } } diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -219,13 +219,15 @@ if (gArgs.GetArg("-prune", 0) && gArgs.GetBoolArg("-rescan", false)) { return InitError( _("Rescans are not possible in pruned mode. You will need to use " - "-reindex which will download the whole blockchain again.")); + "-reindex which will download the whole blockchain again.") + .translated); } if (minRelayTxFee.GetFeePerK() > HIGH_TX_FEE_PER_KB) { InitWarning( AmountHighWarn("-minrelaytxfee") + " " + - _("The wallet will avoid paying less than the minimum relay fee.")); + _("The wallet will avoid paying less than the minimum relay fee.") + .translated); } if (gArgs.IsArgSet("-maxtxfee")) { @@ -237,7 +239,8 @@ if (nMaxFee > HIGH_MAX_TX_FEE) { InitWarning(_("-maxtxfee is set very high! Fees this large could " - "be paid on a single transaction.")); + "be paid on a single transaction.") + .translated); } maxTxFee = nMaxFee; @@ -245,7 +248,8 @@ return InitError(strprintf( _("Invalid amount for -maxtxfee=: '%s' (must " "be at least the minrelay fee of %s to prevent " - "stuck transactions)"), + "stuck transactions)") + .translated, gArgs.GetArg("-maxtxfee", ""), minRelayTxFee.ToString())); } } diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -20,21 +20,21 @@ // environment instances for the same directory fs::path canonical_wallet_dir = fs::canonical(wallet_dir, error); if (error || !fs::exists(wallet_dir)) { - chain.initError( - strprintf(_("Specified -walletdir \"%s\" does not exist"), - wallet_dir.string())); + chain.initError(strprintf( + _("Specified -walletdir \"%s\" does not exist").translated, + wallet_dir.string())); return false; } else if (!fs::is_directory(wallet_dir)) { - chain.initError( - strprintf(_("Specified -walletdir \"%s\" is not a directory"), - wallet_dir.string())); + chain.initError(strprintf( + _("Specified -walletdir \"%s\" is not a directory").translated, + wallet_dir.string())); return false; // The canonical path transforms relative paths into absolute ones, // so we check the non-canonical version } else if (!wallet_dir.is_absolute()) { - chain.initError( - strprintf(_("Specified -walletdir \"%s\" is a relative path"), - wallet_dir.string())); + chain.initError(strprintf( + _("Specified -walletdir \"%s\" is a relative path").translated, + wallet_dir.string())); return false; } gArgs.ForceSetArg("-walletdir", canonical_wallet_dir.string()); @@ -42,7 +42,7 @@ LogPrintf("Using wallet directory %s\n", GetWalletDir().string()); - chain.initMessage(_("Verifying wallet(s)...")); + chain.initMessage(_("Verifying wallet(s)...").translated); // Parameter interaction code should have thrown an error if -salvagewallet // was enabled with more than wallet file, so the wallet_files size check @@ -58,7 +58,8 @@ if (!wallet_paths.insert(location.GetPath()).second) { chain.initError(strprintf(_("Error loading wallet %s. Duplicate " - "-wallet filename specified."), + "-wallet filename specified.") + .translated, wallet_file)); return false; } diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -703,8 +703,9 @@ // show progress dialog in GUI pwallet->chain().showProgress( - strprintf("%s " + _("Importing..."), pwallet->GetDisplayName()), 0, - false); + strprintf("%s " + _("Importing...").translated, + pwallet->GetDisplayName()), + 0, false); std::vector> keys; std::vector> scripts; while (file.good()) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1860,8 +1860,9 @@ // Show rescan progress in GUI as dialog or on splashscreen, if -rescan // on startup. - ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), - 0); + ShowProgress( + strprintf("%s " + _("Rescanning...").translated, GetDisplayName()), + 0); BlockHash tip_hash; // The way the 'block_height' is initialized is just a workaround for // the gcc bug #47679 since version 4.6.0. @@ -1883,7 +1884,8 @@ if (*block_height % 100 == 0 && progress_end - progress_begin > 0.0) { ShowProgress( - strprintf("%s " + _("Rescanning..."), GetDisplayName()), + strprintf("%s " + _("Rescanning...").translated, + GetDisplayName()), std::max( 1, std::min(99, (int)((progress_current - progress_begin) / @@ -1954,8 +1956,9 @@ } // Hide progress dialog in GUI. - ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), - 100); + ShowProgress( + strprintf("%s " + _("Rescanning...").translated, GetDisplayName()), + 100); if (block_height && fAbortRescan) { WalletLogPrintf("Rescan aborted at block %d. Progress=%f\n", *block_height, progress_current); @@ -3048,7 +3051,8 @@ unsigned int nSubtractFeeFromAmount = 0; for (const auto &recipient : vecSend) { if (nValue < Amount::zero() || recipient.nAmount < Amount::zero()) { - strFailReason = _("Transaction amounts must not be negative"); + strFailReason = + _("Transaction amounts must not be negative").translated; return false; } @@ -3060,7 +3064,8 @@ } if (vecSend.empty()) { - strFailReason = _("Transaction must have at least one recipient"); + strFailReason = + _("Transaction must have at least one recipient").translated; return false; } @@ -3102,7 +3107,8 @@ if (IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { strFailReason = _("Can't generate a change-address key. Private keys " - "are disabled for this wallet."); + "are disabled for this wallet.") + .translated; return false; } CPubKey vchPubKey; @@ -3110,7 +3116,8 @@ ret = reservekey.GetReservedKey(vchPubKey, true); if (!ret) { strFailReason = - _("Keypool ran out, please call keypoolrefill first"); + _("Keypool ran out, please call keypoolrefill first") + .translated; return false; } @@ -3179,15 +3186,18 @@ if (recipient.fSubtractFeeFromAmount && nFeeRet > Amount::zero()) { if (txout.nValue < Amount::zero()) { - strFailReason = _("The transaction amount is " - "too small to pay the fee"); + strFailReason = _("The transaction amount is too " + "small to pay the fee") + .translated; } else { strFailReason = _("The transaction amount is too small to " - "send after the fee has been deducted"); + "send after the fee has been deducted") + .translated; } } else { - strFailReason = _("Transaction amount too small"); + strFailReason = + _("Transaction amount too small").translated; } return false; @@ -3214,7 +3224,7 @@ coin_selection_params.use_bnb = false; continue; } else { - strFailReason = _("Insufficient funds"); + strFailReason = _("Insufficient funds").translated; return false; } } @@ -3237,7 +3247,8 @@ nChangePosInOut = GetRandInt(txNew.vout.size() + 1); } else if ((unsigned int)nChangePosInOut > txNew.vout.size()) { - strFailReason = _("Change index out of range"); + strFailReason = + _("Change index out of range").translated; return false; } @@ -3259,7 +3270,7 @@ int nBytes = CalculateMaximumSignedTxSize( txNewConst, this, coinControl.fAllowWatchOnly); if (nBytes < 0) { - strFailReason = _("Signing transaction failed"); + strFailReason = _("Signing transaction failed").translated; return false; } @@ -3269,7 +3280,8 @@ // on the next pass, give up because we must be at the maximum // allowed fee. if (nFeeNeeded < chain().relayMinFee().GetFee(nBytes)) { - strFailReason = _("Transaction too large for fee policy"); + strFailReason = + _("Transaction too large for fee policy").translated; return false; } @@ -3320,7 +3332,8 @@ // Or we should have just subtracted fee from recipients and // nFeeNeeded should not have changed. strFailReason = - _("Transaction fee and change calculation failed"); + _("Transaction fee and change calculation failed") + .translated; return false; } @@ -3385,7 +3398,7 @@ MutableTransactionSignatureCreator( &txNew, nIn, coin.txout.nValue, sigHashType), scriptPubKey, sigdata)) { - strFailReason = _("Signing transaction failed"); + strFailReason = _("Signing transaction failed").translated; return false; } @@ -3399,7 +3412,7 @@ // Limit size. if (tx->GetTotalSize() >= MAX_STANDARD_TX_SIZE) { - strFailReason = _("Transaction too large"); + strFailReason = _("Transaction too large").translated; return false; } } @@ -3408,7 +3421,8 @@ DEFAULT_WALLET_REJECT_LONG_CHAINS)) { // Lastly, ensure this tx will pass the mempool's chain limits if (!chain().checkChainLimits(tx)) { - strFailReason = _("Transaction has too long of a mempool chain"); + strFailReason = + _("Transaction has too long of a mempool chain").translated; return false; } } @@ -4450,7 +4464,8 @@ std::vector vWtx; if (gArgs.GetBoolArg("-zapwallettxes", false)) { - chain.initMessage(_("Zapping all transactions from wallet...")); + chain.initMessage( + _("Zapping all transactions from wallet...").translated); std::unique_ptr tempWallet = std::make_unique( chainParams, chain, location, @@ -4458,12 +4473,13 @@ DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx); if (nZapWalletRet != DBErrors::LOAD_OK) { chain.initError( - strprintf(_("Error loading %s: Wallet corrupted"), walletFile)); + strprintf(_("Error loading %s: Wallet corrupted").translated, + walletFile)); return nullptr; } } - chain.initMessage(_("Loading wallet...")); + chain.initMessage(_("Loading wallet...").translated); int64_t nStart = GetTimeMillis(); bool fFirstRun = true; @@ -4477,28 +4493,32 @@ if (nLoadWalletRet != DBErrors::LOAD_OK) { if (nLoadWalletRet == DBErrors::CORRUPT) { chain.initError( - strprintf(_("Error loading %s: Wallet corrupted"), walletFile)); + strprintf(_("Error loading %s: Wallet corrupted").translated, + walletFile)); return nullptr; } if (nLoadWalletRet == DBErrors::NONCRITICAL_ERROR) { chain.initError(strprintf( _("Error reading %s! All keys read correctly, but transaction " - "data" - " or address book entries might be missing or incorrect."), + "data or address book entries might be missing or incorrect.") + .translated, walletFile)); } else if (nLoadWalletRet == DBErrors::TOO_NEW) { chain.initError(strprintf( - _("Error loading %s: Wallet requires newer version of %s"), + _("Error loading %s: Wallet requires newer version of %s") + .translated, walletFile, PACKAGE_NAME)); return nullptr; } else if (nLoadWalletRet == DBErrors::NEED_REWRITE) { chain.initError(strprintf( - _("Wallet needed to be rewritten: restart %s to complete"), + _("Wallet needed to be rewritten: restart %s to complete") + .translated, PACKAGE_NAME)); return nullptr; } else { - chain.initError(strprintf(_("Error loading %s"), walletFile)); + chain.initError( + strprintf(_("Error loading %s").translated, walletFile)); return nullptr; } } @@ -4519,7 +4539,7 @@ } if (nMaxVersion < walletInstance->GetVersion()) { - chain.initError(_("Cannot downgrade wallet")); + chain.initError(_("Cannot downgrade wallet").translated); return nullptr; } @@ -4539,7 +4559,8 @@ chain.initError( _("Cannot upgrade a non HD split wallet without upgrading to " "support pre split keypool. Please use -upgradewallet=200300 " - "or -upgradewallet with no version specified.")); + "or -upgradewallet with no version specified.") + .translated); return nullptr; } @@ -4569,7 +4590,7 @@ // Regenerate the keypool if upgraded to HD if (hd_upgrade) { if (!walletInstance->TopUpKeyPool()) { - chain.initError(_("Unable to generate keys")); + chain.initError(_("Unable to generate keys").translated); return nullptr; } } @@ -4594,7 +4615,7 @@ // Top up the keypool if (walletInstance->CanGenerateKeys() && !walletInstance->TopUpKeyPool()) { - chain.initError(_("Unable to generate initial keys")); + chain.initError(_("Unable to generate initial keys").translated); return nullptr; } @@ -4605,7 +4626,8 @@ // Make it impossible to disable private keys after creation chain.initError( strprintf(_("Error loading %s: Private keys can only be " - "disabled during creation"), + "disabled during creation") + .translated, walletFile)); return nullptr; } else if (walletInstance->IsWalletFlagSet( @@ -4615,7 +4637,8 @@ !walletInstance->mapCryptedKeys.empty()) { chain.initWarning( strprintf(_("Warning: Private keys detected in wallet " - "{%s} with disabled private keys"), + "{%s} with disabled private keys") + .translated, walletFile)); } } @@ -4632,7 +4655,8 @@ chain.initWarning( AmountHighWarn("-mintxfee") + " " + _("This is the minimum transaction fee you pay on " - "every transaction.")); + "every transaction.") + .translated); } walletInstance->m_min_fee = CFeeRate(n); } @@ -4640,16 +4664,17 @@ if (gArgs.IsArgSet("-fallbackfee")) { Amount nFeePerK = Amount::zero(); if (!ParseMoney(gArgs.GetArg("-fallbackfee", ""), nFeePerK)) { - chain.initError( - strprintf(_("Invalid amount for -fallbackfee=: '%s'"), - gArgs.GetArg("-fallbackfee", ""))); + chain.initError(strprintf( + _("Invalid amount for -fallbackfee=: '%s'").translated, + gArgs.GetArg("-fallbackfee", ""))); return nullptr; } if (nFeePerK > HIGH_TX_FEE_PER_KB) { chain.initWarning( AmountHighWarn("-fallbackfee") + " " + _("This is the transaction fee you may pay when fee " - "estimates are not available.")); + "estimates are not available.") + .translated); } walletInstance->m_fallback_fee = CFeeRate(nFeePerK); // disable fallback fee in case value was set to 0, enable if non-null @@ -4667,13 +4692,15 @@ chain.initWarning( AmountHighWarn("-paytxfee") + " " + _("This is the transaction fee you will pay if you " - "send a transaction.")); + "send a transaction.") + .translated); } walletInstance->m_pay_tx_fee = CFeeRate(nFeePerK, 1000); if (walletInstance->m_pay_tx_fee < chain.relayMinFee()) { chain.initError(strprintf( _("Invalid amount for -paytxfee=: '%s' " - "(must be at least %s)"), + "(must be at least %s)") + .translated, gArgs.GetArg("-paytxfee", ""), chain.relayMinFee().ToString())); return nullptr; } @@ -4730,12 +4757,13 @@ chain.initError( _("Prune: last wallet synchronisation goes beyond " "pruned data. You need to -reindex (download the " - "whole blockchain again in case of pruned node)")); + "whole blockchain again in case of pruned node)") + .translated); return nullptr; } } - chain.initMessage(_("Rescanning...")); + chain.initMessage(_("Rescanning...").translated); walletInstance->WalletLogPrintf( "Rescanning last %i blocks (from block %i)...\n", *tip_height - rescan_height, rescan_height); @@ -4762,7 +4790,8 @@ reserver, true /* update */) .status)) { chain.initError( - _("Failed to rescan the wallet during initialization")); + _("Failed to rescan the wallet during initialization") + .translated); return nullptr; } } diff --git a/src/warnings.cpp b/src/warnings.cpp --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -46,7 +46,8 @@ strStatusBar = "This is a pre-release test build - use at your own " "risk - do not use for mining or merchant applications"; strGUI = _("This is a pre-release test build - use at your own risk - " - "do not use for mining or merchant applications"); + "do not use for mining or merchant applications") + .translated; } // Misc warnings like out of disk space and clock is wrong @@ -60,7 +61,8 @@ "Some miners appear to be experiencing issues."; strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: The network does not appear to fully agree! Some " - "miners appear to be experiencing issues."); + "miners appear to be experiencing issues.") + .translated; } else if (fLargeWorkInvalidChainFound) { strStatusBar = "Warning: We do not appear to fully agree with our " "peers! You may need to upgrade, or other nodes may " @@ -68,7 +70,8 @@ strGUI += (strGUI.empty() ? "" : uiAlertSeperator) + _("Warning: We do not appear to fully agree with our peers! You " - "may need to upgrade, or other nodes may need to upgrade."); + "may need to upgrade, or other nodes may need to upgrade.") + .translated; } if (strFor == "gui") { diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -18,7 +18,7 @@ ("src/index/base.cpp", "FatalError(const char *fmt, const Args &... args)"), ("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char *fmt, const Args &... args)"), ("src/util/system.cpp", - "strprintf(_(COPYRIGHT_HOLDERS), COPYRIGHT_HOLDERS_SUBSTITUTION)"), + "strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION)"), ("src/tinyformat.h", "printf(const char *fmt, const Args &... args)"), ("src/tinyformat.h", "printf(const char *fmt, TINYFORMAT_VARARGS(n))"), ("src/wallet/wallet.h",