PhraseEditor // Add tooltip to the weight field.
This commit is contained in:
parent
b2c2182d36
commit
5bbc4edf33
|
@ -32,10 +32,10 @@ public struct VwrPhraseEditorUI: View {
|
|||
@ObservedObject public var fileChangeIndicator = FileObserveProject.shared
|
||||
@State private var selAutoReloadExternalModifications: Bool = UserDefaults.standard.bool(
|
||||
forKey: UserDef.kPhraseEditorAutoReloadExternalModifications.rawValue)
|
||||
@State var lblAddPhraseTag1 = UITerms.AddPhrases.locPhrase.localized.0
|
||||
@State var lblAddPhraseTag2 = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
@State var lblAddPhraseTag3 = UITerms.AddPhrases.locWeight.localized.0
|
||||
@State var lblAddPhraseTag4 = UITerms.AddPhrases.locComment.localized.0
|
||||
@State var lblAddPhraseTag1 = PETerms.AddPhrases.locPhrase.localized.0
|
||||
@State var lblAddPhraseTag2 = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
@State var lblAddPhraseTag3 = PETerms.AddPhrases.locWeight.localized.0
|
||||
@State var lblAddPhraseTag4 = PETerms.AddPhrases.locComment.localized.0
|
||||
@State var txtAddPhraseField1 = ""
|
||||
@State var txtAddPhraseField2 = ""
|
||||
@State var txtAddPhraseField3 = ""
|
||||
|
@ -86,33 +86,33 @@ public struct VwrPhraseEditorUI: View {
|
|||
clearAllFields()
|
||||
switch selUserDataType {
|
||||
case .thePhrases:
|
||||
lblAddPhraseTag1 = UITerms.AddPhrases.locPhrase.localized.0
|
||||
lblAddPhraseTag2 = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
lblAddPhraseTag3 = UITerms.AddPhrases.locWeight.localized.0
|
||||
lblAddPhraseTag4 = UITerms.AddPhrases.locComment.localized.0
|
||||
lblAddPhraseTag1 = PETerms.AddPhrases.locPhrase.localized.0
|
||||
lblAddPhraseTag2 = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
lblAddPhraseTag3 = PETerms.AddPhrases.locWeight.localized.0
|
||||
lblAddPhraseTag4 = PETerms.AddPhrases.locComment.localized.0
|
||||
case .theFilter:
|
||||
lblAddPhraseTag1 = UITerms.AddPhrases.locPhrase.localized.0
|
||||
lblAddPhraseTag2 = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
lblAddPhraseTag1 = PETerms.AddPhrases.locPhrase.localized.0
|
||||
lblAddPhraseTag2 = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
lblAddPhraseTag3 = ""
|
||||
lblAddPhraseTag4 = UITerms.AddPhrases.locComment.localized.0
|
||||
lblAddPhraseTag4 = PETerms.AddPhrases.locComment.localized.0
|
||||
case .theReplacements:
|
||||
lblAddPhraseTag1 = UITerms.AddPhrases.locReplaceTo.localized.0
|
||||
lblAddPhraseTag2 = UITerms.AddPhrases.locReplaceTo.localized.1
|
||||
lblAddPhraseTag1 = PETerms.AddPhrases.locReplaceTo.localized.0
|
||||
lblAddPhraseTag2 = PETerms.AddPhrases.locReplaceTo.localized.1
|
||||
lblAddPhraseTag3 = ""
|
||||
lblAddPhraseTag4 = UITerms.AddPhrases.locComment.localized.0
|
||||
lblAddPhraseTag4 = PETerms.AddPhrases.locComment.localized.0
|
||||
case .theAssociates:
|
||||
lblAddPhraseTag1 = UITerms.AddPhrases.locInitial.localized.0
|
||||
lblAddPhraseTag1 = PETerms.AddPhrases.locInitial.localized.0
|
||||
lblAddPhraseTag2 = {
|
||||
let result = UITerms.AddPhrases.locPhrase.localized.0
|
||||
let result = PETerms.AddPhrases.locPhrase.localized.0
|
||||
return (result == "Phrase") ? "Phrases" : result
|
||||
}()
|
||||
lblAddPhraseTag3 = ""
|
||||
lblAddPhraseTag4 = ""
|
||||
case .theSymbols:
|
||||
lblAddPhraseTag1 = UITerms.AddPhrases.locPhrase.localized.0
|
||||
lblAddPhraseTag2 = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
lblAddPhraseTag1 = PETerms.AddPhrases.locPhrase.localized.0
|
||||
lblAddPhraseTag2 = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
lblAddPhraseTag3 = ""
|
||||
lblAddPhraseTag4 = UITerms.AddPhrases.locComment.localized.0
|
||||
lblAddPhraseTag4 = PETerms.AddPhrases.locComment.localized.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,9 +269,9 @@ public struct VwrPhraseEditorUI: View {
|
|||
guard let weightVal = Double(txtAddPhraseField3) else { return }
|
||||
if weightVal > 0 { txtAddPhraseField3 = "" }
|
||||
}
|
||||
)
|
||||
).help(PETerms.TooltipTexts.weightInputBox.localized)
|
||||
}
|
||||
Button(UITerms.AddPhrases.locAdd.localized.0) {
|
||||
Button(PETerms.AddPhrases.locAdd.localized.0) {
|
||||
DispatchQueue.main.async { insertEntry() }
|
||||
}.disabled(txtAddPhraseField1.isEmpty || txtAddPhraseField2.isEmpty)
|
||||
}
|
||||
|
@ -314,8 +314,8 @@ extension vChewingLM.ReplacableUserDataType {
|
|||
public var localizedDescription: String { NSLocalizedString(rawValue, comment: "") }
|
||||
}
|
||||
|
||||
private enum UITerms {
|
||||
fileprivate enum AddPhrases: String {
|
||||
public enum PETerms {
|
||||
public enum AddPhrases: String {
|
||||
case locPhrase = "Phrase"
|
||||
case locReadingOrStroke = "Reading/Stroke"
|
||||
case locWeight = "Weight"
|
||||
|
@ -324,7 +324,7 @@ private enum UITerms {
|
|||
case locAdd = "Add"
|
||||
case locInitial = "Initial"
|
||||
|
||||
var localized: (String, String) {
|
||||
public var localized: (String, String) {
|
||||
if self == .locAdd {
|
||||
return loc.contains("zh") ? ("添入", "") : loc.contains("ja") ? ("記入", "") : ("Add", "")
|
||||
}
|
||||
|
@ -335,4 +335,11 @@ private enum UITerms {
|
|||
return (val1, val2)
|
||||
}
|
||||
}
|
||||
|
||||
public enum TooltipTexts: String {
|
||||
case weightInputBox =
|
||||
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result."
|
||||
|
||||
public var localized: String { rawValue.localized }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,24 +62,24 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
|
|||
clearAllFields()
|
||||
switch selUserDataType {
|
||||
case .thePhrases:
|
||||
txtPEField1.placeholderString = UITerms.AddPhrases.locPhrase.localized.0
|
||||
txtPEField2.placeholderString = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
txtPEField3.placeholderString = UITerms.AddPhrases.locWeight.localized.0
|
||||
txtPECommentField.placeholderString = UITerms.AddPhrases.locComment.localized.0
|
||||
txtPEField1.placeholderString = PETerms.AddPhrases.locPhrase.localized.0
|
||||
txtPEField2.placeholderString = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
txtPEField3.placeholderString = PETerms.AddPhrases.locWeight.localized.0
|
||||
txtPECommentField.placeholderString = PETerms.AddPhrases.locComment.localized.0
|
||||
case .theFilter:
|
||||
txtPEField1.placeholderString = UITerms.AddPhrases.locPhrase.localized.0
|
||||
txtPEField2.placeholderString = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
txtPEField1.placeholderString = PETerms.AddPhrases.locPhrase.localized.0
|
||||
txtPEField2.placeholderString = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
txtPEField3.placeholderString = ""
|
||||
txtPECommentField.placeholderString = UITerms.AddPhrases.locComment.localized.0
|
||||
txtPECommentField.placeholderString = PETerms.AddPhrases.locComment.localized.0
|
||||
case .theReplacements:
|
||||
txtPEField1.placeholderString = UITerms.AddPhrases.locReplaceTo.localized.0
|
||||
txtPEField2.placeholderString = UITerms.AddPhrases.locReplaceTo.localized.1
|
||||
txtPEField1.placeholderString = PETerms.AddPhrases.locReplaceTo.localized.0
|
||||
txtPEField2.placeholderString = PETerms.AddPhrases.locReplaceTo.localized.1
|
||||
txtPEField3.placeholderString = ""
|
||||
txtPECommentField.placeholderString = UITerms.AddPhrases.locComment.localized.0
|
||||
txtPECommentField.placeholderString = PETerms.AddPhrases.locComment.localized.0
|
||||
case .theAssociates:
|
||||
txtPEField1.placeholderString = UITerms.AddPhrases.locInitial.localized.0
|
||||
txtPEField1.placeholderString = PETerms.AddPhrases.locInitial.localized.0
|
||||
txtPEField2.placeholderString = {
|
||||
let result = UITerms.AddPhrases.locPhrase.localized.0
|
||||
let result = PETerms.AddPhrases.locPhrase.localized.0
|
||||
return (result == "Phrase") ? "Phrases" : result
|
||||
}()
|
||||
txtPEField3.placeholderString = ""
|
||||
|
@ -87,10 +87,10 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
|
|||
"Inline comments are not supported in associated phrases.", comment: ""
|
||||
)
|
||||
case .theSymbols:
|
||||
txtPEField1.placeholderString = UITerms.AddPhrases.locPhrase.localized.0
|
||||
txtPEField2.placeholderString = UITerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
txtPEField1.placeholderString = PETerms.AddPhrases.locPhrase.localized.0
|
||||
txtPEField2.placeholderString = PETerms.AddPhrases.locReadingOrStroke.localized.0
|
||||
txtPEField3.placeholderString = ""
|
||||
txtPECommentField.placeholderString = UITerms.AddPhrases.locComment.localized.0
|
||||
txtPECommentField.placeholderString = PETerms.AddPhrases.locComment.localized.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
|
|||
btnPEReload.title = NSLocalizedString("Reload", comment: "")
|
||||
btnPEConsolidate.title = NSLocalizedString("Consolidate", comment: "")
|
||||
btnPESave.title = NSLocalizedString("Save", comment: "")
|
||||
btnPEAdd.title = UITerms.AddPhrases.locAdd.localized.0
|
||||
btnPEAdd.title = PETerms.AddPhrases.locAdd.localized.0
|
||||
btnPEOpenExternally.title = NSLocalizedString("...", comment: "")
|
||||
|
||||
// Text Editor View
|
||||
|
@ -155,6 +155,9 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
|
|||
txtPEField2.delegate = self
|
||||
txtPEField3.delegate = self
|
||||
|
||||
// Tooltip.
|
||||
txtPEField3.toolTip = PETerms.TooltipTexts.weightInputBox.localized
|
||||
|
||||
// Finally, update the entire editor UI.
|
||||
updatePhraseEditor()
|
||||
}
|
||||
|
@ -225,30 +228,6 @@ extension CtlPrefWindow: NSTextViewDelegate, NSTextFieldDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
private enum UITerms {
|
||||
fileprivate enum AddPhrases: String {
|
||||
case locPhrase = "Phrase"
|
||||
case locReadingOrStroke = "Reading/Stroke"
|
||||
case locWeight = "Weight"
|
||||
case locComment = "Comment"
|
||||
case locReplaceTo = "Replace to"
|
||||
case locAdd = "Add"
|
||||
case locInitial = "Initial"
|
||||
|
||||
var localized: (String, String) {
|
||||
if self == .locAdd {
|
||||
let loc = PrefMgr.shared.appleLanguages[0]
|
||||
return loc.contains("zh") ? ("添入", "") : loc.contains("ja") ? ("記入", "") : ("Add", "")
|
||||
}
|
||||
let rawArray = NSLocalizedString(self.rawValue, comment: "").components(separatedBy: " ")
|
||||
if rawArray.isEmpty { return ("N/A", "N/A") }
|
||||
let val1: String = rawArray[0]
|
||||
let val2: String = (rawArray.count >= 2) ? rawArray[1] : ""
|
||||
return (val1, val2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension NSTextField {
|
||||
fileprivate var isEmpty: Bool { stringValue.isEmpty }
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"Loading…" = "Loading…";
|
||||
"Consolidate" = "Consolidate";
|
||||
"Reload" = "Reload";
|
||||
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result.";
|
||||
"Factory dictionary not loaded yet." = "Factory dictionary not loaded yet.";
|
||||
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations.";
|
||||
"This editor only: Auto-reload modifications happened outside of this editor" = "This editor only: Auto-reload modifications happened outside of this editor";
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"Loading…" = "Loading…";
|
||||
"Consolidate" = "Consolidate";
|
||||
"Reload" = "Reload";
|
||||
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result.";
|
||||
"Factory dictionary not loaded yet." = "Factory dictionary not loaded yet.";
|
||||
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations.";
|
||||
"This editor only: Auto-reload modifications happened outside of this editor" = "This editor only: Auto-reload modifications happened outside of this editor";
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"Loading…" = "読み込む中…";
|
||||
"Consolidate" = "整理";
|
||||
"Reload" = "再読込";
|
||||
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "優先度を記入しなかった場合、最高値「0」はデフォルト値です。理想な優先度の範囲は [-9.5, 0] 以内で、ウォーキング算法に捕まれられます。例外は懲戒値「-114.514」で、優先度を最低に極めた値であり、唯一結果のない場合、ウォーキング算法に無視されます。";
|
||||
"Factory dictionary not loaded yet." = "内蔵辞書はまだ読込中。";
|
||||
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "システム API 制限のため、一部の機能は macOS 10.15 と macOS 11 で提供できません。";
|
||||
"This editor only: Auto-reload modifications happened outside of this editor" = "このエディターの外部からの編集結果をこのエディターに自動的に読み込む";
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"Loading…" = "正在载入…";
|
||||
"Consolidate" = "整理";
|
||||
"Reload" = "重新载入";
|
||||
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填写权重的话,预设权重为最高值「0」。理想的权重范围在 [-9.5, 0] 这个闭区间内,可以被爬轨引擎自动抓到。例外就是惩戒权重「-114.514」,属于极端降权。这种情况下,除非是唯一结果,否则会被爬轨引擎无视。";
|
||||
"Factory dictionary not loaded yet." = "原厂辞典尚未完成载入。";
|
||||
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "因系统 API 限制,个别功能无法对 macOS 10.15 和 macOS 11 提供。";
|
||||
"This editor only: Auto-reload modifications happened outside of this editor" = "仅限该编辑器:自动读入来自该编辑器外部的档案内容修改";
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"Loading…" = "正在載入…";
|
||||
"Consolidate" = "整理";
|
||||
"Reload" = "重新載入";
|
||||
"If not filling the weight, it will be 0.0, the maximum one. An ideal weight situates in [-9.5, 0], making itself can be captured by the walking algorithm. The exception is -114.514, the disciplinary weight. The walking algorithm will ignore it unless it is the unique result." = "不填寫權重的話,預設權重為最高值「0」。理想的權重範圍在 [-9.5, 0] 這個閉區間內,可以被爬軌引擎自動抓到。例外就是懲戒權重「-114.514」,屬於極端降權。這種情況下,除非是唯一結果,否則會被爬軌引擎無視。";
|
||||
"Factory dictionary not loaded yet." = "原廠辭典尚未完成載入。";
|
||||
"Some features are unavailable for macOS 10.15 and macOS 11 due to API limitations." = "因系統 API 限制,個別功能無法對 macOS 10.15 和 macOS 11 提供。";
|
||||
"This editor only: Auto-reload modifications happened outside of this editor" = "僅限該編輯器:自動讀入來自該編輯器外部的檔案內容修改";
|
||||
|
|
Loading…
Reference in New Issue