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>
|
||||
// settingsdialog.cpp — Settings dialog with category list
|
||||
#include "settingsdialog.h"
|
||||
#include "networksettingspage.h"
|
||||
@@ -14,6 +15,9 @@
|
||||
#include "../../lib/mem.h"
|
||||
#include "../db/db_manager.h"
|
||||
#include "../transport/utun_node.h"
|
||||
#include "../transport/node_config.h"
|
||||
#include "../transport/config_updater.h"
|
||||
#include "../../lib/debug_config.h"
|
||||
extern "C" {
|
||||
#include "chat/chat_core.h"
|
||||
}
|
||||
@@ -33,7 +37,7 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
: QDialog(parent)
|
||||
, m_configPath(configPath)
|
||||
{
|
||||
setWindowTitle("Settings");
|
||||
setWindowTitle(QCoreApplication::translate("ChatGui", "Settings"));
|
||||
setMinimumSize(760, 460);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
|
||||
@@ -49,16 +53,16 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
" background: palette(window); font-size: 13px; }"
|
||||
"QListWidget::item { padding: 10px 14px; }"
|
||||
"QListWidget::item:selected { background: #3390EC; color: white; }");
|
||||
m_categoryList->addItem("Profile");
|
||||
m_categoryList->addItem("Storage");
|
||||
m_categoryList->addItem("Network");
|
||||
m_categoryList->addItem("Connections");
|
||||
m_categoryList->addItem("Database");
|
||||
m_categoryList->addItem("Status");
|
||||
m_categoryList->addItem("Nodes");
|
||||
m_categoryList->addItem("Sound");
|
||||
m_categoryList->addItem("Audio");
|
||||
m_categoryList->addItem("Рация");
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Profile"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Storage"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Network"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Connections"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Database"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Status"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Nodes"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Sound"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Audio"));
|
||||
m_categoryList->addItem(QCoreApplication::translate("ChatGui", "Radio"));
|
||||
mainLayout->addWidget(m_categoryList);
|
||||
|
||||
// --- Right panel: stacked pages ---
|
||||
@@ -73,35 +77,50 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
auto* profilePage = new QWidget(m_pages);
|
||||
auto* profLayout = new QFormLayout(profilePage);
|
||||
profLayout->setContentsMargins(0, 12, 0, 0);
|
||||
auto* nameLabel = new QLabel("Display name:", profilePage);
|
||||
auto* nameLabel = new QLabel(QCoreApplication::translate("ChatGui", "Display name:"), profilePage);
|
||||
m_nicknameEdit = new QLineEdit(profilePage);
|
||||
m_nicknameEdit->setPlaceholderText("Your name (shown to others)");
|
||||
m_nicknameEdit->setPlaceholderText(QCoreApplication::translate("ChatGui", "Your name (shown to others)"));
|
||||
m_nicknameEdit->setMaxLength(32);
|
||||
m_nicknameEdit->setStyleSheet(
|
||||
"QLineEdit { border: 1px solid palette(mid); border-radius: 4px;"
|
||||
" padding: 6px 10px; font-size: 13px; background: palette(base); }");
|
||||
profLayout->addRow(nameLabel, m_nicknameEdit);
|
||||
|
||||
auto* sortLabel = new QLabel("Channel sorting:", profilePage);
|
||||
m_languageCombo = new QComboBox(profilePage);
|
||||
m_languageCombo->setObjectName(QStringLiteral("languageCombo"));
|
||||
m_languageCombo->addItem(QCoreApplication::translate("ChatGui", "System language"), QStringLiteral("system"));
|
||||
m_languageCombo->addItem(QStringLiteral("English"), QStringLiteral("en"));
|
||||
m_languageCombo->addItem(QStringLiteral("Русский"), QStringLiteral("ru"));
|
||||
NodeConfig languageConfig(m_configPath);
|
||||
if (!languageConfig.load()) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CONFIG, "GUI language: cannot read preferences from %s", qPrintable(m_configPath));
|
||||
}
|
||||
m_languageCombo->setCurrentIndex(m_languageCombo->findData(languageConfig.language()));
|
||||
profLayout->addRow(QCoreApplication::translate("ChatGui", "Interface language:"), m_languageCombo);
|
||||
auto* languageNote = new QLabel(QCoreApplication::translate("ChatGui", "Language changes take effect after restart."), profilePage);
|
||||
languageNote->setWordWrap(true);
|
||||
profLayout->addRow(languageNote);
|
||||
|
||||
auto* sortLabel = new QLabel(QCoreApplication::translate("ChatGui", "Channel sorting:"), profilePage);
|
||||
m_sortCombo = new QComboBox(profilePage);
|
||||
m_sortCombo->addItem("Alphabetical (A-Z)");
|
||||
m_sortCombo->addItem("Recent Activity");
|
||||
m_sortCombo->addItem(QCoreApplication::translate("ChatGui", "Alphabetical (A-Z)"));
|
||||
m_sortCombo->addItem(QCoreApplication::translate("ChatGui", "Recent Activity"));
|
||||
m_sortCombo->setStyleSheet(
|
||||
"QComboBox { border: 1px solid palette(mid); border-radius: 4px;"
|
||||
" padding: 6px 10px; font-size: 13px; background: palette(base); }");
|
||||
profLayout->addRow(sortLabel, m_sortCombo);
|
||||
|
||||
auto* joinLabel = new QLabel("Join requests:", profilePage);
|
||||
auto* joinLabel = new QLabel(QCoreApplication::translate("ChatGui", "Join requests:"), profilePage);
|
||||
m_joinPolicyCombo = new QComboBox(profilePage);
|
||||
m_joinPolicyCombo->addItem("Auto-join");
|
||||
m_joinPolicyCombo->addItem("Ask before joining");
|
||||
m_joinPolicyCombo->addItem("Deny all");
|
||||
m_joinPolicyCombo->addItem(QCoreApplication::translate("ChatGui", "Auto-join"));
|
||||
m_joinPolicyCombo->addItem(QCoreApplication::translate("ChatGui", "Ask before joining"));
|
||||
m_joinPolicyCombo->addItem(QCoreApplication::translate("ChatGui", "Deny all"));
|
||||
m_joinPolicyCombo->setStyleSheet(
|
||||
"QComboBox { border: 1px solid palette(mid); border-radius: 4px;"
|
||||
" padding: 6px 10px; font-size: 13px; background: palette(base); }");
|
||||
profLayout->addRow(joinLabel, m_joinPolicyCombo);
|
||||
|
||||
m_autoConnectCheck = new QCheckBox("Auto-connect to group nodes", profilePage);
|
||||
m_autoConnectCheck = new QCheckBox(QCoreApplication::translate("ChatGui", "Auto-connect to group nodes"), profilePage);
|
||||
m_autoConnectCheck->setStyleSheet("font-size: 13px;");
|
||||
profLayout->addRow(m_autoConnectCheck);
|
||||
m_pages->addWidget(profilePage);
|
||||
@@ -120,11 +139,11 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
auto* connPage = new QWidget(m_pages);
|
||||
auto* connLayout = new QVBoxLayout(connPage);
|
||||
connLayout->setAlignment(Qt::AlignCenter);
|
||||
auto* hintLabel = new QLabel("Live ETCP connection monitor\nwith per-link BBR statistics", connPage);
|
||||
auto* hintLabel = new QLabel(QCoreApplication::translate("ChatGui", "Live ETCP connection monitor\nwith per-link BBR statistics"), connPage);
|
||||
hintLabel->setAlignment(Qt::AlignCenter);
|
||||
hintLabel->setStyleSheet("font-size: 12px; color: palette(text); padding: 20px;");
|
||||
connLayout->addWidget(hintLabel);
|
||||
auto* openBtn = new QPushButton("Open Connection Monitor", connPage);
|
||||
auto* openBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Open Connection Monitor"), connPage);
|
||||
openBtn->setStyleSheet("QPushButton { padding: 10px 20px; font-size: 13px; }");
|
||||
connect(openBtn, &QPushButton::clicked, this, &SettingsDialog::onOpenConnMonitor);
|
||||
connLayout->addWidget(openBtn);
|
||||
@@ -160,8 +179,8 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
btnLayout->setSpacing(8);
|
||||
btnLayout->addStretch();
|
||||
|
||||
auto* cancelBtn = new QPushButton("Cancel", rightPanel);
|
||||
cancelBtn->setFixedWidth(90);
|
||||
auto* cancelBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Cancel"), rightPanel);
|
||||
cancelBtn->setMinimumWidth(90);
|
||||
cancelBtn->setStyleSheet(
|
||||
"QPushButton { border: 1px solid palette(mid); border-radius: 4px;"
|
||||
" padding: 6px 16px; font-size: 13px; background: palette(button); }"
|
||||
@@ -169,8 +188,8 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
connect(cancelBtn, &QPushButton::clicked, this, &QDialog::reject);
|
||||
btnLayout->addWidget(cancelBtn);
|
||||
|
||||
m_saveBtn = new QPushButton("Save", rightPanel);
|
||||
m_saveBtn->setFixedWidth(90);
|
||||
m_saveBtn = new QPushButton(QCoreApplication::translate("ChatGui", "Save"), rightPanel);
|
||||
m_saveBtn->setMinimumWidth(90);
|
||||
m_saveBtn->setDefault(true);
|
||||
m_saveBtn->setStyleSheet(
|
||||
"QPushButton { border: none; border-radius: 4px;"
|
||||
@@ -299,8 +318,10 @@ void SettingsDialog::onSave() {
|
||||
m_audioDevicePage->applyAndSave();
|
||||
m_storagePage->applyAndSave();
|
||||
if (!m_radioPage->apply()) {
|
||||
QMessageBox::warning(this, QStringLiteral("Настройки рации"), QStringLiteral("Не удалось применить настройки рации. "
|
||||
"Проверьте доступность ядра и файла конфигурации; подробности в логе radio."));
|
||||
QMessageBox::warning(this, QCoreApplication::translate("ChatGui",
|
||||
"Radio settings"), QCoreApplication::translate("ChatGui",
|
||||
"Failed to apply radio settings. Check that the core and configuration file are available; "
|
||||
"see the radio log for details."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -357,6 +378,15 @@ void SettingsDialog::onSave() {
|
||||
postChatSetting(m_configPath, "group_autoconnect", v);
|
||||
}
|
||||
}
|
||||
const QString language = m_languageCombo->currentData().toString();
|
||||
if (!config_update_option(m_configPath, "gui", "language", language)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CONFIG, "GUI language: failed to save preference=%s path=%s",
|
||||
qPrintable(language), qPrintable(m_configPath));
|
||||
QMessageBox::warning(this, QCoreApplication::translate("ChatGui", "Settings"),
|
||||
QCoreApplication::translate("ChatGui", "Failed to save the interface language. Check the configuration file."));
|
||||
return;
|
||||
}
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CONFIG, "GUI language: saved preference=%s; applies after restart", qPrintable(language));
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user