Skip to content

Commit

Permalink
Merge bitcoin#16224: gui: Bilingual GUI error messages
Browse files Browse the repository at this point in the history
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

# Conflicts:
#	src/dashd.cpp
#	src/httpserver.cpp
#	src/index/base.cpp
#	src/init.cpp
#	src/interfaces/chain.cpp
#	src/interfaces/chain.h
#	src/interfaces/node.cpp
#	src/net.h
#	src/qt/bitcoingui.cpp
#	src/ui_interface.h
#	src/wallet/init.cpp
#	src/wallet/load.cpp
  • Loading branch information
MarcoFalke authored and PastaPastaPasta committed Apr 5, 2022
1 parent 59eb127 commit 7a6f894
Show file tree
Hide file tree
Showing 23 changed files with 202 additions and 179 deletions.
3 changes: 2 additions & 1 deletion doc/translation_strings_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ On a high level, these strings are to be translated:

### GUI strings

Anything that appears to the user in the GUI is to be translated. This includes labels, menu items, button texts, tooltips and window titles.
Do not translate technical or extremely rare errors.
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.
This includes messages passed to the GUI through the UI interface through `InitMessage`, `ThreadSafeMessageBox` or `ShowProgress`.

General recommendations
Expand Down
14 changes: 7 additions & 7 deletions src/dashd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static bool AppInit(int argc, char* argv[])
SetupServerArgs();
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
return InitError(strprintf("Error parsing command line arguments: %s\n", error));
return InitError(Untranslated(strprintf("Error parsing command line arguments: %s\n", error)));
}

if (gArgs.IsArgSet("-printcrashinfo")) {
Expand Down Expand Up @@ -87,10 +87,10 @@ static bool AppInit(int argc, char* argv[])
bool datadirFromCmdLine = gArgs.IsArgSet("-datadir");
if (datadirFromCmdLine && !fs::is_directory(GetDataDir(false)))
{
return InitError(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")));
return InitError(Untranslated(strprintf("Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", ""))));
}
if (!gArgs.ReadConfigFiles(error, true)) {
return InitError(strprintf("Error reading configuration file: %s\n", error));
return InitError(Untranslated(strprintf("Error reading configuration file: %s\n", error)));
}
if (!datadirFromCmdLine && !fs::is_directory(GetDataDir(false)))
{
Expand All @@ -101,13 +101,13 @@ static bool AppInit(int argc, char* argv[])
try {
SelectParams(gArgs.GetChainName());
} catch (const std::exception& e) {
return InitError(strprintf("%s\n", e.what()));
return InitError(Untranslated(strprintf("%s\n", e.what())));
}

// 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(strprintf("Command line contains unexpected token '%s', see dashd -h for a list of options.\n", argv[i]));
return InitError(Untranslated(strprintf("Command line contains unexpected token '%s', see dashd -h for a list of options.\n", argv[i])));
}
}

Expand Down Expand Up @@ -142,13 +142,13 @@ static bool AppInit(int argc, char* argv[])

// Daemonize
if (daemon(1, 0)) { // don't chdir (1), do close FDs (0)
return InitError(strprintf("daemon() failed: %s\n", strerror(errno)));
return InitError(Untranslated(strprintf("daemon() failed: %s\n", strerror(errno))));
}
#if defined(MAC_OSX)
#pragma GCC diagnostic pop
#endif
#else
return InitError("-daemon is not supported on this operating system\n");
return InitError(Untranslated("-daemon is not supported on this operating system\n"));
#endif // HAVE_DECL_DAEMON
}
// Lock data directory after daemonization
Expand Down
2 changes: 1 addition & 1 deletion src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ static bool InitRPCAuthentication()
LogPrintf("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;
}
Expand Down
9 changes: 5 additions & 4 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
#include <httpserver.h>

#include <chainparamsbase.h>
#include <util/system.h>
#include <util/strencodings.h>
#include <util/threadnames.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 <stdio.h>
Expand Down Expand Up @@ -173,7 +174,7 @@ static bool InitHTTPAllowList()
LookupSubNet(strAllow.c_str(), 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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/index/base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <shutdown.h>
#include <tinyformat.h>
#include <ui_interface.h>
#include <util/translation.h>
#include <validation.h>
#include <warnings.h>

Expand All @@ -22,7 +23,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();
}
Expand Down
Loading

0 comments on commit 7a6f894

Please sign in to comment.