From b74dcb3b4aa29958d22135f2d6c015578069e83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Tim=C3=B3n?= Date: Thu, 16 Apr 2015 16:20:01 +0200 Subject: Separate CTranslationInterface from CClientUIInterface --- src/util.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/util.h') 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 #include +#include #include +/** Signals for translation. */ +class CTranslationInterface +{ +public: + /** Translate a message to the native language of the user. */ + boost::signals2::signal Translate; +}; + extern std::map mapArgs; extern std::map > 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 rv = translationInterface.Translate(psz); + return rv ? (*rv) : psz; +} void SetupEnvironment(); -- cgit v1.2.3