aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2019-06-28 11:49:40 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2019-07-24 16:33:20 +0300
commit7c45e14f2f682eddcc853c0f6051c7c8c6387289 (patch)
treec58d7f247fe7727eb124e35a04d0f83779311833 /src
parent0b86e517ad733c8740c519332aa4c0e9035dbaab (diff)
Add bilingual message type
Diffstat (limited to 'src')
-rw-r--r--src/util/translation.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util/translation.h b/src/util/translation.h
index d709b26890..c70508c01e 100644
--- a/src/util/translation.h
+++ b/src/util/translation.h
@@ -5,6 +5,28 @@
#ifndef BITCOIN_UTIL_TRANSLATION_H
#define BITCOIN_UTIL_TRANSLATION_H
+#include <tinyformat.h>
+
+#include <utility>
+
+/**
+ * Bilingual messages:
+ * - in GUI: user's native language + untranslated (i.e. English)
+ * - in log and stderr: untranslated only
+ */
+struct bilingual_str {
+ std::string original;
+ std::string translated;
+};
+
+namespace tinyformat {
+template <typename... Args>
+bilingual_str format(const bilingual_str& fmt, const Args&... args)
+{
+ return bilingual_str{format(fmt.original, args...), format(fmt.translated, args...)};
+}
+} // namespace tinyformat
+
/** Translate a message to the native language of the user. */
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;