Skip to content

Commit e1a10ff

Browse files
committed
Hoist repeated translated strings to RPCConsole member variables
1 parent e816ae5 commit e1a10ff

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/qt/rpcconsole.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,9 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
474474
const QString list{"<ul><li>" + Join(CONNECTION_TYPE_DOC, QString("</li><li>")) + "</li></ul>"};
475475
ui->peerConnectionTypeLabel->setToolTip(ui->peerConnectionTypeLabel->toolTip().arg(list));
476476
const QString hb_list{"<ul><li>\""
477-
+ tr("To") + "\"" + tr("we selected the peer for high bandwidth relay") + "</li><li>\""
478-
+ tr("From") + "\"" + tr("the peer selected us for high bandwidth relay") + "</li><li>\""
479-
+ tr("No") + "\"" + tr("no high bandwidth relay selected") + "</li></ul>"};
477+
+ tr_to + "\"" + tr("we selected the peer for high bandwidth relay") + "</li><li>\""
478+
+ tr_from + "\"" + tr("the peer selected us for high bandwidth relay") + "</li><li>\""
479+
+ tr_no + "\"" + tr("no high bandwidth relay selected") + "</li></ul>"};
480480
ui->peerHighBandwidthLabel->setToolTip(ui->peerHighBandwidthLabel->toolTip().arg(hb_list));
481481
ui->dataDir->setToolTip(ui->dataDir->toolTip().arg(QString(nonbreaking_hyphen) + "datadir"));
482482
ui->blocksDir->setToolTip(ui->blocksDir->toolTip().arg(QString(nonbreaking_hyphen) + "blocksdir"));
@@ -1114,11 +1114,11 @@ void RPCConsole::updateDetailWidget()
11141114
peerAddrDetails += "<br />" + tr("via %1").arg(QString::fromStdString(stats->nodeStats.addrLocal));
11151115
ui->peerHeading->setText(peerAddrDetails);
11161116
ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStats.nServices));
1117-
ui->peerRelayTxes->setText(stats->nodeStats.fRelayTxes ? tr("Yes") : tr("No"));
1117+
ui->peerRelayTxes->setText(stats->nodeStats.fRelayTxes ? tr_yes : tr_no);
11181118
QString bip152_hb_settings;
1119-
if (stats->nodeStats.m_bip152_highbandwidth_to) bip152_hb_settings = tr("To");
1120-
if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings.isEmpty() ? tr("From") : "/" + tr("From"));
1121-
if (bip152_hb_settings.isEmpty()) bip152_hb_settings = tr("No");
1119+
if (stats->nodeStats.m_bip152_highbandwidth_to) bip152_hb_settings = tr_to;
1120+
if (stats->nodeStats.m_bip152_highbandwidth_from) bip152_hb_settings += (bip152_hb_settings.isEmpty() ? tr_from : "/" + tr_from);
1121+
if (bip152_hb_settings.isEmpty()) bip152_hb_settings = tr_no;
11221122
ui->peerHighBandwidth->setText(bip152_hb_settings);
11231123
ui->peerLastSend->setText(stats->nodeStats.nLastSend ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastSend) : tr("never"));
11241124
ui->peerLastRecv->setText(stats->nodeStats.nLastRecv ? GUIUtil::formatDurationStr(GetSystemTimeInSeconds() - stats->nodeStats.nLastRecv) : tr("never"));
@@ -1133,15 +1133,15 @@ void RPCConsole::updateDetailWidget()
11331133
ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, /* prepend_direction */ true));
11341134
ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network));
11351135
if (stats->nodeStats.m_permissionFlags == PF_NONE) {
1136-
ui->peerPermissions->setText(tr("N/A"));
1136+
ui->peerPermissions->setText(tr_na);
11371137
} else {
11381138
QStringList permissions;
11391139
for (const auto& permission : NetPermissions::ToStrings(stats->nodeStats.m_permissionFlags)) {
11401140
permissions.append(QString::fromStdString(permission));
11411141
}
11421142
ui->peerPermissions->setText(permissions.join(" & "));
11431143
}
1144-
ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) : tr("N/A"));
1144+
ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) : tr_na);
11451145

11461146
// This check fails for example if the lock was busy and
11471147
// nodeStateStats couldn't be fetched.

src/qt/rpcconsole.h

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class RPCConsole: public QWidget
7070

7171
QString tabTitle(TabTypes tab_type) const;
7272
QKeySequence tabShortcut(TabTypes tab_type) const;
73+
QString tr_yes{tr("Yes")}, tr_no{tr("No")}, tr_to{tr("To")}, tr_from{tr("From")}, tr_na{tr("N/A")};
7374

7475
protected:
7576
virtual bool eventFilter(QObject* obj, QEvent *event) override;

0 commit comments

Comments
 (0)