Add English and Russian ChatGUI interface translations
This commit is contained in:
1 parent
972c6b7f0a
commit
27d93ecaf9
50 files changed
+4978
-491
No files matched your search
@@ -1,3 +1,4 @@
|
||||
#include <QCoreApplication>
|
||||
// networksettingspage.cpp — Network configuration form (список listen-сокетов)
|
||||
#include "networksettingspage.h"
|
||||
#include "../transport/config_updater.h"
|
||||
@@ -13,7 +14,7 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
static const QString AUTO_IP_LABEL = "Auto (0.0.0.0)";
|
||||
static QString autoIpLabel() { return QCoreApplication::translate("ChatGui", "Auto (0.0.0.0)"); }
|
||||
|
||||
NetworkSettingsPage::NetworkSettingsPage(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -22,11 +23,11 @@ NetworkSettingsPage::NetworkSettingsPage(QWidget* parent)
|
||||
layout->setSpacing(12);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
auto* title = new QLabel("Listen Sockets", this);
|
||||
auto* title = new QLabel(QCoreApplication::translate("ChatGui", "Listen Sockets"), this);
|
||||
title->setStyleSheet("font-weight: bold; font-size: 13px;");
|
||||
layout->addWidget(title);
|
||||
|
||||
m_autoSocketsCheck = new QCheckBox("Auto sockets (UDP+TCP from interfaces)", this);
|
||||
m_autoSocketsCheck = new QCheckBox(QCoreApplication::translate("ChatGui", "Auto sockets (UDP+TCP from interfaces)"), this);
|
||||
layout->addWidget(m_autoSocketsCheck);
|
||||
|
||||
m_serverList = new QListWidget(this);
|
||||
@@ -34,8 +35,8 @@ NetworkSettingsPage::NetworkSettingsPage(QWidget* parent)
|
||||
layout->addWidget(m_serverList);
|
||||
|
||||
auto* btnRow = new QHBoxLayout();
|
||||
m_addBtn = new QPushButton("Add", this);
|
||||
m_removeBtn = new QPushButton("Remove", this);
|
||||
m_addBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Add"), this);
|
||||
m_removeBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Remove"), this);
|
||||
btnRow->addWidget(m_addBtn);
|
||||
btnRow->addWidget(m_removeBtn);
|
||||
btnRow->addStretch();
|
||||
@@ -44,41 +45,44 @@ NetworkSettingsPage::NetworkSettingsPage(QWidget* parent)
|
||||
// --- форма правки выбранного сокета ---
|
||||
auto* formLayout = new QGridLayout();
|
||||
|
||||
formLayout->addWidget(new QLabel("Name:", this), 0, 0);
|
||||
formLayout->addWidget(new QLabel(QCoreApplication::translate("ChatGui", "Name:"), this), 0, 0);
|
||||
m_nameEdit = new QLineEdit(this);
|
||||
m_nameEdit->setMinimumWidth(180);
|
||||
formLayout->addWidget(m_nameEdit, 0, 1);
|
||||
|
||||
formLayout->addWidget(new QLabel("IP Address:", this), 1, 0);
|
||||
formLayout->addWidget(new QLabel(QCoreApplication::translate("ChatGui", "IP Address:"), this), 1, 0);
|
||||
m_ipCombo = new QComboBox(this);
|
||||
m_ipCombo->setEditable(true);
|
||||
m_ipCombo->setMinimumWidth(180);
|
||||
formLayout->addWidget(m_ipCombo, 1, 1);
|
||||
|
||||
formLayout->addWidget(new QLabel("Port:", this), 2, 0);
|
||||
formLayout->addWidget(new QLabel(QCoreApplication::translate("ChatGui", "Port:"), this), 2, 0);
|
||||
m_portSpin = new QSpinBox(this);
|
||||
m_portSpin->setRange(1, 65535);
|
||||
m_portSpin->setValue(1333);
|
||||
formLayout->addWidget(m_portSpin, 2, 1);
|
||||
|
||||
formLayout->addWidget(new QLabel("Protocol:", this), 3, 0);
|
||||
formLayout->addWidget(new QLabel(QCoreApplication::translate("ChatGui", "Protocol:"), this), 3, 0);
|
||||
m_protoCombo = new QComboBox(this);
|
||||
m_protoCombo->addItems({"UDP", "TCP"});
|
||||
formLayout->addWidget(m_protoCombo, 3, 1);
|
||||
|
||||
formLayout->addWidget(new QLabel("Type:", this), 4, 0);
|
||||
formLayout->addWidget(new QLabel(QCoreApplication::translate("ChatGui", "Type:"), this), 4, 0);
|
||||
m_typeCombo = new QComboBox(this);
|
||||
m_typeCombo->addItems({"public", "nat", "private", "local"});
|
||||
m_typeCombo->addItem(QCoreApplication::translate("ChatGui", "Public"), QStringLiteral("public"));
|
||||
m_typeCombo->addItem(QStringLiteral("NAT"), QStringLiteral("nat"));
|
||||
m_typeCombo->addItem(QCoreApplication::translate("ChatGui", "Private"), QStringLiteral("private"));
|
||||
m_typeCombo->addItem(QCoreApplication::translate("ChatGui", "Local"), QStringLiteral("local"));
|
||||
formLayout->addWidget(m_typeCombo, 4, 1);
|
||||
|
||||
formLayout->addWidget(new QLabel("Interface:", this), 5, 0);
|
||||
formLayout->addWidget(new QLabel(QCoreApplication::translate("ChatGui", "Interface:"), this), 5, 0);
|
||||
m_interfaceCombo = new QComboBox(this);
|
||||
m_interfaceCombo->setMinimumWidth(180);
|
||||
formLayout->addWidget(m_interfaceCombo, 5, 1);
|
||||
|
||||
layout->addLayout(formLayout);
|
||||
|
||||
auto* note = new QLabel("Changes take effect after restart.", this);
|
||||
auto* note = new QLabel(QCoreApplication::translate("ChatGui", "Changes take effect after restart."), this);
|
||||
note->setStyleSheet("color: gray; font-size: 11px;");
|
||||
layout->addWidget(note);
|
||||
layout->addStretch();
|
||||
@@ -111,7 +115,7 @@ static void splitAddr(const QString& addr, QString& ip, int& port) {
|
||||
}
|
||||
|
||||
void NetworkSettingsPage::populateInterfaces() {
|
||||
m_interfaceCombo->addItem("Auto (any)");
|
||||
m_interfaceCombo->addItem(QCoreApplication::translate("ChatGui", "Auto (any)"));
|
||||
for (const QNetworkInterface& iface : QNetworkInterface::allInterfaces()) {
|
||||
if (iface.flags() & QNetworkInterface::IsLoopBack) continue;
|
||||
if (!(iface.flags() & QNetworkInterface::IsUp)) continue;
|
||||
@@ -120,7 +124,7 @@ void NetworkSettingsPage::populateInterfaces() {
|
||||
}
|
||||
|
||||
void NetworkSettingsPage::populateAddresses() {
|
||||
m_ipCombo->addItem(AUTO_IP_LABEL);
|
||||
m_ipCombo->addItem(autoIpLabel());
|
||||
for (const QNetworkInterface& iface : QNetworkInterface::allInterfaces()) {
|
||||
if (iface.flags() & QNetworkInterface::IsLoopBack) continue;
|
||||
if (!(iface.flags() & QNetworkInterface::IsUp)) continue;
|
||||
@@ -166,11 +170,11 @@ void NetworkSettingsPage::loadFormFromSelected() {
|
||||
m_nameEdit->setText(s.name);
|
||||
QString ip; int port = 0;
|
||||
splitAddr(s.addr, ip, port);
|
||||
if (ip == "0.0.0.0") ip = AUTO_IP_LABEL;
|
||||
if (ip == "0.0.0.0") ip = autoIpLabel();
|
||||
m_ipCombo->setCurrentText(ip);
|
||||
m_portSpin->setValue(port > 0 ? port : 1333);
|
||||
m_protoCombo->setCurrentIndex(s.transport == "tcp" ? 1 : 0);
|
||||
int typeIdx = m_typeCombo->findText(s.type);
|
||||
int typeIdx = m_typeCombo->findData(s.type);
|
||||
m_typeCombo->setCurrentIndex(typeIdx >= 0 ? typeIdx : 0);
|
||||
int ifIdx = m_interfaceCombo->findText(s.netif);
|
||||
m_interfaceCombo->setCurrentIndex(ifIdx >= 0 ? ifIdx : 0);
|
||||
@@ -185,13 +189,13 @@ void NetworkSettingsPage::updateSelectedServerFromForm() {
|
||||
s.name = m_nameEdit->text().trimmed();
|
||||
|
||||
QString ip = m_ipCombo->currentText().trimmed();
|
||||
if (ip == AUTO_IP_LABEL) ip = "0.0.0.0";
|
||||
if (ip == autoIpLabel()) ip = "0.0.0.0";
|
||||
s.addr = ip + ":" + QString::number(m_portSpin->value());
|
||||
|
||||
s.transport = (m_protoCombo->currentIndex() == 1) ? "tcp" : "udp";
|
||||
s.type = m_typeCombo->currentText().trimmed();
|
||||
s.type = m_typeCombo->currentData().toString();
|
||||
QString iface = m_interfaceCombo->currentText();
|
||||
s.netif = iface.startsWith("Auto") ? QString() : iface;
|
||||
s.netif = m_interfaceCombo->currentIndex() == 0 ? QString() : iface;
|
||||
}
|
||||
|
||||
void NetworkSettingsPage::updateSelectedListItemText() {
|
||||
|
||||
Reference in new issue
Block a user