Skip to content

Commit 38e33aa

Browse files
committed
refactor: Make GetWarnings() bilingual_str aware internally
1 parent 20e9531 commit 38e33aa

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/warnings.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
#include <warnings.h>
77

88
#include <sync.h>
9+
#include <util/string.h>
910
#include <util/system.h>
1011
#include <util/translation.h>
1112

13+
#include <vector>
14+
1215
static Mutex g_warnings_mutex;
1316
static std::string strMiscWarning GUARDED_BY(g_warnings_mutex);
1417
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
@@ -40,32 +43,34 @@ void SetfLargeWorkInvalidChainFound(bool flag)
4043

4144
std::string GetWarnings(bool verbose)
4245
{
43-
std::string warnings_concise;
44-
std::string warnings_verbose;
45-
const std::string warning_separator = "<hr />";
46+
bilingual_str warnings_concise;
47+
std::vector<bilingual_str> warnings_verbose;
4648

4749
LOCK(g_warnings_mutex);
4850

4951
// Pre-release build warning
5052
if (!CLIENT_VERSION_IS_RELEASE) {
51-
warnings_concise = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications";
52-
warnings_verbose = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications").translated;
53+
warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications");
54+
warnings_verbose.emplace_back(warnings_concise);
5355
}
5456

5557
// Misc warnings like out of disk space and clock is wrong
56-
if (strMiscWarning != "") {
57-
warnings_concise = strMiscWarning;
58-
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + strMiscWarning;
58+
if (!strMiscWarning.empty()) {
59+
warnings_concise = Untranslated(strMiscWarning);
60+
warnings_verbose.emplace_back(warnings_concise);
5961
}
6062

6163
if (fLargeWorkForkFound) {
62-
warnings_concise = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.";
63-
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated;
64+
warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.");
65+
warnings_verbose.emplace_back(warnings_concise);
6466
} else if (fLargeWorkInvalidChainFound) {
65-
warnings_concise = "Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.";
66-
warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.").translated;
67+
warnings_concise = _("Warning: We do not appear to fully agree with our peers! You may need to upgrade, or other nodes may need to upgrade.");
68+
warnings_verbose.emplace_back(warnings_concise);
69+
}
70+
71+
if (verbose) {
72+
return Join(warnings_verbose, Untranslated("<hr />")).translated;
6773
}
6874

69-
if (verbose) return warnings_verbose;
70-
else return warnings_concise;
75+
return warnings_concise.original;
7176
}

0 commit comments

Comments
 (0)