Skip to content

Commit

Permalink
qt: remove util/translation.h
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Jan 26, 2024
1 parent 183d3fe commit 4927a70
Show file tree
Hide file tree
Showing 122 changed files with 736 additions and 981 deletions.
2 changes: 0 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ BITCOIN_CORE_H = \
util/tokenpipe.h \
util/trace.h \
util/transaction_identifier.h \
util/translation.h \
util/types.h \
util/ui_change_type.h \
util/vector.h \
Expand Down Expand Up @@ -919,7 +918,6 @@ libbitcoinkernel_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -fvisibility=default
# and more modules are decoupled from the consensus engine, this list will
# shrink to only those which are absolutely necessary.
libbitcoinkernel_la_SOURCES = \
kernel/bitcoinkernel.cpp \
arith_uint256.cpp \
chain.cpp \
clientversion.cpp \
Expand Down
1 change: 0 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ BITCOIN_TESTS =\
test/timedata_tests.cpp \
test/torcontrol_tests.cpp \
test/transaction_tests.cpp \
test/translation_tests.cpp \
test/txindex_tests.cpp \
test/txpackage_tests.cpp \
test/txreconciliation_tests.cpp \
Expand Down
5 changes: 2 additions & 3 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <univalue.h>
#include <util/fs.h>
#include <util/fs_helpers.h>
#include <util/translation.h>

