Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,11 @@ class KeyboardViewController: UIInputViewController {
autoCapAtStartOfProxy()

if commandState == .invalid {
commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata
if !didYouMeanWord.isEmpty {
commandBar.text = commandPromptSpacing + "Did you mean: " + didYouMeanWord + "?"
} else {
commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata
}
commandBar.isShowingInfoButton = true
} else {
commandBar.isShowingInfoButton = false
Expand All @@ -2078,6 +2082,7 @@ class KeyboardViewController: UIInputViewController {
}
}
commandBar.textColor = keyCharColor
didYouMeanWord = ""
return
} else if [.translate, .plural].contains(commandState) { // functional commands above
autoActionState = .suggest
Expand All @@ -2096,9 +2101,14 @@ class KeyboardViewController: UIInputViewController {
loadKeys()
proxy.insertText(selectedText)
autoCapAtStartOfProxy()
commandBar.text = commandPromptSpacing + invalidCommandMsgWiktionary
if !didYouMeanWord.isEmpty {
commandBar.text = commandPromptSpacing + "Did you mean: " + didYouMeanWord + "?"
} else {
commandBar.text = commandPromptSpacing + invalidCommandMsgWiktionary
}
commandBar.isShowingInfoButton = true
commandBar.textColor = keyCharColor
didYouMeanWord = ""
return
} else { // functional commands above
autoActionState = .suggest
Expand Down Expand Up @@ -2130,9 +2140,14 @@ class KeyboardViewController: UIInputViewController {
loadKeys()
proxy.insertText(selectedText)
autoCapAtStartOfProxy()
commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata
if !didYouMeanWord.isEmpty {
commandBar.text = commandPromptSpacing + "Did you mean: " + didYouMeanWord + "?"
} else {
commandBar.text = commandPromptSpacing + invalidCommandMsgWikidata
}
commandBar.isShowingInfoButton = true
commandBar.textColor = keyCharColor
didYouMeanWord = ""
return
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var commandPromptSpacing = ""
var inputWordIsCapitalized = false
var wordToReturn = ""
var potentialWordsToReturn = [String]()
var didYouMeanWord = ""

var invalidCommandMsgWikidata = ""
var invalidCommandTextWikidata1 = ""
Expand Down
8 changes: 7 additions & 1 deletion Keyboards/KeyboardsBase/ScribeFunctionality/Conjugate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,11 @@ func isVerbInConjugationTable(queriedVerbToConjugate: String) -> Bool {
let columnName = (controllerLanguage == "Swedish") ? "verb" : "infinitive"
let results = LanguageDBManager.shared.queryVerb(of: verbToConjugate, with: [columnName])

return !results.isEmpty && !results[0].isEmpty
let verbExists = !results.isEmpty && !results[0].isEmpty
if !verbExists {
let suggestions = LanguageDBManager.shared.queryAutocompletions(word: verbToConjugate)
didYouMeanWord = suggestions.first ?? ""
}

return verbExists
}
2 changes: 2 additions & 0 deletions Keyboards/KeyboardsBase/ScribeFunctionality/Translate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ func queryWordToTranslate(queriedWordToTranslate: String) {
wordToReturn = LanguageDBManager.translations.queryTranslation(of: wordToTranslate)[0]
guard !wordToReturn.isEmpty
else {
let suggestions = LanguageDBManager.shared.queryAutocompletions(word: wordToTranslate.lowercased())
didYouMeanWord = suggestions.first ?? ""
commandState = .invalid
return
}
Expand Down
Loading