aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorJorge Timón <jtimon@jtimon.cc>2015-04-16 16:20:01 +0200
committerJorge Timón <jtimon@jtimon.cc>2015-04-16 19:58:48 +0200
commitb74dcb3b4aa29958d22135f2d6c015578069e83c (patch)
tree3c7555117404c14c54be2415c00d6a7b65e951da /src/util.h
parent8f955b9661224adc950e302b42d2f7bcb5e90bef (diff)
downloadbitcoin-b74dcb3b4aa29958d22135f2d6c015578069e83c.tar.xz
Separate CTranslationInterface from CClientUIInterface
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 9b5a4153dd..483d9d7858 100644
--- a/src/util.h
+++ b/src/util.h
@@ -25,8 +25,17 @@
#include <vector>
#include <boost/filesystem/path.hpp>
+#include <boost/signals2/signal.hpp>
#include <boost/thread/exceptions.hpp>
+/** Signals for translation. */
+class CTranslationInterface
+{
+public:
+ /** Translate a message to the native language of the user. */
+ boost::signals2::signal<std::string (const char* psz)> Translate;
+};
+
extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
extern bool fDebug;
@@ -37,6 +46,17 @@ extern std::string strMiscWarning;
extern bool fLogTimestamps;
extern bool fLogIPs;
extern volatile bool fReopenDebugLog;
+extern CTranslationInterface translationInterface;
+
+/**
+ * Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
+ * If no translation slot is registered, nothing is returned, and simply return the input.
+ */
+inline std::string _(const char* psz)
+{
+ boost::optional<std::string> rv = translationInterface.Translate(psz);
+ return rv ? (*rv) : psz;
+}
void SetupEnvironment();