namespace {

Expand Down Expand Up @@ -199,14 +198,14 @@ util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgro
DumpPeerAddresses(args, *addrman);
} catch (const InvalidAddrManVersionError&) {
if (!RenameOver(path_addr, (fs::path)path_addr + ".bak")) {
return util::Error{strprintf(_("Failed to rename invalid peers.dat file. Please move or delete it and try again."))};
return util::Error{strprintf("Failed to rename invalid peers.dat file. Please move or delete it and try again.")};
}
// Addrman can be in an inconsistent state after failure, reset it
addrman = std::make_unique<AddrMan>(netgroupman, /*deterministic=*/false, /*consistency_check_ratio=*/check_addrman);
LogPrintf("Creating new peers.dat because the file version was not compatible (%s). Original backed up to peers.dat.bak\n", fs::quoted(fs::PathToString(path_addr)));
DumpPeerAddresses(args, *addrman);
} catch (const std::exception& e) {
return util::Error{strprintf(_("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start."),
return util::Error{strprintf("Invalid or corrupt peers.dat (%s). If you believe this is a bug, please report it to %s. As a workaround, you can move the file (%s) out of the way (rename, move, or delete) to have a new one created on the next start.",
e.what(), PACKAGE_BUGREPORT, fs::quoted(fs::PathToString(path_addr)))};
}
return addrman;
Expand Down
3 changes: 1 addition & 2 deletions src/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <node/interface_ui.h>
#include <sync.h>
#include <util/time.h>
#include <util/translation.h>


BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time)
Expand All @@ -30,7 +29,7 @@ void BanMan::LoadBanlist()
{
LOCK(m_banned_mutex);

if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated);
if (m_client_interface) m_client_interface->InitMessage("Loading banlist…");

const auto start{SteadyClock::now()};
if (m_ban_db.Read(m_banned)) {
Expand Down
4 changes: 2 additions & 2 deletions src/bench/wallet_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ static void WalletCreate(benchmark::Bench& bench, bool encrypted)
}

DatabaseStatus status;
bilingual_str error_string;
std::vector<bilingual_str> warnings;
std::string error_string;
std::vector<std::string> warnings;

fs::path wallet_path = test_setup->m_path_root / strprintf("test_wallet_%d", random.rand32()).c_str();
bench.run([&] {
Expand Down
1 change: 0 additions & 1 deletion src/bench/wallet_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <test/util/mining.h>
#include <test/util/setup_common.h>
#include <wallet/test/util.h>
#include <util/translation.h>
#include <validationinterface.h>
#include <wallet/context.h>
#include <wallet/receive.h>
Expand Down
12 changes: 6 additions & 6 deletions src/bitcoin-chainstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,22 @@ int main(int argc, char* argv[])
{
std::cout << "Header tip changed: " << height << ", " << timestamp << ", " << presync << std::endl;
}
void progress(const bilingual_str& title, int progress_percent, bool resume_possible) override
void progress(const std::string& title, int progress_percent, bool resume_possible) override
{
std::cout << "Progress: " << title.original << ", " << progress_percent << ", " << resume_possible << std::endl;
std::cout << "Progress: " << title << ", " << progress_percent << ", " << resume_possible << std::endl;
}
void warning(const bilingual_str& warning) override
void warning(const std::string& warning) override
{
std::cout << "Warning: " << warning.original << std::endl;
std::cout << "Warning: " << warning << std::endl;
}
void flushError(const std::string& debug_message) override
{
std::cerr << "Error flushing block data to disk: " << debug_message << std::endl;
}
void fatalError(const std::string& debug_message, const bilingual_str& user_message) override
void fatalError(const std::string& debug_message, const std::string& user_message) override
{
std::cerr << "Error: " << debug_message << std::endl;
std::cerr << (user_message.empty() ? "A fatal internal error occurred." : user_message.original) << std::endl;
std::cerr << (user_message.empty() ? "A fatal internal error occurred." : user_message) << std::endl;
}
};
auto notifications = std::make_unique<KernelNotifications>();
Expand Down
3 changes: 0 additions & 3 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
#include <util/exception.h>
#include <util/strencodings.h>
#include <util/time.h>
#include <util/translation.h>

#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <functional>
#include <memory>
#include <optional>
#include <string>
Expand All @@ -50,7 +48,6 @@
// just use a plain system_clock.
using CliClock = std::chrono::system_clock;

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
UrlDecodeFn* const URL_DECODE = urlDecode;

static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
Expand Down
3 changes: 0 additions & 3 deletions src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@
#include <util/rbf.h>
#include <util/strencodings.h>
#include <util/string.h>
#include <util/translation.h>

#include <cstdio>
#include <functional>
#include <memory>

static bool fCreateBlank;
static std::map<std::string,UniValue> registers;
static const int CONTINUE_EXECUTION=-1;

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;

static void SetupBitcoinTxArgs(ArgsManager &argsman)
{
Expand Down
5 changes: 0 additions & 5 deletions src/bitcoin-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@
#include <streams.h>
#include <util/exception.h>
#include <util/strencodings.h>
#include <util/translation.h>

#include <atomic>
#include <cstdio>
#include <functional>
#include <memory>
#include <thread>

static const int CONTINUE_EXECUTION=-1;

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;

static void SetupBitcoinUtilArgs(ArgsManager &argsman)
{
SetupHelpOptions(argsman);
Expand Down
2 changes: 0 additions & 2 deletions src/bitcoin-wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
#include <pubkey.h>
#include <tinyformat.h>
#include <util/exception.h>
#include <util/translation.h>
#include <wallet/wallettool.h>

#include <exception>
#include <functional>
#include <string>
#include <tuple>

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
UrlDecodeFn* const URL_DECODE = nullptr;

static void SetupWalletToolArgs(ArgsManager& argsman)
Expand Down
11 changes: 3 additions & 8 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@
#include <util/syserror.h>
#include <util/threadnames.h>
#include <util/tokenpipe.h>
#include <util/translation.h>

#include <any>
#include <functional>
#include <optional>

using node::NodeContext;

const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
UrlDecodeFn* const URL_DECODE = urlDecode;

#if HAVE_DECL_FORK
Expand Down Expand Up @@ -112,11 +109,10 @@ int fork_daemon(bool nochdir, bool noclose, TokenPipeEnd& endpoint)

static bool ParseArgs(ArgsManager& args, int argc, char* argv[])
{
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
SetupServerArgs(args);
std::string error;
if (!args.ParseParameters(argc, argv, error)) {
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s", error)));
return InitError(strprintf("Error parsing command line arguments: %s", error));
}

if (auto error = common::InitConfig(args)) {
Expand All @@ -126,7 +122,7 @@ static bool ParseArgs(ArgsManager& args, int argc, char* argv[])
// Error out when loose non-argument tokens are encountered on command line
for (int i = 1; i < argc; i++) {
if (!IsSwitchChar(argv[i][0])) {
return InitError(Untranslated(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.", argv[i])));
return InitError(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.", argv[i]));
}
}
return true;
Expand Down Expand Up @@ -169,7 +165,6 @@ static bool AppInit(NodeContext& node)
std::any context{&node};
try
{
// -server defaults to true for bitcoind but not for the GUI so do this here
args.SoftSetBoolArg("-server", true);
// Set this early so that parameter interactions go to console
InitLogging(args);
Expand Down Expand Up @@ -204,7 +199,7 @@ static bool AppInit(NodeContext& node)
}
break;
case -1: // Error happened.
return InitError(Untranslated(strprintf("fork_daemon() failed: %s", SysErrorString(errno))));
return InitError(strprintf("fork_daemon() failed: %s", SysErrorString(errno)));
default: { // Parent: wait and exit.
int token = daemon_ep.TokenRead();
if (token) { // Success
Expand Down
19 changes: 8 additions & 11 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <clientversion.h>
#include <util/translation.h>

#include <tinyformat.h>

Expand All @@ -12,9 +11,7 @@
#include <vector>

/**
* Name of client reported in the 'version' message. Report the same name
* for both bitcoind and bitcoin-qt, to make it harder for attackers to
* target servers or GUI users specifically.
* Name of client reported in the 'version' message.
*/
const std::string CLIENT_NAME("Satoshi");

Expand Down Expand Up @@ -79,7 +76,7 @@ std::string FormatSubVersion(const std::string& name, int nClientVersion, const

std::string CopyrightHolders(const std::string& strPrefix)
{
const auto copyright_devs = strprintf(_(COPYRIGHT_HOLDERS).translated, COPYRIGHT_HOLDERS_SUBSTITUTION);
const auto copyright_devs = strprintf(COPYRIGHT_HOLDERS, COPYRIGHT_HOLDERS_SUBSTITUTION);
std::string strCopyrightHolders = strPrefix + copyright_devs;

// Make sure Bitcoin Core copyright is not removed by accident
Expand All @@ -93,15 +90,15 @@ std::string LicenseInfo()
{
const std::string URL_SOURCE_CODE = "<https://github.com/bitcoin/bitcoin>";

return CopyrightHolders(strprintf(_("Copyright (C) %i-%i").translated, 2009, COPYRIGHT_YEAR) + " ") + "\n" +
return CopyrightHolders(strprintf("Copyright (C) %i-%i", 2009, COPYRIGHT_YEAR) + " ") + "\n" +
"\n" +
strprintf(_("Please contribute if you find %s useful. "
"Visit %s for further information about the software.").translated, PACKAGE_NAME, "<" PACKAGE_URL ">") +
strprintf("Please contribute if you find %s useful. "
"Visit %s for further information about the software.", PACKAGE_NAME, "<" PACKAGE_URL ">") +
"\n" +
strprintf(_("The source code is available from %s.").translated, URL_SOURCE_CODE) +
strprintf("The source code is available from %s.", URL_SOURCE_CODE) +
"\n" +
"\n" +
_("This is experimental software.").translated + "\n" +
strprintf(_("Distributed under the MIT software license, see the accompanying file %s or %s").translated, "COPYING", "<https://opensource.org/licenses/MIT>") +
"This is experimental software." + "\n" +
strprintf("Distributed under the MIT software license, see the accompanying file %s or %s", "COPYING", "<https://opensource.org/licenses/MIT>") +
"\n";
}
2 changes: 1 addition & 1 deletion src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ const Coin& AccessByTxid(const CCoinsViewCache& cache, const Txid& txid);
/**
* This is a minimally invasive approach to shutdown on LevelDB read errors from the
* chainstate, while keeping user interface out of the common library, which is shared
* between bitcoind, and bitcoin-qt and non-server tools.
* between bitcoind and non-server tools.
*
* Writes do not need similar protection, as failure to write is handled by the caller.
*/
Expand Down
13 changes: 6 additions & 7 deletions src/common/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <logging.h>
#include <tinyformat.h>
#include <util/fs.h>
#include <util/translation.h>

#include <algorithm>
#include <exception>
Expand All @@ -19,7 +18,7 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting
{
try {
if (!CheckDataDirOption(args)) {
return ConfigError{ConfigStatus::FAILED, strprintf(_("Specified data directory \"%s\" does not exist."), args.GetArg("-datadir", ""))};
return ConfigError{ConfigStatus::FAILED, strprintf("Specified data directory \"%s\" does not exist.", args.GetArg("-datadir", ""))};
}

// Record original datadir and config paths before parsing the config
Expand All @@ -36,7 +35,7 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting

std::string error;
if (!args.ReadConfigFiles(error, true)) {
return ConfigError{ConfigStatus::FAILED, strprintf(_("Error reading configuration file: %s"), error)};
return ConfigError{ConfigStatus::FAILED, strprintf("Error reading configuration file: %s", error)};
}

// Check for chain settings (Params() calls are only valid after this clause)
Expand Down Expand Up @@ -84,15 +83,15 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting
if (args.GetBoolArg("-allowignoredconf", false)) {
LogPrintf("Warning: %s\n", error);
} else {
return ConfigError{ConfigStatus::FAILED, Untranslated(error)};
return ConfigError{ConfigStatus::FAILED, error};
}
}

// Create settings.json if -nosettings was not specified.
if (args.GetSettingsPath()) {
std::vector<std::string> details;
if (!args.ReadSettingsFile(&details)) {
const bilingual_str& message = _("Settings file could not be read");
const std::string& message = "Settings file could not be read";
if (!settings_abort_fn) {
return ConfigError{ConfigStatus::FAILED, message, details};
} else if (settings_abort_fn(message, details)) {
Expand All @@ -102,12 +101,12 @@ std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn setting
}
}
if (!args.WriteSettingsFile(&details)) {
const bilingual_str& message = _("Settings file could not be written");
const std::string& message = "Settings file could not be written";
return ConfigError{ConfigStatus::FAILED_WRITE, message, details};
}
}
} catch (const std::exception& e) {
return ConfigError{ConfigStatus::FAILED, Untranslated(e.what())};
return ConfigError{ConfigStatus::FAILED, e.what()};
}
return {};
}
Expand Down
5 changes: 2 additions & 3 deletions src/common/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef BITCOIN_COMMON_INIT_H
#define BITCOIN_COMMON_INIT_H

#include <util/translation.h>

#include <functional>
#include <optional>
Expand All @@ -23,14 +22,14 @@ enum class ConfigStatus {

struct ConfigError {
ConfigStatus status;
bilingual_str message{};
std::string message{};
std::vector<std::string> details{};
};

//! Callback function to let the user decide whether to abort loading if
//! settings.json file exists and can't be parsed, or to ignore the error and
//! overwrite the file.
using SettingsAbortFn = std::function<bool(const bilingual_str& message, const std::vector<std::string>& details)>;
using SettingsAbortFn = std::function<bool(const std::string& message, const std::vector<std::string>& details)>;

/* Read config files, and create datadir and settings.json if they don't exist. */
std::optional<ConfigError> InitConfig(ArgsManager& args, SettingsAbortFn settings_abort_fn = nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/core_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ util::Result<int> SighashFromStr(const std::string& sighash)
if (it != map_sighash_values.end()) {
return it->second;
} else {
return util::Error{Untranslated(sighash + " is not a valid sighash parameter.")};
return util::Error{sighash + " is not a valid sighash parameter."};
}
}
Loading

0 comments on commit 4927a70

Please sign in to comment.