Skip to content

Commit 73d75aa

Browse files
committed
feat: 更新翻译文件,增强多语言支持
- 在英文和简体中文翻译文件中添加和修改多个翻译条目。 - 更新用户界面文本,提升用户体验和可读性。 - 引入新的接收和发送模式切换提示,优化交互反馈。
1 parent 933b660 commit 73d75aa

12 files changed

Lines changed: 147 additions & 29 deletions
216 Bytes
Binary file not shown.

src/app/resources/i18n/fluentserialassistant.en_US.ts

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,22 @@ JSON Object: reads numeric fields; array fields are expanded
463463
<source>当前窗口和已打开页面已刷新。</source>
464464
<translation>Current window and opened pages have been refreshed.</translation>
465465
</message>
466+
<message>
467+
<source>当前接收显示为 %1,点击切换为 %2</source>
468+
<translation>Receive display is %1; click to switch to %2</translation>
469+
</message>
466470
<message>
467471
<source>文本</source>
468472
<translation>Text</translation>
469473
</message>
474+
<message>
475+
<source>当前为 HEX 发送,点击切换为文本</source>
476+
<translation>Currently sending HEX; click to switch to text</translation>
477+
</message>
478+
<message>
479+
<source>当前为文本发送,点击切换为 HEX</source>
480+
<translation>Currently sending text; click to switch to HEX</translation>
481+
</message>
470482
<message>
471483
<source>混合</source>
472484
<translation>Mixed</translation>
@@ -769,7 +781,7 @@ Reply: %2</translation>
769781
</message>
770782
<message>
771783
<source>选择发送文件</source>
772-
<translation>Select file to send</translation>
784+
<translation>Select file</translation>
773785
</message>
774786
<message>
775787
<source>无法发送文件</source>
@@ -1009,7 +1021,7 @@ Expected response: %2</translation>
10091021
</message>
10101022
<message>
10111023
<source>填入发送</source>
1012-
<translation>Fill Send</translation>
1024+
<translation>Fill TX</translation>
10131025
</message>
10141026
<message>
10151027
<source>发送</source>
@@ -1259,23 +1271,23 @@ Content: %4</translation>
12591271
</message>
12601272
<message>
12611273
<source>无流控</source>
1262-
<translation>No Flow Control</translation>
1274+
<translation>None</translation>
12631275
</message>
12641276
<message>
12651277
<source>硬件流控</source>
1266-
<translation>Hardware Flow Control</translation>
1278+
<translation>Hardware</translation>
12671279
</message>
12681280
<message>
12691281
<source>软件流控</source>
1270-
<translation>Software Flow Control</translation>
1282+
<translation>Software</translation>
12711283
</message>
12721284
<message>
12731285
<source>流控</source>
12741286
<translation>Flow Control</translation>
12751287
</message>
12761288
<message>
12771289
<source>启动连接</source>
1278-
<translation>Connect on Startup</translation>
1290+
<translation>Auto Connect</translation>
12791291
</message>
12801292
<message>
12811293
<source>接收设置</source>
@@ -1287,7 +1299,7 @@ Content: %4</translation>
12871299
</message>
12881300
<message>
12891301
<source>保存接收</source>
1290-
<translation>Save Received</translation>
1302+
<translation>Save RX</translation>
12911303
</message>
12921304
<message>
12931305
<source>自动滚动</source>
@@ -1299,7 +1311,7 @@ Content: %4</translation>
12991311
</message>
13001312
<message>
13011313
<source>暂停显示</source>
1302-
<translation>Pause Display</translation>
1314+
<translation>Pause</translation>
13031315
</message>
13041316
<message>
13051317
<source>自动日志</source>
@@ -1319,7 +1331,7 @@ Content: %4</translation>
13191331
</message>
13201332
<message>
13211333
<source>HEX 边界,如 AA 55 或 0D 0A</source>
1322-
<translation>HEX boundary, e.g. AA 55 or 0D 0A</translation>
1334+
<translation>HEX boundary: AA 55 / 0D 0A</translation>
13231335
</message>
13241336
<message>
13251337
<source>边界</source>
@@ -1351,7 +1363,7 @@ Content: %4</translation>
13511363
</message>
13521364
<message>
13531365
<source>自动追加</source>
1354-
<translation>Auto Append</translation>
1366+
<translation>Append</translation>
13551367
</message>
13561368
<message>
13571369
<source>字节序</source>
@@ -1367,15 +1379,15 @@ Content: %4</translation>
13671379
</message>
13681380
<message>
13691381
<source>显示发送字符串</source>
1370-
<translation>Show send string</translation>
1382+
<translation>Show TX</translation>
13711383
</message>
13721384
<message>
13731385
<source>定时发送</source>
13741386
<translation>Timed Send</translation>
13751387
</message>
13761388
<message>
13771389
<source>自动重连</source>
1378-
<translation>Auto Reconnect</translation>
1390+
<translation>Reconnect</translation>
13791391
</message>
13801392
<message>
13811393
<source>TX 颜色</source>
@@ -1435,7 +1447,7 @@ Content: %4</translation>
14351447
</message>
14361448
<message>
14371449
<source>批量发送</source>
1438-
<translation>Batch Send</translation>
1450+
<translation>Batch</translation>
14391451
</message>
14401452
<message>
14411453
<source>删除</source>
@@ -1455,7 +1467,7 @@ Content: %4</translation>
14551467
</message>
14561468
<message>
14571469
<source>响应包含,留空不等待</source>
1458-
<translation>Response contains, leave empty to skip waiting</translation>
1470+
<translation>Expected response</translation>
14591471
</message>
14601472
<message>
14611473
<source>文</source>
@@ -1475,7 +1487,7 @@ Content: %4</translation>
14751487
</message>
14761488
<message>
14771489
<source>失败中止</source>
1478-
<translation>Abort on Failure</translation>
1490+
<translation>Abort Fail</translation>
14791491
</message>
14801492
<message>
14811493
<source>循环</source>
@@ -1491,7 +1503,7 @@ Content: %4</translation>
14911503
</message>
14921504
<message>
14931505
<source>导出结果</source>
1494-
<translation>Export Results</translation>
1506+
<translation>Export</translation>
14951507
</message>
14961508
<message>
14971509
<source>未运行</source>
@@ -1527,7 +1539,7 @@ Content: %4</translation>
15271539
</message>
15281540
<message>
15291541
<source>选择待发送文件</source>
1530-
<translation>Select file to send</translation>
1542+
<translation>Select file</translation>
15311543
</message>
15321544
<message>
15331545
<source>浏览</source>
348 Bytes
Binary file not shown.

