Skip to content

Commit 5b24f60

Browse files
author
MarcoFalke
committed
Merge bitcoin#16224: gui: Bilingual GUI error messages
18bd83b util: Cleanup translation.h (Hennadii Stepanov) e95e658 doc: Do not translate technical or extremely rare errors (Hennadii Stepanov) 7e923d4 Make InitError bilingual (Hennadii Stepanov) 917ca93 Make ThreadSafe{MessageBox|Question} bilingual (Hennadii Stepanov) 23b9fa2 gui: Add detailed text to BitcoinGUI::message (Hennadii Stepanov) Pull request description: This is an alternative to bitcoin#15340 (it works with the `Chain` interface; see: bitcoin#15340 (comment)). Refs: - bitcoin#16218 (partial fix) - bitcoin#15894 (comment) This PR: - makes GUI error messages bilingual: user's native language + untranslated (i.e. English) - insures that only untranslated messages are written to the debug log file and to `stderr` (that is not the case on master). If a translated string is unavailable only an English string appears to a user. Here are some **examples** (updated): ![Screenshot from 2020-04-24 17-08-37](https://user-images.githubusercontent.com/32963518/80222043-e2458780-864e-11ea-83fc-197b7121dba5.png) ![Screenshot from 2020-04-24 17-12-17](https://user-images.githubusercontent.com/32963518/80222051-e5407800-864e-11ea-92f7-dfef1144becd.png) * `qt5ct: using qt5ct plugin` message is my local environment specific; please ignore it. --- Note for reviewers: `InitWarning()` is out of this PR scope. ACKs for top commit: Sjors: re-tACK 18bd83b MarcoFalke: ACK 18bd83b 🐦 Tree-SHA512: 3cc8ec44f84403e54b57d11714c86b0855ed90eb794b5472e432005073354b9e3f7b4e8e7bf347a4c21be47299dbc7170f2d0c4b80e308205ff09596e55a4f96
2 parents 3930014 + 18bd83b commit 5b24f60

23 files changed

+166
-144
lines changed

doc/translation_strings_policy.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ On a high level, these strings are to be translated:
2323

2424
### GUI strings
2525

26-
Anything that appears to the user in the GUI is to be translated. This includes labels, menu items, button texts, tooltips and window titles.
26+
Do not translate technical or extremely rare errors.
27+
Anything else that appears to the user in the GUI is to be translated. This includes labels, menu items, button texts, tooltips and window titles.
2728
This includes messages passed to the GUI through the UI interface through `InitMessage`, `ThreadSafeMessageBox` or `ShowProgress`.
2829

2930
General recommendations

src/bitcoind.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static bool AppInit(int argc, char* argv[])
5656
SetupServerArgs(node);
5757
std::string error;
5858
if (!gArgs.ParseParameters(argc, argv, error)) {
59-
return InitError(strprintf("Error parsing command line arguments: %s\n", error));
59+
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));
6060
}
6161

6262
// Process help and version before taking care about datadir
@@ -80,22 +80,22 @@ static bool AppInit(int argc, char* argv[])
8080
try
8181
{
8282
if (!CheckDataDirOption()) {
83-
return InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
83+
return InitError(Untranslated(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))));
8484
}
8585
if (!gArgs.ReadConfigFiles(error, true)) {
86-
return InitError(strprintf("Error reading configuration file: %s\n", error));
86+
return InitError(Untranslated(strprintf("Error reading configuration file: %s\n", error)));
8787
}
8888
// Check for -chain, -testnet or -regtest parameter (Params() calls are only valid after this clause)
8989
try {
9090
SelectParams(gArgs.GetChainName());
9191
} catch (const std::exception& e) {
92-
return InitError(strprintf("%s\n", e.what()));
92+
return InitError(Untranslated(strprintf("%s\n", e.what())));
9393
}
9494

9595
// Error out when loose non-argument tokens are encountered on command line
9696
for (int i = 1; i < argc; i++) {
9797
if (!IsSwitchChar(argv[i][0])) {
98-
return InitError(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]));
98+
return InitError(Untranslated(strprintf("Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i])));
9999
}
100100
}
101101

@@ -130,13 +130,13 @@ static bool AppInit(int argc, char* argv[])
130130

131131
// Daemonize
132132
if (daemon(1, 0)) { // don't chdir (1), do close FDs (0)
133-
return InitError(strprintf("daemon() failed: %s\n", strerror(errno)));
133+
return InitError(Untranslated(strprintf("daemon() failed: %s\n", strerror(errno))));
134134
}
135135
#if defined(MAC_OSX)
136136
#pragma GCC diagnostic pop
137137
#endif
138138
#else
139-
return InitError("-daemon is not supported on this operating system\n");
139+
return InitError(Untranslated("-daemon is not supported on this operating system\n"));
140140
#endif // HAVE_DECL_DAEMON
141141
}
142142
// Lock data directory after daemonization

src/httprpc.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static bool InitRPCAuthentication()
252252
LogPrintf("No rpcpassword set - using random cookie authentication.\n");
253253
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
254254
uiInterface.ThreadSafeMessageBox(
255-
_("Error: A fatal internal error occurred, see debug.log for details").translated, // Same message as AbortNode
255+
_("Error: A fatal internal error occurred, see debug.log for details"), // Same message as AbortNode
256256
"", CClientUIInterface::MSG_ERROR);
257257
return false;
258258
}

src/httpserver.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66

77
#include <chainparamsbase.h>
88
#include <compat.h>
9-
#include <util/threadnames.h>
10-
#include <util/system.h>
11-
#include <util/strencodings.h>
129
#include <netbase.h>
1310
#include <rpc/protocol.h> // For HTTP status codes
1411
#include <shutdown.h>
1512
#include <sync.h>
1613
#include <ui_interface.h>
14+
#include <util/strencodings.h>
15+
#include <util/system.h>
16+
#include <util/threadnames.h>
17+
#include <util/translation.h>
1718

1819
#include <deque>
1920
#include <memory>
@@ -175,7 +176,7 @@ static bool InitHTTPAllowList()
175176
LookupSubNet(strAllow, subnet);
176177
if (!subnet.IsValid()) {
177178
uiInterface.ThreadSafeMessageBox(
178-
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),
179+
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),
179180
"", CClientUIInterface::MSG_ERROR);
180181
return false;
181182
}

src/index/base.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <tinyformat.h>
99
#include <ui_interface.h>
1010
#include <util/system.h>
11+
#include <util/translation.h>
1112
#include <validation.h>
1213
#include <warnings.h>
1314

@@ -23,7 +24,7 @@ static void FatalError(const char* fmt, const Args&... args)
2324
SetMiscWarning(strMessage);
2425
LogPrintf("*** %s\n", strMessage);
2526
uiInterface.ThreadSafeMessageBox(
26-
"Error: A fatal internal error occurred, see debug.log for details",
27+
Untranslated("Error: A fatal internal error occurred, see debug.log for details"),
2728
"", CClientUIInterface::MSG_ERROR);
2829
StartShutdown();
2930
}

0 commit comments

Comments
 (0)