diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-06-10 11:21:40 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-06-10 15:01:09 +0300 |
commit | 38e33aa481cefbe12c50f344bae190c0d95fb489 (patch) | |
tree | e07340819a06b3fb96c9e64613749f07112930dd | |
parent | 20e95313790c75631e44f9572a2f8767685c52d6 (diff) | |
download | bitcoin-38e33aa481cefbe12c50f344bae190c0d95fb489.tar.xz |
refactor: Make GetWarnings() bilingual_str aware internally
-rw-r--r-- | src/warnings.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/warnings.cpp b/src/warnings.cpp index e04e800687..0c645de2ba 100644 --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -6,9 +6,12 @@ #include <warnings.h> #include <sync.h> +#include <util/string.h> #include <util/system.h> #include <util/translation.h> +#include <vector> + 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 = "<hr />"; + bilingual_str warnings_concise; + std::vector<bilingual_str> 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 Join(warnings_verbose, Untranslated("<hr />")).translated; } - if (verbose) return warnings_verbose; - else return warnings_concise; + return warnings_concise.original; } |