Bitcoin Core  0.19.99
P2P Digital Currency
translation.h
Go to the documentation of this file.
1 // Copyright (c) 2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_UTIL_TRANSLATION_H
6 #define BITCOIN_UTIL_TRANSLATION_H
7 
8 #include <tinyformat.h>
9 
10 #include <utility>
11 
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 
31 const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
32 
37 inline bilingual_str _(const char* psz)
38 {
39  return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};
40 }
41 
42 #endif // BITCOIN_UTIL_TRANSLATION_H
Bilingual messages:
Definition: translation.h:17
bilingual_str format(const bilingual_str &fmt, const Args &... args)
Definition: translation.h:24
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate a message to the native language of the user.
Definition: bitcoin-cli.cpp:32
std::string translated
Definition: translation.h:19
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:37
std::string original
Definition: translation.h:18