diff --git a/Easydict/App/Localizable.xcstrings b/Easydict/App/Localizable.xcstrings index 344105d83..99c333888 100644 --- a/Easydict/App/Localizable.xcstrings +++ b/Easydict/App/Localizable.xcstrings @@ -3136,19 +3136,42 @@ } } }, - "shortcut_confict_message" : { + "shortcut_confict_message (Shortcut.shared.confictMenuItem?.title ?? \"\")" : { + + }, + "shortcut_confict_message %@" : { "extractionState" : "manual", "localizations" : { "en" : { "stringUnit" : { "state" : "translated", - "value" : "Shortcut Confict With" + "value" : "The current shortcut can't be used because it is already used \"%@\"" } }, "zh-Hans" : { "stringUnit" : { "state" : "translated", - "value" : "快捷键冲突" + "value" : "当前快捷键无法使用,因为它已被\n“%@”占用" + } + } + } + }, + "shortcut_confict_title (keyCombo!.keyEquivalentModifierMaskString + keyCombo!.characters)" : { + + }, + "shortcut_confict_title %@" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Shortcut Confict With \"%@\" Unable Use This" + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "快捷键”%@“,无法使用" } } } diff --git a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift index f4eaf72ec..434c33c77 100644 --- a/Easydict/NewApp/Feature/Shortcut/Shortcut.swift +++ b/Easydict/NewApp/Feature/Shortcut/Shortcut.swift @@ -23,6 +23,7 @@ public enum ShortcutType: String { // Confict Message public struct ShortcutConfictAlertMessage: Identifiable { public var id: String { message } + var title: String var message: String } diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift index 7c8b50c5f..e94dfda4e 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralKeyHolderWrapper.swift @@ -63,11 +63,12 @@ extension GeneralKeyHolderWrapper { // shortcut validate confict if Shortcut.validateShortcut(key) { if #available(macOS 12, *) { - confictAlterMessage = ShortcutConfictAlertMessage(message: String(localized: "shortcut_confict_message") + " " + (Shortcut.shared.confictMenuItem?.title ?? "")) + confictAlterMessage = ShortcutConfictAlertMessage(title: String(localized: "shortcut_confict_title \(keyCombo!.keyEquivalentModifierMaskString + keyCombo!.characters)"), message: String(localized: "shortcut_confict_message \(Shortcut.shared.confictMenuItem?.title ?? "")")) } else { // Fallback on earlier versions - let msg = NSLocalizedString("shortcut_confict_message", comment: "") + " " + (Shortcut.shared.confictMenuItem?.title ?? "") - confictAlterMessage = ShortcutConfictAlertMessage(message: msg) + let title = NSLocalizedString("shortcut_confict_title \(keyCombo!.keyEquivalentModifierMaskString + keyCombo!.characters)", comment: "") + let msg = NSLocalizedString("shortcut_confict_message \(Shortcut.shared.confictMenuItem?.title ?? "")", comment: "") + confictAlterMessage = ShortcutConfictAlertMessage(title: title, message: msg) } recordView.clear() return diff --git a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift index c18ef3c88..aaede6309 100644 --- a/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift +++ b/Easydict/NewApp/View/SettingView/Tabs/View/Shortcut/GeneralShortcutSetting.swift @@ -11,7 +11,7 @@ import SwiftUI @available(macOS 13, *) extension ShortcutTab { struct GeneralShortcutSettingView: View { - @State var confictAlterMessage: ShortcutConfictAlertMessage = .init(message: "") + @State var confictAlterMessage: ShortcutConfictAlertMessage = .init(title: "", message: "") var body: some View { let showAlter = Binding( @@ -59,7 +59,7 @@ extension ShortcutTab { presenting: confictAlterMessage) { _ in Button(String(localized: "shortcut_confict_confirm")) { - confictAlterMessage = ShortcutConfictAlertMessage(message: "") + confictAlterMessage = ShortcutConfictAlertMessage(title: "", message: "") } } message: { message in Text(message.message)