Skip to content

Commit 7c45e14

Browse files
committed
Add bilingual message type
1 parent 0b86e51 commit 7c45e14

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/util/translation.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,28 @@
55
#ifndef BITCOIN_UTIL_TRANSLATION_H
66
#define BITCOIN_UTIL_TRANSLATION_H
77

8+
#include <tinyformat.h>
9+
10+
#include <utility>
11+
12+
/**
13+
* Bilingual messages:
14+
* - in GUI: user's native language + untranslated (i.e. English)
15+
* - in log and stderr: untranslated only
16+
*/
17+
struct bilingual_str {
18+
std::string original;
19+
std::string translated;
20+
};
21+
22+
namespace tinyformat {
23+
template <typename... Args>
24+
bilingual_str format(const bilingual_str& fmt, const Args&... args)
25+
{
26+
return bilingual_str{format(fmt.original, args...), format(fmt.translated, args...)};
27+
}
28+
} // namespace tinyformat
29+
830
/** Translate a message to the native language of the user. */
931
const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
1032

0 commit comments

Comments
 (0)