feat: 国际化支持,英文源串+中文翻译

全部44处qsTr源串改为英文,新建translations/jnetapplet_zh_CN.ts
中文翻译文件。CMake增加LinguistTools+qt_add_translation编译
.ts->.qm,init()按系统语言加载.qm并安装到qApp。

中文系统显示中文翻译,英文系统显示英文源串。
This commit is contained in:
2026-07-24 11:40:12 +08:00
parent 43fdcc8b0a
commit fba506d9d8
9 changed files with 318 additions and 48 deletions
+8 -8
View File
@@ -83,7 +83,7 @@ Window {
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
text: qsTr("关于")
text: qsTr("About")
font.pixelSize: 15
font.weight: Font.Bold
color: root.textPrimary
@@ -130,7 +130,7 @@ Window {
spacing: 2
Text {
text: qsTr("网络速度监控")
text: qsTr("Network Speed Monitor")
font.pixelSize: 18
font.weight: Font.Bold
color: root.textPrimary
@@ -179,7 +179,7 @@ Window {
spacing: 0
Text {
text: qsTr("版本")
text: qsTr("Version")
font.pixelSize: 12
color: "#0081FF"
Layout.preferredWidth: 56
@@ -200,7 +200,7 @@ Window {
spacing: 0
Text {
text: qsTr("作者")
text: qsTr("Author")
font.pixelSize: 12
color: "#0081FF"
Layout.preferredWidth: 56
@@ -221,7 +221,7 @@ Window {
spacing: 0
Text {
text: qsTr("描述")
text: qsTr("Description")
font.pixelSize: 12
color: "#0081FF"
Layout.preferredWidth: 56
@@ -229,7 +229,7 @@ Window {
}
Text {
text: qsTr("监控网络速度和流量")
text: qsTr("Monitor network speed and traffic")
font.pixelSize: 12
color: root.textPrimary
Layout.fillWidth: true
@@ -243,7 +243,7 @@ Window {
spacing: 0
Text {
text: qsTr("仓库")
text: qsTr("Repository")
font.pixelSize: 12
color: "#0081FF"
Layout.preferredWidth: 56
@@ -281,7 +281,7 @@ Window {
Text {
id: copiedHintText
anchors.centerIn: parent
text: qsTr("已复制")
text: qsTr("Copied")
font.pixelSize: 10
color: "#22A34A"
}
+7 -7
View File
@@ -95,7 +95,7 @@ Control {
spacing: 6
Text {
text: qsTr("网络速度监控")
text: qsTr("Network Speed Monitor")
font.pixelSize: 15
font.weight: Font.Bold
color: popup.primaryText
@@ -126,7 +126,7 @@ Control {
}
Text {
text: popup.ipAddress ? qsTr("IPv4") + popup.ipAddress : ""
text: popup.ipAddress ? qsTr("IPv4: ") + popup.ipAddress : ""
font.pixelSize: 13
color: popup.secondaryText
visible: popup.ipAddress !== ""
@@ -135,7 +135,7 @@ Control {
// IPv6 全球地址行,无 IPv6 时隐藏不占位
Text {
text: popup.ipv6Address ? qsTr("IPv6") + popup.ipv6Address : ""
text: popup.ipv6Address ? qsTr("IPv6: ") + popup.ipv6Address : ""
font.pixelSize: 13
color: popup.secondaryText
visible: popup.ipv6Address !== ""
@@ -187,7 +187,7 @@ Control {
}
Text {
text: qsTr("下载")
text: qsTr("Download")
font.pixelSize: 11
color: popup.secondaryText
Layout.alignment: Qt.AlignHCenter
@@ -244,7 +244,7 @@ Control {
}
Text {
text: qsTr("上传")
text: qsTr("Upload")
font.pixelSize: 11
color: popup.secondaryText
Layout.alignment: Qt.AlignHCenter
@@ -279,7 +279,7 @@ Control {
Item { Layout.fillWidth: true }
Text {
text: qsTr("总计")
text: qsTr("Total")
font.pixelSize: 11
font.weight: Font.Bold
color: popup.secondaryText
@@ -456,7 +456,7 @@ Control {
}
Text {
text: qsTr("未检测到网络接口")
text: qsTr("No network interface detected")
font.pixelSize: 12
color: popup.secondaryText
Layout.alignment: Qt.AlignHCenter
+20 -20
View File
@@ -51,7 +51,7 @@ Window {
readonly property color selText: isDarkMode ? "#64B5F6" : "#1565C0"
// 卸载按钮文字:复制命令后临时显示提示,定时器到期后还原
property string uninstallButtonText: qsTr("卸载插件")
property string uninstallButtonText: qsTr("Uninstall Plugin")
width: 350
height: 390
@@ -70,15 +70,15 @@ Window {
// 设计原因:用户面对多个网口时难以仅凭 enp3s0/wlp3s0 等命名判断用途,
// 加一行类型说明(有线/无线/VPN 等)降低认知负担
function interfaceDescription(name) {
if (name === "lo") return qsTr("本地回环")
if (name === "Meta") return qsTr("虚拟接口")
if (/^enp|^eth/.test(name)) return qsTr("有线网络")
if (/^wlp|^wlan/.test(name)) return qsTr("无线网络")
if (/^docker|^veth/.test(name)) return qsTr("容器网络")
if (/^br/.test(name)) return qsTr("桥接")
if (name === "lo") return qsTr("Loopback")
if (name === "Meta") return qsTr("Virtual Interface")
if (/^enp|^eth/.test(name)) return qsTr("Wired Network")
if (/^wlp|^wlan/.test(name)) return qsTr("Wireless Network")
if (/^docker|^veth/.test(name)) return qsTr("Container Network")
if (/^br/.test(name)) return qsTr("Bridge")
if (/^tun|^tap/.test(name)) return qsTr("VPN")
if (/^virbr/.test(name)) return qsTr("虚拟桥接")
return qsTr("其他")
if (/^virbr/.test(name)) return qsTr("Virtual Bridge")
return qsTr("Other")
}
// 根据接口名返回类型图标(Unicode 符号),用于网络接口列表每行左侧
@@ -139,7 +139,7 @@ Window {
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
text: qsTr("设置")
text: qsTr("Settings")
font.pixelSize: 15
font.weight: Font.Bold
color: root.textPrimary
@@ -193,7 +193,7 @@ Window {
// 网络接口选择区
Text {
text: qsTr("网络接口")
text: qsTr("Network Interface")
font.pixelSize: 13
font.weight: Font.Bold
color: root.textSecondary
@@ -346,7 +346,7 @@ Window {
// 无接口提示:在卡片内居中
Text {
anchors.centerIn: parent
text: qsTr("未检测到网络接口")
text: qsTr("No network interface detected")
font.pixelSize: 12
color: root.textTertiary
visible: networkInterfaces.length === 0
@@ -357,7 +357,7 @@ Window {
// 设计原因:用户选择的颜色通过 applet.textColor 持久化到
// ~/.config/jnetapplet/settings.ini,重启 dde-shell 后仍生效
Text {
text: qsTr("字体颜色")
text: qsTr("Font Color")
font.pixelSize: 13
font.weight: Font.Bold
color: root.textSecondary
@@ -380,7 +380,7 @@ Window {
Layout.fillWidth: true
Layout.preferredHeight: 40
// 提示状态时背景和边框变绿
readonly property bool isStatus: uninstallButtonText !== qsTr("卸载插件")
readonly property bool isStatus: uninstallButtonText !== qsTr("Uninstall Plugin")
color: isStatus
? Qt.rgba(22/255, 163/255, 74/255, 0.08)
: (uninstallMouse.containsMouse ? Qt.rgba(220/255, 38/255, 38/255, 0.15) : Qt.rgba(220/255, 38/255, 38/255, 0.08))
@@ -443,7 +443,7 @@ Window {
anchors.margins: 20
Text {
text: qsTr("警告")
text: qsTr("Warning")
font.pixelSize: 16
font.weight: Font.Bold
color: accentColor
@@ -451,7 +451,7 @@ Window {
}
Text {
text: qsTr("以下命令用于卸载插件并重启 dde-shell,请复制到终端中执行:")
text: qsTr("The following command uninstalls the plugin and restarts dde-shell. Please copy and run it in terminal:")
font.pixelSize: 12
color: root.textPrimary
Layout.alignment: Qt.AlignHCenter
@@ -496,7 +496,7 @@ Window {
Text {
anchors.centerIn: parent
text: qsTr("取消")
text: qsTr("Cancel")
font.pixelSize: 13
color: root.textPrimary
}
@@ -519,7 +519,7 @@ Window {
Text {
anchors.centerIn: parent
text: qsTr("复制命令")
text: qsTr("Copy Command")
font.pixelSize: 13
font.weight: Font.Medium
color: "white"
@@ -536,7 +536,7 @@ Window {
clipboardHelper.copy()
uninstallConfirmDialog.close()
// 卸载按钮文字临时替换为复制成功提示,5 秒后还原
uninstallButtonText = qsTr("卸载命令已复制到剪贴板,请在终端中粘贴执行")
uninstallButtonText = qsTr("Uninstall command copied to clipboard. Please paste and run it in terminal.")
statusHideTimer.start()
}
}
@@ -557,6 +557,6 @@ Window {
Timer {
id: statusHideTimer
interval: 5000
onTriggered: uninstallButtonText = qsTr("卸载插件")
onTriggered: uninstallButtonText = qsTr("Uninstall Plugin")
}
}
+3 -3
View File
@@ -177,7 +177,7 @@ Window {
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
text: qsTr("流量波动图")
text: qsTr("Traffic Chart")
font.pixelSize: 15
font.weight: Font.Bold
color: root.textPrimary
@@ -421,7 +421,7 @@ Window {
ctx.font = "13px sans-serif"
ctx.textAlign = "center"
ctx.textBaseline = "middle"
ctx.fillText(qsTr("暂无历史数据"), pl + pw / 2, pt + ph / 2)
ctx.fillText(qsTr("No history data"), pl + pw / 2, pt + ph / 2)
return
}
@@ -578,7 +578,7 @@ Window {
Text {
anchors.centerIn: parent
text: root.hoverHint.length > 0
? root.hoverHint : qsTr("鼠标移到曲线上查看详情")
? root.hoverHint : qsTr("Hover over the curve for details")
font.pixelSize: 11
color: root.hoverHint.length > 0 ? root.textPrimary : root.textTertiary
}
+6 -6
View File
@@ -222,9 +222,9 @@ AppletItem {
id: toolTip
text: root.ready
? (root.activeInterface
+ " · IPv4" + (root.ipAddress || qsTr(""))
+ (root.ipv6Address ? "\nIPv6" + root.ipv6Address : ""))
: qsTr("未检测到网络接口")
+ " · " + qsTr("IPv4: ") + (root.ipAddress || qsTr("None"))
+ (root.ipv6Address ? "\n" + qsTr("IPv6: ") + root.ipv6Address : ""))
: qsTr("No network interface detected")
toolTipX: DockPanelPositioner.x
toolTipY: DockPanelPositioner.y
}
@@ -300,7 +300,7 @@ AppletItem {
id: contextMenu
Platform.MenuItem {
text: qsTr("设置")
text: qsTr("Settings")
onTriggered: {
settingsWindow.show()
settingsWindow.raise()
@@ -310,7 +310,7 @@ AppletItem {
// 流量波动图:屏幕居中独立窗口,展示活动接口最近 30 分钟网速趋势
Platform.MenuItem {
text: qsTr("流量波动图")
text: qsTr("Traffic Chart")
onTriggered: {
trafficChartWindow.show()
trafficChartWindow.raise()
@@ -321,7 +321,7 @@ AppletItem {
Platform.MenuSeparator {}
Platform.MenuItem {
text: qsTr("关于")
text: qsTr("About")
onTriggered: {
aboutWindow.show()
aboutWindow.raise()