Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/qt/psbtoperationsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."));
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/qt/psbtoperationsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_QT_PSBTOPERATIONSDIALOG_H

#include <QDialog>
#include <QString>

#include <psbt.h>
#include <qt/clientmodel.h>
Expand Down Expand Up @@ -46,7 +47,7 @@ public Q_SLOTS:

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);
};
Expand Down
2 changes: 1 addition & 1 deletion src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>";
Expand Down
4 changes: 2 additions & 2 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 23 additions & 0 deletions test/lint/lint-qt-translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
#
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
#
# Check for leading whitespaces in the translatable strings.

import subprocess
import sys


def main():
tr_strings = subprocess.run(['git', 'grep', '-e', 'tr("[[:space:]]', '--', 'src/qt'], stdout=subprocess.PIPE, text=True).stdout

if tr_strings.strip():
print("Avoid leading whitespaces in:")
print(tr_strings)
sys.exit(1)


if __name__ == "__main__":
main()