aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-10-25 13:15:58 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2023-10-25 13:20:07 +0100
commit64879f4c03b9d933898c0bb83d9b7e9c20729e51 (patch)
treeffb2720cba0a297dd74fde52d0a411b802f9d34a /src/qt
parentafa081a39bde77d3959aa35b6e6c75a2fe988d68 (diff)
parent856325fac17465d102da621f1282b6d8ed02f679 (diff)
downloadbitcoin-64879f4c03b9d933898c0bb83d9b7e9c20729e51.tar.xz
Merge bitcoin-core/gui#771: Avoid error-prone leading whitespace in translatable strings
856325fac17465d102da621f1282b6d8ed02f679 lint: Add `lint-qt-translation.py` (Hennadii Stepanov) 294a018bf5106b03af39a2a8cfa4d5f2ebf6912b qt: Avoid error prone leading spaces in translatable strings (Hennadii Stepanov) d8298e7f069f961fc077ceacff2c332d58734688 qt, refactor: Drop superfluous type conversions (Hennadii Stepanov) Pull request description: While working on the GUI translation via Transifex web interface, I found it error-prone to have leading whitespace in translatable strings. This is because it is very easy to unintentionally drop them in translations unnoticed. Fixed all current cases. Added a linter to prevent similar cases in the future. ACKs for top commit: furszy: utACK 856325f Tree-SHA512: b1ca5effb2db6649e1e99382de79acf3a9f81cc9dad434db5623338489e597897e8addd60c1ab3dcc7506ae62753a7a4ad5a41d7a865f8fcdf94348b54baa7e7
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/psbtoperationsdialog.cpp13
-rw-r--r--src/qt/psbtoperationsdialog.h3
-rw-r--r--src/qt/sendcoinsdialog.cpp2
-rw-r--r--src/qt/transactiondesc.cpp2
-rw-r--r--src/qt/walletcontroller.cpp4
5 files changed, 13 insertions, 11 deletions
diff --git a/src/qt/psbtoperationsdialog.cpp b/src/qt/psbtoperationsdialog.cpp
index 26f1696de1..3c2c7fe435 100644
--- a/src/qt/psbtoperationsdialog.cpp
+++ b/src/qt/psbtoperationsdialog.cpp
@@ -167,19 +167,20 @@ void PSBTOperationsDialog::saveTransaction() {
}
void PSBTOperationsDialog::updateTransactionDisplay() {
- m_ui->transactionDescription->setText(QString::fromStdString(renderTransaction(m_transaction_data)));
+ m_ui->transactionDescription->setText(renderTransaction(m_transaction_data));
showTransactionStatus(m_transaction_data);
}
-std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransaction &psbtx)
+QString PSBTOperationsDialog::renderTransaction(const PartiallySignedTransaction &psbtx)
{
- QString tx_description = "";
+ QString tx_description;
+ QLatin1String bullet_point(" * ");
CAmount totalAmount = 0;
for (const CTxOut& out : psbtx.tx->vout) {
CTxDestination address;
ExtractDestination(out.scriptPubKey, address);
totalAmount += out.nValue;
- tx_description.append(tr(" * Sends %1 to %2")
+ tx_description.append(bullet_point).append(tr("Sends %1 to %2")
.arg(BitcoinUnits::formatWithUnit(BitcoinUnit::BTC, out.nValue))
.arg(QString::fromStdString(EncodeDestination(address))));
// Check if the address is one of ours
@@ -188,7 +189,7 @@ std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransac
}
PSBTAnalysis analysis = AnalyzePSBT(psbtx);
- tx_description.append(" * ");
+ tx_description.append(bullet_point);
if (!*analysis.fee) {
// This happens if the transaction is missing input UTXO information.
tx_description.append(tr("Unable to calculate transaction fee or total transaction amount."));
@@ -217,7 +218,7 @@ std::string PSBTOperationsDialog::renderTransaction(const PartiallySignedTransac
tx_description.append(tr("Transaction has %1 unsigned inputs.").arg(QString::number(num_unsigned)));
}
- return tx_description.toStdString();
+ return tx_description;
}
void PSBTOperationsDialog::showStatus(const QString &msg, StatusLevel level) {
diff --git a/src/qt/psbtoperationsdialog.h b/src/qt/psbtoperationsdialog.h
index f37bdbe39a..23f7dbf227 100644
--- a/src/qt/psbtoperationsdialog.h
+++ b/src/qt/psbtoperationsdialog.h
@@ -6,6 +6,7 @@
#define BITCOIN_QT_PSBTOPERATIONSDIALOG_H
#include <QDialog>
+#include <QString>
#include <psbt.h>
#include <qt/clientmodel.h>
@@ -46,7 +47,7 @@ private:
size_t couldSignInputs(const PartiallySignedTransaction &psbtx);
void updateTransactionDisplay();
- std::string renderTransaction(const PartiallySignedTransaction &psbtx);
+ QString renderTransaction(const PartiallySignedTransaction &psbtx);
void showStatus(const QString &msg, StatusLevel level);
void showTransactionStatus(const PartiallySignedTransaction &psbtx);
};
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index dea9b92395..6614ed91a7 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -302,7 +302,7 @@ bool SendCoinsDialog::PrepareSendText(QString& question_string, QString& informa
// generate amount string with wallet name in case of multiwallet
QString amount = BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), rcp.amount);
if (model->isMultiwallet()) {
- amount.append(tr(" from wallet '%1'").arg(GUIUtil::HtmlEscape(model->getWalletName())));
+ amount = tr("%1 from wallet '%2'").arg(amount, GUIUtil::HtmlEscape(model->getWalletName()));
}
// generate address string
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index dae6a2dea9..51f6f44923 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -323,7 +323,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
if (!GetPaymentRequestMerchant(r.second, merchant)) {
merchant.clear();
} else {
- merchant += tr(" (Certificate was not verified)");
+ merchant = tr("%1 (Certificate was not verified)").arg(merchant);
}
if (!merchant.isNull()) {
strHTML += "<b>" + tr("Merchant") + ":</b> " + GUIUtil::HtmlEscape(merchant) + "<br>";
diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp
index b1ef489cc3..c7fe62f4e9 100644
--- a/src/qt/walletcontroller.cpp
+++ b/src/qt/walletcontroller.cpp
@@ -472,10 +472,10 @@ void MigrateWalletActivity::migrate(WalletModel* wallet_model)
if (res) {
m_success_message = tr("The wallet '%1' was migrated successfully.").arg(GUIUtil::HtmlEscape(res->wallet->getWalletName()));
if (res->watchonly_wallet_name) {
- m_success_message += tr(" Watchonly scripts have been migrated to a new wallet named '%1'.").arg(GUIUtil::HtmlEscape(res->watchonly_wallet_name.value()));
+ m_success_message += QChar(' ') + tr("Watchonly scripts have been migrated to a new wallet named '%1'.").arg(GUIUtil::HtmlEscape(res->watchonly_wallet_name.value()));
}
if (res->solvables_wallet_name) {
- m_success_message += tr(" Solvable but not watched scripts have been migrated to a new wallet named '%1'.").arg(GUIUtil::HtmlEscape(res->solvables_wallet_name.value()));
+ m_success_message += QChar(' ') + tr("Solvable but not watched scripts have been migrated to a new wallet named '%1'.").arg(GUIUtil::HtmlEscape(res->solvables_wallet_name.value()));
}
m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(res->wallet));
} else {