From 7aa719588f330e9865da80475c7d5b35dee3cdc5 Mon Sep 17 00:00:00 2001 From: Jefsky Date: Thu, 28 May 2026 15:57:34 +0800 Subject: [PATCH] fix(i18n): support dynamic translation for command labels Plugins register commands with ctx.i18n.translate() which resolves to a static string. When the user switches languages, these labels don't update because they're stored as resolved strings in config. Fix by adding optional labelKey property to IShortKeyConfig and IPluginShortKeyConfig. When labelKey is provided, the UI uses it to dynamically translate the label via $T() instead of using the static label string. This is backward compatible - existing plugins that only provide label still work as before. New plugins can provide labelKey for dynamic translation: label: ctx.i18n.translate('PIC_GDRIVE_COMMAND_UPLOAD'), labelKey: 'PIC_GDRIVE_COMMAND_UPLOAD', Fixes #1188 --- src/main/apis/app/shortKey/shortKeyHandler.ts | 1 + src/renderer/pages/ShortKey.vue | 2 +- src/universal/types/types.d.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/apis/app/shortKey/shortKeyHandler.ts b/src/main/apis/app/shortKey/shortKeyHandler.ts index c0ba7597c..26706fd59 100644 --- a/src/main/apis/app/shortKey/shortKeyHandler.ts +++ b/src/main/apis/app/shortKey/shortKeyHandler.ts @@ -89,6 +89,7 @@ class ShortKeyHandler { enable: true, name: config.name, label: config.label, + labelKey: config.labelKey, key: config.key } }) diff --git a/src/renderer/pages/ShortKey.vue b/src/renderer/pages/ShortKey.vue index d049e3bb4..90a1abb16 100644 --- a/src/renderer/pages/ShortKey.vue +++ b/src/renderer/pages/ShortKey.vue @@ -19,7 +19,7 @@ :label="$T('SHORTCUT_NAME')" >