aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-08-19 18:12:35 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-05-01 07:39:00 -0400
commitfae51a5c6f4270a1088e6295b10a8cc45988ae46 (patch)
tree1367e0780ab7e2fda2cb1cd46174029515d098f2 /src/util
parent608359b071dac82a9cf33a6c9e01f87abfcb90eb (diff)
wallet: Avoid translating RPC errors when loading wallets
Common errors and warnings should be translated when displayed in the GUI, but not translated when displayed elsewhere. The wallet method CreateWalletFromFile does not know its caller, so this commit changes it to return a bilingual_str to the caller.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/translation.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/translation.h b/src/util/translation.h
index fc45da440a..b2d964c977 100644
--- a/src/util/translation.h
+++ b/src/util/translation.h
@@ -18,6 +18,20 @@ struct bilingual_str {
std::string translated;
};
+inline bilingual_str operator+(const bilingual_str& lhs, const bilingual_str& rhs)
+{
+ return bilingual_str{
+ lhs.original + rhs.original,
+ lhs.translated + rhs.translated};
+}
+
+/** Mark a bilingual_str as untranslated */
+inline static bilingual_str Untranslated(std::string original) { return {original, original}; }
+/** Unary operator to return the original */
+inline static std::string OpOriginal(const bilingual_str& b) { return b.original; }
+/** Unary operator to return the translation */
+inline static std::string OpTranslated(const bilingual_str& b) { return b.translated; }
+
namespace tinyformat {
template <typename... Args>
bilingual_str format(const bilingual_str& fmt, const Args&... args)