From 38e33aa481cefbe12c50f344bae190c0d95fb489 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 10 Jun 2020 11:21:40 +0300 Subject: [PATCH] refactor: Make GetWarnings() bilingual_str aware internally --- src/warnings.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/warnings.cpp b/src/warnings.cpp index e04e8006872..0c645de2ba3 100644 --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -6,9 +6,12 @@ #include #include +#include #include #include +#include + static Mutex g_warnings_mutex; static std::string strMiscWarning GUARDED_BY(g_warnings_mutex); static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false; @@ -40,32 +43,34 @@ void SetfLargeWorkInvalidChainFound(bool flag) std::string GetWarnings(bool verbose) { - std::string warnings_concise; - std::string warnings_verbose; - const std::string warning_separator = "
"; + bilingual_str warnings_concise; + std::vector warnings_verbose; LOCK(g_warnings_mutex); // Pre-release build warning if (!CLIENT_VERSION_IS_RELEASE) { - warnings_concise = "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"; - warnings_verbose = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications").translated; + warnings_concise = _("This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"); + warnings_verbose.emplace_back(warnings_concise); } // Misc warnings like out of disk space and clock is wrong - if (strMiscWarning != "") { - warnings_concise = strMiscWarning; - warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + strMiscWarning; + if (!strMiscWarning.empty()) { + warnings_concise = Untranslated(strMiscWarning); + warnings_verbose.emplace_back(warnings_concise); } if (fLargeWorkForkFound) { - warnings_concise = "Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues."; - warnings_verbose += (warnings_verbose.empty() ? "" : warning_separator) + _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues.").translated; + warnings_concise = _("Warning: The network does not appear to fully agree! Some miners appear to be experiencing issues."); + warnings_verbose.emplace_back(warnings_concise); } else if (fLargeWorkInvalidChainFound) { - 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."; - 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; + 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."); + warnings_verbose.emplace_back(warnings_concise); } - if (verbose) return warnings_verbose; - else return warnings_concise; + if (verbose) { + return Join(warnings_verbose, Untranslated("
")).translated; + } + + return warnings_concise.original; }