Skip to content

Commit d960d5c

Browse files
author
MarcoFalke
committed
Merge #16362: Add bilingual_str type
753f7cc scripted-diff: Make translation bilingual (Hennadii Stepanov) 7c45e14 Add bilingual message type (Hennadii Stepanov) 0b86e51 Refactor out translation.h (Hennadii Stepanov) Pull request description: This PR adds the `bilingual_str` struct and a `strprintf` overload: https://github.com/bitcoin/bitcoin/blob/0626b8cbdf0aa971500eb5613c7ab4096c496966/src/tinyformat.h#L1066-L1067 Both new features allow bitcoin code to easily send dual translated and non-translated messages to the GUI and the logging framework. This PR is only a refactoring (has been split off the #16224 (see: bitcoin/bitcoin#16224)) and does not change behavior. ACKs for top commit: MarcoFalke: ACK 753f7cc ryanofsky: utACK 753f7cc. Only change since last review is fixing lint error (double includes) Tree-SHA512: 52b0654421d558e4775c0484d78be26319fe3db5118af9b0a9bdfbdaad53a3704f527a5d5aba1013a64560b9b6a0c3c4cf0a6782e49aa731e18d99de95220385
2 parents 0626b8c + 753f7cc commit d960d5c

27 files changed

+248
-184
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ BITCOIN_CORE_H = \
212212
util/rbf.h \
213213
util/threadnames.h \
214214
util/time.h \
215+
util/translation.h \
215216
util/url.h \
216217
util/validation.h \
217218
validation.h \

src/banman.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#include <ui_interface.h>
1010
#include <util/system.h>
1111
#include <util/time.h>
12+
#include <util/translation.h>
1213

1314

1415
BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time)
1516
: m_client_interface(client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time)
1617
{
17-
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist..."));
18+
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist...").translated);
1819

1920
int64_t n_start = GetTimeMillis();
2021
m_is_dirty = false;

src/bitcoin-cli.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
#include <rpc/client.h>
1414
#include <rpc/protocol.h>
1515
#include <rpc/request.h>
16-
#include <util/system.h>
1716
#include <util/strencodings.h>
17+
#include <util/system.h>
18+
#include <util/translation.h>
1819

20+
#include <functional>
1921
#include <memory>
2022
#include <stdio.h>
2123
#include <tuple>

src/bitcoin-tx.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
#include <script/sign.h>
1919
#include <script/signingprovider.h>
2020
#include <univalue.h>
21-
#include <util/rbf.h>
22-
#include <util/system.h>
2321
#include <util/moneystr.h>
22+
#include <util/rbf.h>
2423
#include <util/strencodings.h>
24+
#include <util/system.h>
25+
#include <util/translation.h>
2526

27+
#include <functional>
2628
#include <memory>
2729
#include <stdio.h>
2830

src/bitcoin-wallet.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
#include <chainparams.h>
1010
#include <chainparamsbase.h>
1111
#include <logging.h>
12-
#include <util/system.h>
1312
#include <util/strencodings.h>
13+
#include <util/system.h>
14+
#include <util/translation.h>
1415
#include <wallet/wallettool.h>
1516

17+
#include <functional>
1618
#include <stdio.h>
1719

1820
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;

src/bitcoind.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#include <util/strencodings.h>
2020
#include <util/system.h>
2121
#include <util/threadnames.h>
22+
#include <util/translation.h>
23+
24+
#include <functional>
2225

2326
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
2427

src/httprpc.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
#include <httprpc.h>
66

77
#include <chainparams.h>
8+
#include <crypto/hmac_sha256.h>
89
#include <httpserver.h>
910
#include <key_io.h>
1011
#include <rpc/protocol.h>
1112
#include <rpc/server.h>
1213
#include <sync.h>
13-
#include <util/system.h>
14-
#include <util/strencodings.h>
1514
#include <ui_interface.h>
15+
#include <util/strencodings.h>
16+
#include <util/system.h>
17+
#include <util/translation.h>
1618
#include <walletinitinterface.h>
17-
#include <crypto/hmac_sha256.h>
18-
#include <stdio.h>
1919

2020
#include <memory>
21+
#include <stdio.h>
2122

2223
#include <boost/algorithm/string.hpp> // boost::trim
2324

@@ -218,7 +219,7 @@ static bool InitRPCAuthentication()
218219
LogPrintf("No rpcpassword set - using random cookie authentication.\n");
219220
if (!GenerateAuthCookie(&strRPCUserColonPass)) {
220221
uiInterface.ThreadSafeMessageBox(
221-
_("Error: A fatal internal error occurred, see debug.log for details"), // Same message as AbortNode
222+
_("Error: A fatal internal error occurred, see debug.log for details").translated, // Same message as AbortNode
222223
"", CClientUIInterface::MSG_ERROR);
223224
return false;
224225
}

src/index/txindex.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <shutdown.h>
77
#include <ui_interface.h>
88
#include <util/system.h>
9+
#include <util/translation.h>
910
#include <validation.h>
1011

1112
#include <boost/thread.hpp>
@@ -137,7 +138,7 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator&
137138

138139
int64_t count = 0;
139140
LogPrintf("Upgrading txindex database... [0%%]\n");
140-
uiInterface.ShowProgress(_("Upgrading txindex database"), 0, true);
141+
uiInterface.ShowProgress(_("Upgrading txindex database").translated, 0, true);
141142
int report_done = 0;
142143
const size_t batch_size = 1 << 24; // 16 MiB
143144

@@ -174,7 +175,7 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator&
174175
(static_cast<uint32_t>(*(txid.begin() + 1)) << 0);
175176
int percentage_done = (int)(high_nibble * 100.0 / 65536.0 + 0.5);
176177

177-
uiInterface.ShowProgress(_("Upgrading txindex database"), percentage_done, true);
178+
uiInterface.ShowProgress(_("Upgrading txindex database").translated, percentage_done, true);
178179
if (report_done < percentage_done/10) {
179180
LogPrintf("Upgrading txindex database... [%d%%]\n", percentage_done);
180181
report_done = percentage_done/10;

0 commit comments

Comments
 (0)