From 63face00a71f8ba326bac5679767b93539919324 Mon Sep 17 00:00:00 2001 From: jokul Date: Mon, 13 Jul 2026 20:31:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=E6=94=AF=E6=8C=81=EF=BC=8C=E9=80=82=E9=85=8D=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CMakeLists.txt 添加 LinguistTools 翻译构建流程 - 添加 zh_CN 翻译文件(11 条) - 构建时自动用 lrelease 编译 .ts 到 .qm - .qm 文件安装到 translations/ 目录,dde-shell 自动加载 - 添加 update_translations 目标用于手动更新翻译源文件 - .gitignore 忽略 .qm 编译产物 --- .gitignore | 1 + CMakeLists.txt | 37 ++++++++++- .../org.deepin.ds.graphics-driver_zh_CN.ts | 62 +++++++++++++++++++ 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 translations/org.deepin.ds.graphics-driver_zh_CN.ts diff --git a/.gitignore b/.gitignore index 3a9054b..170653c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ .cache/ *.o *.so +*.qm diff --git a/CMakeLists.txt b/CMakeLists.txt index 690d2f1..5238b01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,42 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_AUTOMOC ON) -find_package(Qt6 REQUIRED COMPONENTS Core Quick DBus) +find_package(Qt6 REQUIRED COMPONENTS Core Quick DBus LinguistTools) find_package(Dtk6 REQUIRED COMPONENTS Core) +# 插件 ID +set(PLUGIN_ID "org.deepin.ds.graphics-driver") + +# 翻译源文件目录 +set(TRANSLATIONS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/translations) + +# 翻译文件列表 +set(TS_FILES + ${TRANSLATIONS_DIR}/${PLUGIN_ID}_zh_CN.ts +) + +# 生成 .qm 编译翻译文件 +set(QM_FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_ID}_zh_CN.qm +) + +add_custom_command( + OUTPUT ${QM_FILES} + COMMAND /usr/lib/qt6/bin/lrelease ${TS_FILES} -qm ${QM_FILES} + DEPENDS ${TS_FILES} + COMMENT "Compiling translations to .qm files" +) + +# 手动更新翻译源文件(不加入 ALL,仅在需要时手动 make update_translations) +add_custom_target(update_translations + COMMAND /usr/lib/qt6/bin/lupdate ${CMAKE_CURRENT_SOURCE_DIR}/package -ts ${TS_FILES} + COMMENT "Updating translation source files" +) + add_library(org.deepin.ds.graphics-driver SHARED graphicsdriverapplet.h graphicsdriverapplet.cpp + ${QM_FILES} ) set_target_properties(org.deepin.ds.graphics-driver PROPERTIES PREFIX "") @@ -34,5 +64,6 @@ target_link_libraries(org.deepin.ds.graphics-driver PRIVATE # 安装到dde-shell插件目录 install(TARGETS org.deepin.ds.graphics-driver DESTINATION /usr/lib/x86_64-linux-gnu/dde-shell) -install(FILES package/metadata.json DESTINATION /usr/share/dde-shell/org.deepin.ds.graphics-driver) -install(FILES package/driverview.qml DESTINATION /usr/share/dde-shell/org.deepin.ds.graphics-driver) +install(FILES package/metadata.json DESTINATION /usr/share/dde-shell/${PLUGIN_ID}) +install(FILES package/driverview.qml DESTINATION /usr/share/dde-shell/${PLUGIN_ID}) +install(FILES ${QM_FILES} DESTINATION /usr/share/dde-shell/${PLUGIN_ID}/translations) diff --git a/translations/org.deepin.ds.graphics-driver_zh_CN.ts b/translations/org.deepin.ds.graphics-driver_zh_CN.ts new file mode 100644 index 0000000..027aa5b --- /dev/null +++ b/translations/org.deepin.ds.graphics-driver_zh_CN.ts @@ -0,0 +1,62 @@ + + + + + driverview + + + Unknown + 未知 + + + + Graphics Driver: + 显卡驱动: + + + + Graphics Driver Manager + 显卡驱动管理 + + + + Driver service is not available + 驱动服务不可用 + + + + Device Information + 设备信息 + + + + Current Driver: + 当前驱动: + + + + Device: + 设备: + + + + Refresh + 刷新 + + + + Test Install + 测试安装 + + + + Installing... + 安装中... + + + + Cancel + 取消 + + +