diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-04-30 16:34:45 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-04-30 16:37:18 +0200 |
commit | 8a10000222cb49eb253b41802ecf312adaf79439 (patch) | |
tree | d3f87f54b5e8e138e65e6fcb945dd1c8ef28e469 /src/util.h | |
parent | f026ab606d7bc317a725888296921df961d26208 (diff) | |
parent | b74dcb3b4aa29958d22135f2d6c015578069e83c (diff) |
Merge pull request #6022
b74dcb3 Separate CTranslationInterface from CClientUIInterface (Jorge Timón)
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 20 |
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(); |