src/app/resources/i18n/fluentserialassistant.zh_CN.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,10 +463,22 @@ JSON 对象:读取数值字段,数组字段会展开
463463
<source>当前窗口和已打开页面已刷新。</source>
464464
<translation>当前窗口和已打开页面已刷新。</translation>
465465
</message>
466+
<message>
467+
<source>当前接收显示为 %1,点击切换为 %2</source>
468+
<translation>当前接收显示为 %1,点击切换为 %2</translation>
469+
</message>
466470
<message>
467471
<source>文本</source>
468472
<translation>文本</translation>
469473
</message>
474+
<message>
475+
<source>当前为 HEX 发送,点击切换为文本</source>
476+
<translation>当前为 HEX 发送,点击切换为文本</translation>
477+
</message>
478+
<message>
479+
<source>当前为文本发送,点击切换为 HEX</source>
480+
<translation>当前为文本发送,点击切换为 HEX</translation>
481+
</message>
470482
<message>
471483
<source>混合</source>
472484
<translation>混合</translation>

src/app/view/settings_page.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,6 @@ SettingsPage::SettingsPage(QWidget *parent)
193193
connect(languageCard, &ComboBoxSettingCard::currentIndexChanged, this, [this, languageCard](int index) {
194194
const QString localeName = AppI18n::applyLocale(AppI18n::localeNameForIndex(index));
195195
languageCard->setContent(AppI18n::text("当前:%1").arg(AppI18n::localeDisplayName(localeName)));
196-
InfoBar::success(AppI18n::text("语言已切换"),
197-
AppI18n::text("当前窗口和已打开页面已刷新。"), Qt::Horizontal, true,
198-
2500, InfoBarPosition::Top, window());
199196
});
200197
connect(FluentConfig::instance(), &FluentConfig::localeNameChanged, this, [languageCard](const QString &localeName) {
201198
const int index = AppI18n::localeIndex(localeName);

src/app/view/workbench/workbench_page_internal.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ constexpr int SidePanelWidth = 324;
6161
constexpr int TerminalPanelMinWidth = 560;
6262
constexpr int ReconnectIntervalMs = 2000;
6363
constexpr int CompactControlHeight = 32;
64+
constexpr int FormLabelWidth = 84;
6465
constexpr int DefaultFileChunkSize = 256;
6566
constexpr int DefaultFileChunkIntervalMs = 10;
6667
constexpr int MaxFrameBufferBytes = 1024 * 1024;
@@ -225,7 +226,8 @@ inline void addFormRow(QVBoxLayout *root, const QString &labelText, QWidget *con
225226
row->setSpacing(8);
226227

227228
auto *label = new BodyLabel(labelText, parent);
228-
setFixedControlWidth(label, 52);
229+
setFixedControlWidth(label, FormLabelWidth);
230+
label->setToolTip(labelText);
229231
row->addWidget(label, 0, Qt::AlignVCenter);
230232

231233
control->setMinimumWidth(0);

src/app/view/workbench/workbench_page_side_sections.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "app/view/workbench/workbench_page_internal.h"
21
#include "app/core/app_i18n.h"
2+
#include "app/view/workbench/workbench_page_internal.h"
33

44
using namespace FluentQt;
55
using namespace WorkbenchPagePrivate;
@@ -203,6 +203,7 @@ QWidget *WorkbenchPage::createReceiveSettingsSection()
203203
connect(m_displayModeSegment, &SegmentedWidget::currentItemChanged, this, [this](const QString &routeKey) {
204204
QSettings settings;
205205
settings.setValue(QStringLiteral("terminal/displayMode"), routeKey);
206+
updateReceiveModeButton();
206207
renderTerminal();
207208
});
208209
connect(m_receiveEncodingCombo, &ComboBox::currentIndexChanged, this, [this](int) {
@@ -383,9 +384,10 @@ QWidget *WorkbenchPage::createSendSettingsSection()
383384
settings.setValue(QStringLiteral("checksum/autoAppend"), checked);
384385
});
385386
connect(m_checksumCalcButton, &PushButton::clicked, this, &WorkbenchPage::calculateChecksumForCurrentPayload);
386-
connect(m_hexSendCheck, &CheckBox::toggled, this, [](bool checked) {
387+
connect(m_hexSendCheck, &CheckBox::toggled, this, [this](bool checked) {
387388
QSettings settings;
388389
settings.setValue(QStringLiteral("send/mode"), checked ? QStringLiteral("hex") : QStringLiteral("text"));
390+
updateSendModeButton();
389391
});
390392
connect(m_showTxCheck, &CheckBox::toggled, this, [this](bool checked) {
391393
QSettings settings;

src/app/view/workbench/workbench_page_terminal_sections.cpp

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,32 @@
55
using namespace FluentQt;
66
using namespace WorkbenchPagePrivate;
77

8+
namespace {
9+
10+
bool isReceiveHexMode(const QString &mode)
11+
{
12+
return mode == QStringLiteral("hex");
13+
}
14+
15+
QString shortcutReceiveDisplayModeLabel(bool hexMode)
16+
{
17+
return hexMode ? QStringLiteral("HEX") : AppI18n::text("文本");
18+
}
19+
20+
QString nextReceiveDisplayMode(bool hexMode)
21+
{
22+
return hexMode ? QStringLiteral("text") : QStringLiteral("hex");
23+
}
24+
25+
} // namespace
26+
827
QWidget *WorkbenchPage::createTerminalSection()
928
{
1029
auto *section = new HeaderCardWidget(this);
1130
hideCardTitle(section);
1231
auto *root = cardBody(section, 10);
1332
section->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
1433

15-
section->headerLayout()->addStretch(1);
1634
section->headerLayout()->addWidget(new BodyLabel(QStringLiteral("RX"), section));
1735
m_rxCounterLabel = new StrongBodyLabel(QStringLiteral("0 B"), section);
1836
section->headerLayout()->addWidget(m_rxCounterLabel);
@@ -27,6 +45,7 @@ QWidget *WorkbenchPage::createTerminalSection()
2745
section->headerLayout()->addWidget(m_txRateLabel);
2846
m_connectionTimeLabel = new CaptionLabel(AppI18n::text("未连接"), section);
2947
section->headerLayout()->addWidget(m_connectionTimeLabel);
48+
section->headerLayout()->addStretch(1);
3049

3150
auto *searchButton = new TransparentToolButton(icon(FluentIcon::Search), section);
3251
searchButton->setToolTip(AppI18n::text("搜索"));
@@ -36,9 +55,11 @@ QWidget *WorkbenchPage::createTerminalSection()
3655
themeButton->setToolTip(AppI18n::text("切换主题"));
3756
auto *languageButton = new TransparentToolButton(icon(FluentIcon::Language), section);
3857
languageButton->setToolTip(AppI18n::text("切换语言"));
58+
m_receiveModeButton = new TransparentToolButton(icon(FluentIcon::Font), section);
3959
auto *settingsButton = new TransparentToolButton(icon(FluentIcon::Setting), section);
4060
settingsButton->setToolTip(AppI18n::text("设置"));
41-
for (ToolButton *button : {searchButton, plotButton, themeButton, languageButton, settingsButton}) {
61+
for (ToolButton *button : {searchButton, plotButton, themeButton, languageButton, m_receiveModeButton,
62+
settingsButton}) {
4263
button->setFixedSize(CompactControlHeight, CompactControlHeight);
4364
button->setIconSize(QSize(16, 16));
4465
}
@@ -47,6 +68,7 @@ QWidget *WorkbenchPage::createTerminalSection()
4768
section->headerLayout()->addWidget(plotButton);
4869
section->headerLayout()->addWidget(themeButton);
4970
section->headerLayout()->addWidget(languageButton);
71+
section->headerLayout()->addWidget(m_receiveModeButton);
5072
section->headerLayout()->addWidget(settingsButton);
5173

5274
auto *searchView = new FlyoutView(AppI18n::text("终端搜索"), QString(), icon(FluentIcon::Search), QPixmap(), true);
@@ -132,10 +154,12 @@ QWidget *WorkbenchPage::createTerminalSection()
132154
FluentConfig::instance()->save();
133155
ThemeManager::instance()->setTheme(next);
134156
});
135-
connect(languageButton, &TransparentToolButton::clicked, this, [this]() {
136-
const QString localeName = AppI18n::applyLocale(AppI18n::toggledChineseEnglishLocaleName());
137-
showSuccess(AppI18n::text("语言已切换"),
138-
AppI18n::text("当前:%1").arg(AppI18n::localeDisplayName(localeName)));
157+
connect(languageButton, &TransparentToolButton::clicked, this,
158+
[]() { AppI18n::applyLocale(AppI18n::toggledChineseEnglishLocaleName()); });
159+
connect(m_receiveModeButton, &TransparentToolButton::clicked, this, [this]() {
160+
if (m_displayModeSegment) {
161+
m_displayModeSegment->setCurrentItem(nextReceiveDisplayMode(isReceiveHexMode(currentDisplayMode())));
162+
}
139163
});
140164
connect(settingsButton, &TransparentToolButton::clicked, this, &WorkbenchPage::settingsRequested);
141165
connect(m_terminalSearchEdit, &SearchLineEdit::textChanged, this, [this]() {
@@ -159,10 +183,25 @@ QWidget *WorkbenchPage::createTerminalSection()
159183
renderTerminal();
160184
});
161185
connect(m_terminalFilterCombo, &ComboBox::currentIndexChanged, this, [this](int) { renderTerminal(); });
186+
updateReceiveModeButton();
162187

163188
return section;
164189
}
165190

191+
void WorkbenchPage::updateReceiveModeButton()
192+
{
193+
if (!m_receiveModeButton) {
194+
return;
195+
}
196+
197+
const bool hexMode = isReceiveHexMode(currentDisplayMode());
198+
const QString currentLabel = shortcutReceiveDisplayModeLabel(hexMode);
199+
const QString nextLabel = shortcutReceiveDisplayModeLabel(!hexMode);
200+
m_receiveModeButton->setIcon(icon(hexMode ? FluentIcon::Code : FluentIcon::Font));
201+
m_receiveModeButton->setToolTip(
202+
AppI18n::text("当前接收显示为 %1,点击切换为 %2").arg(currentLabel, nextLabel));
203+
}
204+
166205
QWidget *WorkbenchPage::createSendSection()
167206
{
168207
auto *section = new HeaderCardWidget(this);
@@ -179,6 +218,12 @@ QWidget *WorkbenchPage::createSendSection()
179218
m_sendEdit->installEventFilter(this);
180219
sendRow->addWidget(m_sendEdit, 1);
181220

221+
m_sendModeButton = new PushButton(section);
222+
setFixedControlWidth(m_sendModeButton, 72);
223+
m_sendModeButton->setMinimumHeight(112);
224+
m_sendModeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
225+
sendRow->addWidget(m_sendModeButton);
226+
182227
m_sendButton = new PrimaryPushButton(icon(FluentIcon::Send), QString(), section);
183228
m_sendButton->setToolTip(AppI18n::text("发送"));
184229
m_sendButton->setIconSize(QSize(40, 40));
@@ -188,7 +233,25 @@ QWidget *WorkbenchPage::createSendSection()
188233

189234
root->addLayout(sendRow);
190235

236+
connect(m_sendModeButton, &PushButton::clicked, this, [this]() {
237+
if (m_hexSendCheck) {
238+
m_hexSendCheck->setChecked(!m_hexSendCheck->isChecked());
239+
}
240+
});
191241
connect(m_sendButton, &PrimaryPushButton::clicked, this, &WorkbenchPage::sendCurrentPayload);
242+
updateSendModeButton();
192243

193244
return section;
194245
}
246+
247+
void WorkbenchPage::updateSendModeButton()
248+
{
249+
if (!m_sendModeButton) {
250+
return;
251+
}
252+
253+
const bool hexMode = m_hexSendCheck && m_hexSendCheck->isChecked();
254+
m_sendModeButton->setText(hexMode ? QStringLiteral("HEX") : AppI18n::text("文本"));
255+
m_sendModeButton->setToolTip(hexMode ? AppI18n::text("当前为 HEX 发送,点击切换为文本")
256+
: AppI18n::text("当前为文本发送,点击切换为 HEX"));
257+
}

src/app/view/workbench_page.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ WorkbenchPage::WorkbenchPage(QWidget *parent, bool restoreSavedSession, bool all
2929
updateConnectionUi(m_serial.isOpen());
3030
updateCounters();
3131
updateHistoryCombo();
32+
updateReceiveModeButton();
33+
updateSendModeButton();
3234
updatePacketTable(m_packetList ? m_packetList->currentRow() : -1);
3335
updateMacroTable(m_macroList ? m_macroList->currentRow() : -1);
3436
updateAutoReplyTable(m_autoReplyList ? m_autoReplyList->currentRow() : -1);

0 commit comments

Comments
 (0)