aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-04-11 18:47:17 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-05-05 04:45:59 +0300
commit917ca93553917251e0fd59717a347c63cdfd8a14 (patch)
tree6dd3c84f09109c1da19d1a23e798a32efdafa9a9 /src
parent23b9fa2e5ec0425980301d2eebad81e660a5ea39 (diff)
downloadbitcoin-917ca93553917251e0fd59717a347c63cdfd8a14.tar.xz
Make ThreadSafe{MessageBox|Question} bilingual
Diffstat (limited to 'src')
-rw-r--r--src/httprpc.cpp2
-rw-r--r--src/httpserver.cpp9
-rw-r--r--src/index/base.cpp3
-rw-r--r--src/init.cpp32
-rw-r--r--src/interfaces/node.h4
-rw-r--r--src/net.cpp27
-rw-r--r--src/net.h5
-rw-r--r--src/noui.cpp19
-rw-r--r--src/noui.h6
-rw-r--r--src/qt/bitcoingui.cpp14
-rw-r--r--src/timedata.cpp4
-rw-r--r--src/ui_interface.cpp10
-rw-r--r--src/ui_interface.h6
-rw-r--r--src/validation.cpp5
14 files changed, 82 insertions, 64 deletions
diff --git a/src/httprpc.cpp b/src/httprpc.cpp
index 60c4d06f12..3c3e6e5bba 100644
--- a/src/httprpc.cpp
+++ b/src/httprpc.cpp
@@ -252,7 +252,7 @@ static bool InitRPCAuthentication()
LogPrintf("No rpcpassword set - using random cookie authentication.\n");
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
uiInterface.ThreadSafeMessageBox(
- _("Error: A fatal internal error occurred, see debug.log for details").translated, // Same message as AbortNode
+ _("Error: A fatal internal error occurred, see debug.log for details"), // Same message as AbortNode
"", CClientUIInterface::MSG_ERROR);
return false;
}
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 176284d103..ffe246b241 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -6,14 +6,15 @@
#include <chainparamsbase.h>
#include <compat.h>
-#include <util/threadnames.h>
-#include <util/system.h>
-#include <util/strencodings.h>
#include <netbase.h>
#include <rpc/protocol.h> // For HTTP status codes
#include <shutdown.h>
#include <sync.h>
#include <ui_interface.h>
+#include <util/strencodings.h>
+#include <util/system.h>
+#include <util/threadnames.h>
+#include <util/translation.h>
#include <deque>
#include <memory>
@@ -175,7 +176,7 @@ static bool InitHTTPAllowList()
LookupSubNet(strAllow, subnet);
if (!subnet.IsValid()) {
uiInterface.ThreadSafeMessageBox(
- strprintf("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24).", strAllow),
+ strprintf(Untranslated("Invalid -rpcallowip subnet specification: %s. Valid are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24)."), strAllow),
"", CClientUIInterface::MSG_ERROR);
return false;
}
diff --git a/src/index/base.cpp b/src/index/base.cpp
index 7bff463f5b..74ea421e13 100644
--- a/src/index/base.cpp
+++ b/src/index/base.cpp
@@ -8,6 +8,7 @@
#include <tinyformat.h>
#include <ui_interface.h>
#include <util/system.h>
+#include <util/translation.h>
#include <validation.h>
#include <warnings.h>
@@ -23,7 +24,7 @@ static void FatalError(const char* fmt, const Args&... args)
SetMiscWarning(strMessage);
LogPrintf("*** %s\n", strMessage);
uiInterface.ThreadSafeMessageBox(
- "Error: A fatal internal error occurred, see debug.log for details",
+ Untranslated("Error: A fatal internal error occurred, see debug.log for details"),
"", CClientUIInterface::MSG_ERROR);
StartShutdown();
}
diff --git a/src/init.cpp b/src/init.cpp
index 3e2ee4d425..51c80d1e2c 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -1542,7 +1542,7 @@ bool AppInitMain(NodeContext& node)
auto is_coinsview_empty = [&](CChainState* chainstate) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
return fReset || fReindexChainState || chainstate->CoinsTip().GetBestBlock().IsNull();
};
- std::string strLoadError;
+ bilingual_str strLoadError;
uiInterface.InitMessage(_("Loading block index...").translated);
@@ -1573,7 +1573,7 @@ bool AppInitMain(NodeContext& node)
// From here on out fReindex and fReset mean something different!
if (!LoadBlockIndex(chainparams)) {
if (ShutdownRequested()) break;
- strLoadError = _("Error loading block database").translated;
+ strLoadError = _("Error loading block database");
break;
}
@@ -1587,7 +1587,7 @@ bool AppInitMain(NodeContext& node)
// Check for changed -prune state. What we are concerned about is a user who has pruned blocks
// in the past, but is now trying to run unpruned.
if (fHavePruned && !fPruneMode) {
- strLoadError = _("You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain").translated;
+ strLoadError = _("You need to rebuild the database using -reindex to go back to unpruned mode. This will redownload the entire blockchain");
break;
}
@@ -1596,7 +1596,7 @@ bool AppInitMain(NodeContext& node)
// (otherwise we use the one already on disk).
// This is called again in ThreadImport after the reindex completes.
if (!fReindex && !LoadGenesisBlock(chainparams)) {
- strLoadError = _("Error initializing block database").translated;
+ strLoadError = _("Error initializing block database");
break;
}
@@ -1614,21 +1614,21 @@ bool AppInitMain(NodeContext& node)
chainstate->CoinsErrorCatcher().AddReadErrCallback([]() {
uiInterface.ThreadSafeMessageBox(
- _("Error reading from database, shutting down.").translated,
+ _("Error reading from database, shutting down."),
"", CClientUIInterface::MSG_ERROR);
});
// If necessary, upgrade from older database format.
// This is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
if (!chainstate->CoinsDB().Upgrade()) {
- strLoadError = _("Error upgrading chainstate database").translated;
+ strLoadError = _("Error upgrading chainstate database");
failed_chainstate_init = true;
break;
}
// ReplayBlocks is a no-op if we cleared the coinsviewdb with -reindex or -reindex-chainstate
if (!chainstate->ReplayBlocks(chainparams)) {
- strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.").translated;
+ strLoadError = _("Unable to replay blocks. You will need to rebuild the database using -reindex-chainstate.");
failed_chainstate_init = true;
break;
}
@@ -1640,7 +1640,7 @@ bool AppInitMain(NodeContext& node)
if (!is_coinsview_empty(chainstate)) {
// LoadChainTip initializes the chain based on CoinsTip()'s best block
if (!chainstate->LoadChainTip(chainparams)) {
- strLoadError = _("Error initializing block database").translated;
+ strLoadError = _("Error initializing block database");
failed_chainstate_init = true;
break; // out of the per-chainstate loop
}
@@ -1653,7 +1653,7 @@ bool AppInitMain(NodeContext& node)
}
} catch (const std::exception& e) {
LogPrintf("%s\n", e.what());
- strLoadError = _("Error opening block database").translated;
+ strLoadError = _("Error opening block database");
break;
}
@@ -1669,7 +1669,7 @@ bool AppInitMain(NodeContext& node)
if (!chainstate->RewindBlockIndex(chainparams)) {
strLoadError = _(
"Unable to rewind the database to a pre-fork state. "
- "You will need to redownload the blockchain").translated;
+ "You will need to redownload the blockchain");
failed_rewind = true;
break; // out of the per-chainstate loop
}
@@ -1698,7 +1698,7 @@ bool AppInitMain(NodeContext& node)
if (tip && tip->nTime > GetAdjustedTime() + 2 * 60 * 60) {
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;
+ "Only rebuild the block database if you are sure that your computer's date and time are correct");
failed_verification = true;
break;
}
@@ -1710,7 +1710,7 @@ bool AppInitMain(NodeContext& node)
chainparams, &chainstate->CoinsDB(),
gArgs.GetArg("-checklevel", DEFAULT_CHECKLEVEL),
gArgs.GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
- strLoadError = _("Corrupted block database detected").translated;
+ strLoadError = _("Corrupted block database detected");
failed_verification = true;
break;
}
@@ -1718,7 +1718,7 @@ bool AppInitMain(NodeContext& node)
}
} catch (const std::exception& e) {
LogPrintf("%s\n", e.what());
- strLoadError = _("Error opening block database").translated;
+ strLoadError = _("Error opening block database");
failed_verification = true;
break;
}
@@ -1733,8 +1733,8 @@ bool AppInitMain(NodeContext& node)
// first suggest a reindex
if (!fReset) {
bool fRet = uiInterface.ThreadSafeQuestion(
- strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?").translated,
- strLoadError + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
+ strLoadError + Untranslated(".\n\n") + _("Do you want to rebuild the block database now?"),
+ strLoadError.original + ".\nPlease restart with -reindex or -reindex-chainstate to recover.",
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT);
if (fRet) {
fReindex = true;
@@ -1744,7 +1744,7 @@ bool AppInitMain(NodeContext& node)
return false;
}
} else {
- return InitError(strLoadError);
+ return InitError(strLoadError.translated);
}
}
}
diff --git a/src/interfaces/node.h b/src/interfaces/node.h
index db9b42b293..aef6b19458 100644
--- a/src/interfaces/node.h
+++ b/src/interfaces/node.h
@@ -213,11 +213,11 @@ public:
//! Register handler for message box messages.
using MessageBoxFn =
- std::function<bool(const std::string& message, const std::string& caption, unsigned int style)>;
+ std::function<bool(const bilingual_str& message, const std::string& caption, unsigned int style)>;
virtual std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) = 0;
//! Register handler for question messages.
- using QuestionFn = std::function<bool(const std::string& message,
+ using QuestionFn = std::function<bool(const bilingual_str& message,
const std::string& non_interactive_message,
const std::string& caption,
unsigned int style)>;
diff --git a/src/net.cpp b/src/net.cpp
index dcc613ba88..97b80b50e2 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2068,9 +2068,8 @@ void CConnman::ThreadMessageHandler()
-bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, NetPermissionFlags permissions)
+bool CConnman::BindListenPort(const CService& addrBind, bilingual_str& strError, NetPermissionFlags permissions)
{
- strError = "";
int nOne = 1;
// Create socket for listening for incoming connections
@@ -2078,16 +2077,16 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
socklen_t len = sizeof(sockaddr);
if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len))
{
- strError = strprintf("Error: Bind address family for %s not supported", addrBind.ToString());
- LogPrintf("%s\n", strError);
+ strError = strprintf(Untranslated("Error: Bind address family for %s not supported"), addrBind.ToString());
+ LogPrintf("%s\n", strError.original);
return false;
}
SOCKET hListenSocket = CreateSocket(addrBind);
if (hListenSocket == INVALID_SOCKET)
{
- strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %s)", NetworkErrorString(WSAGetLastError()));
- LogPrintf("%s\n", strError);
+ strError = strprintf(Untranslated("Error: Couldn't open socket for incoming connections (socket returned error %s)"), NetworkErrorString(WSAGetLastError()));
+ LogPrintf("%s\n", strError.original);
return false;
}
@@ -2111,10 +2110,10 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
{
int nErr = WSAGetLastError();
if (nErr == WSAEADDRINUSE)
- strError = strprintf(_("Unable to bind to %s on this computer. %s is probably already running.").translated, addrBind.ToString(), PACKAGE_NAME);
+ strError = strprintf(_("Unable to bind to %s on this computer. %s is probably already running."), addrBind.ToString(), PACKAGE_NAME);
else
- strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)").translated, addrBind.ToString(), NetworkErrorString(nErr));
- LogPrintf("%s\n", strError);
+ strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr));
+ LogPrintf("%s\n", strError.original);
CloseSocket(hListenSocket);
return false;
}
@@ -2123,8 +2122,8 @@ bool CConnman::BindListenPort(const CService& addrBind, std::string& strError, N
// Listen for incoming connections
if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR)
{
- strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)").translated, NetworkErrorString(WSAGetLastError()));
- LogPrintf("%s\n", strError);
+ strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError()));
+ LogPrintf("%s\n", strError.original);
CloseSocket(hListenSocket);
return false;
}
@@ -2218,7 +2217,7 @@ NodeId CConnman::GetNewNodeId()
bool CConnman::Bind(const CService &addr, unsigned int flags, NetPermissionFlags permissions) {
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
return false;
- std::string strError;
+ bilingual_str strError;
if (!BindListenPort(addr, strError, permissions)) {
if ((flags & BF_REPORT_ERROR) && clientInterface) {
clientInterface->ThreadSafeMessageBox(strError, "", CClientUIInterface::MSG_ERROR);
@@ -2265,7 +2264,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
if (fListen && !InitBinds(connOptions.vBinds, connOptions.vWhiteBinds)) {
if (clientInterface) {
clientInterface->ThreadSafeMessageBox(
- _("Failed to listen on any port. Use -listen=0 if you want this.").translated,
+ _("Failed to listen on any port. Use -listen=0 if you want this."),
"", CClientUIInterface::MSG_ERROR);
}
return false;
@@ -2331,7 +2330,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing.empty()) {
if (clientInterface) {
clientInterface->ThreadSafeMessageBox(
- _("Cannot provide specific connections and have addrman find outgoing connections at the same.").translated,
+ _("Cannot provide specific connections and have addrman find outgoing connections at the same."),
"", CClientUIInterface::MSG_ERROR);
}
return false;
diff --git a/src/net.h b/src/net.h
index 0d79efbba7..35d442e61f 100644
--- a/src/net.h
+++ b/src/net.h
@@ -21,8 +21,8 @@
#include <random.h>
#include <streams.h>
#include <sync.h>
-#include <uint256.h>
#include <threadinterrupt.h>
+#include <uint256.h>
#include <atomic>
#include <deque>
@@ -39,6 +39,7 @@
class CScheduler;
class CNode;
class BanMan;
+struct bilingual_str;
/** Default for -whitelistrelay. */
static const bool DEFAULT_WHITELISTRELAY = true;
@@ -334,7 +335,7 @@ private:
NetPermissionFlags m_permissions;
};
- bool BindListenPort(const CService& bindAddr, std::string& strError, NetPermissionFlags permissions);
+ bool BindListenPort(const CService& bindAddr, bilingual_str& strError, NetPermissionFlags permissions);
bool Bind(const CService& addr, unsigned int flags, NetPermissionFlags permissions);
bool InitBinds(const std::vector<CService>& binds, const std::vector<NetWhitebindPermissions>& whiteBinds);
void ThreadOpenAddedConnections();
diff --git a/src/noui.cpp b/src/noui.cpp
index 11cfe7f94d..ddb3a50ff7 100644
--- a/src/noui.cpp
+++ b/src/noui.cpp
@@ -5,8 +5,9 @@
#include <noui.h>
+#include <logging.h>
#include <ui_interface.h>
-#include <util/system.h>
+#include <util/translation.h>
#include <string>
@@ -18,7 +19,7 @@ boost::signals2::connection noui_ThreadSafeMessageBoxConn;
boost::signals2::connection noui_ThreadSafeQuestionConn;
boost::signals2::connection noui_InitMessageConn;
-bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
+bool noui_ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style)
{
bool fSecure = style & CClientUIInterface::SECURE;
style &= ~CClientUIInterface::SECURE;
@@ -43,15 +44,15 @@ bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& ca
}
if (!fSecure) {
- LogPrintf("%s%s\n", strCaption, message);
+ LogPrintf("%s%s\n", strCaption, message.original);
}
- tfm::format(std::cerr, "%s%s\n", strCaption, message);
+ tfm::format(std::cerr, "%s%s\n", strCaption, message.original);
return false;
}
-bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
+bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
{
- return noui_ThreadSafeMessageBox(message, caption, style);
+ return noui_ThreadSafeMessageBox(Untranslated(message), caption, style);
}
void noui_InitMessage(const std::string& message)
@@ -66,13 +67,13 @@ void noui_connect()
noui_InitMessageConn = uiInterface.InitMessage_connect(noui_InitMessage);
}
-bool noui_ThreadSafeMessageBoxRedirect(const std::string& message, const std::string& caption, unsigned int style)
+bool noui_ThreadSafeMessageBoxRedirect(const bilingual_str& message, const std::string& caption, unsigned int style)
{
- LogPrintf("%s: %s\n", caption, message);
+ LogPrintf("%s: %s\n", caption, message.original);
return false;
}
-bool noui_ThreadSafeQuestionRedirect(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
+bool noui_ThreadSafeQuestionRedirect(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style)
{
LogPrintf("%s: %s\n", caption, message);
return false;
diff --git a/src/noui.h b/src/noui.h
index 5e5767b453..8ec5708328 100644
--- a/src/noui.h
+++ b/src/noui.h
@@ -7,10 +7,12 @@
#include <string>
+struct bilingual_str;
+
/** Non-GUI handler, which logs and prints messages. */
-bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style);
+bool noui_ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style);
/** Non-GUI handler, which logs and prints questions. */
-bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style);
+bool noui_ThreadSafeQuestion(const bilingual_str& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style);
/** Non-GUI handler, which only logs a message. */
void noui_InitMessage(const std::string& message);
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index c9248fde28..3a1fdc22a6 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -36,6 +36,7 @@
#include <interfaces/node.h>
#include <ui_interface.h>
#include <util/system.h>
+#include <util/translation.h>
#include <QAction>
#include <QApplication>
@@ -1369,20 +1370,27 @@ void BitcoinGUI::showModalOverlay()
modalOverlay->toggleVisibility();
}
-static bool ThreadSafeMessageBox(BitcoinGUI* gui, const std::string& message, const std::string& caption, unsigned int style)
+static bool ThreadSafeMessageBox(BitcoinGUI* gui, const bilingual_str& message, const std::string& caption, unsigned int style)
{
bool modal = (style & CClientUIInterface::MODAL);
// The SECURE flag has no effect in the Qt GUI.
// bool secure = (style & CClientUIInterface::SECURE);
style &= ~CClientUIInterface::SECURE;
bool ret = false;
+
+ QString detailed_message; // This is original message, in English, for googling and referencing.
+ if (message.original != message.translated) {
+ detailed_message = BitcoinGUI::tr("Original message:") + "\n" + QString::fromStdString(message.original);
+ }
+
// In case of modal message, use blocking connection to wait for user to click a button
bool invoked = QMetaObject::invokeMethod(gui, "message",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
- Q_ARG(QString, QString::fromStdString(message)),
+ Q_ARG(QString, QString::fromStdString(message.translated)),
Q_ARG(unsigned int, style),
- Q_ARG(bool*, &ret));
+ Q_ARG(bool*, &ret),
+ Q_ARG(QString, detailed_message));
assert(invoked);
return ret;
}
diff --git a/src/timedata.cpp b/src/timedata.cpp
index 942b3cb919..dd56acf44f 100644
--- a/src/timedata.cpp
+++ b/src/timedata.cpp
@@ -101,8 +101,8 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
if (!fMatch)
{
fDone = true;
- 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.").translated, PACKAGE_NAME);
- SetMiscWarning(strMessage);
+ bilingual_str strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), PACKAGE_NAME);
+ SetMiscWarning(strMessage.translated);
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
}
}
diff --git a/src/ui_interface.cpp b/src/ui_interface.cpp
index 85bb746d19..ec8c969fc5 100644
--- a/src/ui_interface.cpp
+++ b/src/ui_interface.cpp
@@ -4,6 +4,8 @@
#include <ui_interface.h>
+#include <util/translation.h>
+
#include <boost/signals2/last_value.hpp>
#include <boost/signals2/signal.hpp>
@@ -40,8 +42,8 @@ ADD_SIGNALS_IMPL_WRAPPER(NotifyBlockTip);
ADD_SIGNALS_IMPL_WRAPPER(NotifyHeaderTip);
ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged);
-bool CClientUIInterface::ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
-bool CClientUIInterface::ThreadSafeQuestion(const std::string& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); }
+bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style); }
+bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style); }
void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); }
void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); }
void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); }
@@ -54,11 +56,11 @@ void CClientUIInterface::BannedListChanged() { return g_ui_signals.BannedListCha
bool InitError(const std::string& str)
{
- uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR);
+ uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_ERROR);
return false;
}
void InitWarning(const std::string& str)
{
- uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
+ uiInterface.ThreadSafeMessageBox(Untranslated(str), "", CClientUIInterface::MSG_WARNING);
}
diff --git a/src/ui_interface.h b/src/ui_interface.h
index b402177b85..9e4290ae95 100644
--- a/src/ui_interface.h
+++ b/src/ui_interface.h
@@ -11,6 +11,8 @@
#include <string>
class CBlockIndex;
+struct bilingual_str;
+
namespace boost {
namespace signals2 {
class connection;
@@ -82,10 +84,10 @@ public:
boost::signals2::connection signal_name##_connect(std::function<signal_name##Sig> fn);
/** Show message box. */
- ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const std::string& message, const std::string& caption, unsigned int style);
+ ADD_SIGNALS_DECL_WRAPPER(ThreadSafeMessageBox, bool, const bilingual_str& message, const std::string& caption, unsigned int style);
/** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */
- ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const std::string& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style);
+ ADD_SIGNALS_DECL_WRAPPER(ThreadSafeQuestion, bool, const bilingual_str& message, const std::string& noninteractive_message, const std::string& caption, unsigned int style);
/** Progress message during initialization. */
ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message);
diff --git a/src/validation.cpp b/src/validation.cpp
index dac1ad40d3..a099e29772 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1651,14 +1651,15 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
}
/** Abort with a message */
+// TODO: AbortNode() should take bilingual_str userMessage parameter.
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
{
SetMiscWarning(strMessage);
LogPrintf("*** %s\n", strMessage);
if (!userMessage.empty()) {
- uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR | prefix);
+ uiInterface.ThreadSafeMessageBox(Untranslated(userMessage), "", CClientUIInterface::MSG_ERROR | prefix);
} else {
- uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details").translated, "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
+ uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
}
StartShutdown();
return false;