Skip to content

Commit

Permalink
fix: optimize the shortcut confict alter message
Browse files Browse the repository at this point in the history
  • Loading branch information
AkaShark committed Feb 1, 2024
1 parent a496ff5 commit d497caa
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
29 changes: 26 additions & 3 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -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" : "快捷键”%@“,无法使用"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Easydict/NewApp/Feature/Shortcut/Shortcut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bool>(
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d497caa

Please sign in to comment.