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 #include <functional>
10 
16 struct bilingual_str {
17  std::string original;
18  std::string translated;
19 };
20 
21 namespace tinyformat {
22 template <typename... Args>
23 bilingual_str format(const bilingual_str& fmt, const Args&... args)
24 {
25  return bilingual_str{format(fmt.original, args...), format(fmt.translated, args...)};
26 }
27 } // namespace tinyformat
28 
30 const extern std::function<std::string(const char*)> G_TRANSLATION_FUN;
31 
36 inline bilingual_str _(const char* psz)
37 {
38  return bilingual_str{psz, G_TRANSLATION_FUN ? (G_TRANSLATION_FUN)(psz) : psz};
39 }
40 
41 #endif // BITCOIN_UTIL_TRANSLATION_H
Bilingual messages:
Definition: translation.h:16
bilingual_str format(const bilingual_str &fmt, const Args &... args)
Definition: translation.h:23
const std::function< std::string(const char *)> G_TRANSLATION_FUN
Translate a message to the native language of the user.
Definition: bitcoin-cli.cpp:31
std::string translated
Definition: translation.h:18
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:36
std::string original
Definition: translation.h:17