Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back English keyboard #484

Merged
merged 19 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
78cb944
Add back English keyboard
Jag-Marcel Aug 2, 2024
ec6d25e
Merge branch 'main' into add-back-english-keyboard
Jag-Marcel Aug 3, 2024
4f8634b
Updates to EN keyboard files
Jag-Marcel Aug 3, 2024
90d3eab
Update branch with English language DB - WIP no emojis
andrewtavis Aug 10, 2024
2062ae0
Fix merge conflict on branch
andrewtavis Aug 10, 2024
3e568ff
Merge branch 'main' into add-back-english-keyboard
andrewtavis Aug 10, 2024
13a6f60
Update all emoji data and include English as well
andrewtavis Aug 12, 2024
da5d357
Merge branch 'main' into add-back-english-keyboard
Jag-Marcel Aug 13, 2024
f81606d
Merged changes from 'main' along with fixes to sqlite tables
Jag-Marcel Aug 13, 2024
3c58551
Merge branch 'add-back-english-keyboard' of https://github.com/Jag-Ma…
Jag-Marcel Aug 13, 2024
d01b754
Added conjugation functionality to EN keyboard
Jag-Marcel Aug 13, 2024
e75f0eb
Edited translation to signal that it's currently unusable
Jag-Marcel Aug 13, 2024
3907843
Merge branch 'main' into add-back-english-keyboard
andrewtavis Aug 13, 2024
4c8fb19
Add ability for English keyboard defaults to be defined
andrewtavis Aug 14, 2024
26a0caa
Moved location of English.entitlements and fixed emoji suggestions cr…
Jag-Marcel Aug 14, 2024
32cfca5
Added additional forms to English conjugation
Jag-Marcel Aug 14, 2024
3cd757a
Fixed declensions
Jag-Marcel Aug 14, 2024
2619fc2
Updated English conjugation tables
Jag-Marcel Aug 14, 2024
dc554ed
#7 update changelog, fix conjugation table vals, fix plural bug
andrewtavis Aug 15, 2024
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

# [Upcoming] Scribe-iOS 3.2.0

### ⌨️ New Keyboards

- Adds an English keyboard ([#7](https://github.com/scribe-org/Scribe-iOS/issues/7)).

### ✨ New Features

- Scribe commands can now be triggered directly on a selected word by pressing the Scribe key and then choosing which command to use ([#141](https://github.com/scribe-org/Scribe-iOS/issues/141)).
Expand All @@ -31,6 +35,10 @@ Emojis for the following are chosen based on [gitmoji](https://gitmoji.dev/).

- Localization strings for English, German, Swedish and Spanish have been added for all remaining app texts ([Scribe-i18n#28](https://github.com/scribe-org/Scribe-i18n/issues/28)).

### 🐞 Bug Fixes

- The plural command now reacts to the capitalization of the input word when a word that's already plural is entered.

# Scribe-iOS 3.1.0

### ✨ New Features
Expand Down
2 changes: 1 addition & 1 deletion Keyboards/KeyboardsBase/Extensions.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Extensions for Scribe keyboards.
* Extensions with helper functions for Scribe keyboards.
*
* Copyright (C) 2024 Scribe
*
Expand Down
2 changes: 2 additions & 0 deletions Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var controllerLanguageAbbr = String()

// Dictionary for accessing language abbreviations.
let languagesAbbrDict = [
"English": "en",
"French": "fr",
"German": "de",
"Italian": "it",
Expand Down Expand Up @@ -194,6 +195,7 @@ func getControllerLanguageAbbr() -> String {
// Dictionary for accessing keyboard abbreviations and layouts.
let keyboardLayoutDict: [String: () -> Void] = [
// Layouts for French checked within setFRKeyboardLayout.
"English": setENKeyboardLayout,
"French": setFRKeyboardLayout,
"German": setDEKeyboardLayout,
"Italian": setITKeyboardLayout,
Expand Down
14 changes: 12 additions & 2 deletions Keyboards/KeyboardsBase/KeyboardKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,12 @@ class KeyboardKey: UIButton {
widthAnchor.constraint(equalToConstant: numSymKeyWidth * scalarReturnKeyWidth).isActive = true
} else if ["123", ".?123", "return", "hideKeyboard"].contains(key) {
if key == "return"
&& (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate)
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
)
&& row == 1
&& DeviceType.isPad {
layer.setValue(true, forKey: "isSpecial")
Expand All @@ -303,7 +308,12 @@ class KeyboardKey: UIButton {
widthAnchor.constraint(equalToConstant: numSymKeyWidth * 1).isActive = true
} else if ["123", ".?123", "return", "hideKeyboard"].contains(key) {
if key == "return"
&& (controllerLanguage == "Portuguese" || controllerLanguage == "Italian" || commandState == .translate)
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
)
&& row == 1
&& DeviceType.isPad {
layer.setValue(true, forKey: "isSpecial")
Expand Down
130 changes: 114 additions & 16 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class KeyboardViewController: UIInputViewController {

if prefix.isNumeric {
completionWords = numericAutosuggestions
} else if ["French", "German", "Spanish"].contains(controllerLanguage) && pronounAutosuggestionTenses.keys.contains(prefix.lowercased()) {
} else if ["English", "French", "German", "Spanish"].contains(controllerLanguage) && pronounAutosuggestionTenses.keys.contains(prefix.lowercased()) {
getPronounAutosuggestions()
} else {
// We have to consider these different cases as the key always has to match.
Expand Down Expand Up @@ -1264,6 +1264,15 @@ class KeyboardViewController: UIInputViewController {
.genitiveDefinite, .genitiveIndefinite, .genitiveDemonstrative
].contains(deCaseDeclensionState) {
formsDisplayDimensions = .view2x2
} else if controllerLanguage == "English" {
switch enConjugationState {
case .present, .presCont, .past, .future, .conditional:
formsDisplayDimensions = .view2x2
case .presSimp, .presPerf, .presPerfCont:
formsDisplayDimensions = .view1x2
case .pastCont:
formsDisplayDimensions = .view3x1
}
} else if commandState == .displayInformation {
formsDisplayDimensions = .view1x1
} else {
Expand Down Expand Up @@ -1423,7 +1432,7 @@ class KeyboardViewController: UIInputViewController {
conjugationStateFxn = conjugationFxn
}

if !["Russian", "Swedish"].contains(controllerLanguage) {
if !["English", "Russian", "Swedish"].contains(controllerLanguage) {
formFPS = conjugationStateFxn() + "FPS"
formSPS = conjugationStateFxn() + "SPS"
formTPS = conjugationStateFxn() + "TPS"
Expand Down Expand Up @@ -1451,6 +1460,24 @@ class KeyboardViewController: UIInputViewController {
formTopRight = swedishTenses[1]
formBottomLeft = swedishTenses[2]
formBottomRight = swedishTenses[3]
} else if controllerLanguage == "English" {
if formsDisplayDimensions == .view2x2 {
let englishTenses = enGetConjugationState()

formTopLeft = englishTenses[0]
formTopRight = englishTenses[1]
formBottomLeft = englishTenses[2]
formBottomRight = englishTenses[3]
} else if formsDisplayDimensions == .view1x2 {
let englishTenses = enGetConjugationState()

formLeft = englishTenses[0]
formRight = englishTenses[1]
} else if formsDisplayDimensions == .view3x1 {
formTop = "presPart"
formMiddle = "pastSimpCont"
formBottom = "pastSimpPluralCont"
}
}
}

Expand Down Expand Up @@ -1481,25 +1508,40 @@ class KeyboardViewController: UIInputViewController {
}

// Assign labels that have been set by SetConjugationLabels function.
// Other labels not assigned as they're not used in conjugation at this time.
formLblFPS.setTitle(" " + (formLabelsDict["FPS"] ?? ""), for: .normal)
formLblSPS.setTitle(" " + (formLabelsDict["SPS"] ?? ""), for: .normal)
formLblTPS.setTitle(" " + (formLabelsDict["TPS"] ?? ""), for: .normal)
formLblFPP.setTitle(" " + (formLabelsDict["FPP"] ?? ""), for: .normal)
formLblSPP.setTitle(" " + (formLabelsDict["SPP"] ?? ""), for: .normal)
formLblTPP.setTitle(" " + (formLabelsDict["TPP"] ?? ""), for: .normal)

formLblTop.setTitle(" " + (formLabelsDict["Top"] ?? ""), for: .normal)
formLblMiddle.setTitle(" " + (formLabelsDict["Middle"] ?? ""), for: .normal)
formLblBottom.setTitle(" " + (formLabelsDict["Bottom"] ?? ""), for: .normal)

formLblTL.setTitle(" " + (formLabelsDict["TL"] ?? ""), for: .normal)
formLblTR.setTitle(" " + (formLabelsDict["TR"] ?? ""), for: .normal)
formLblBL.setTitle(" " + (formLabelsDict["BL"] ?? ""), for: .normal)
formLblBR.setTitle(" " + (formLabelsDict["BR"] ?? ""), for: .normal)

if formsDisplayDimensions == .view3x2 {
formLblLeft.setTitle(" " + (formLabelsDict["Left"] ?? ""), for: .normal)
formLblRight.setTitle(" " + (formLabelsDict["Right"] ?? ""), for: .normal)

switch formsDisplayDimensions {
case .view3x2:
allConjugations = [formFPS, formSPS, formTPS, formFPP, formSPP, formTPP]
allConjugationBtns = get3x2FormDisplayButtons()
} else {
case .view3x1:
allConjugations = [formTop, formMiddle, formBottom]
allConjugationBtns = get3x1FormDisplayButtons()
case .view2x2:
allConjugations = [formTopLeft, formTopRight, formBottomLeft, formBottomRight]
allConjugationBtns = get2x2FormDisplayButtons()
case .view1x2:
allConjugations = [formLeft, formRight]
allConjugationBtns = get1x2FormDisplayButtons()
case .view1x1:
break
}

// Populate conjugation view buttons.
Expand All @@ -1511,8 +1553,28 @@ class KeyboardViewController: UIInputViewController {
styleBtn(btn: allConjugationBtns[index], title: invalidCommandMsg, radius: keyCornerRadius)
} else {
conjugationToDisplay = conjugationsToDisplay[index]
if inputWordIsCapitalized && deConjugationState != .indicativePerfect {
conjugationToDisplay = conjugationToDisplay.capitalized
if controllerLanguage == "English" {
if index == 0 && allConjugations[index] == "presTPS" {
let simple = LanguageDBManager.shared.queryVerb(of: verbToConjugate, with: ["presSimp"])
conjugationToDisplay = simple[0] + "/" + conjugationToDisplay
} else if index == 1 && allConjugations[index] == "presPart" {
if enConjugationState == .present {
conjugationToDisplay = "am/are/is " + conjugationToDisplay
} else {
conjugationToDisplay = "was/were " + conjugationToDisplay
}
} else if index == 3 && allConjugations[index] == "presPerfTPS" {
conjugationToDisplay = "have/" + conjugationToDisplay
} else if index == 3 && allConjugations[index] == "presPerfTPSCont" {
conjugationToDisplay = "have/" + conjugationToDisplay
}
}
if inputWordIsCapitalized {
if controllerLanguage == "English", conjugationToDisplay.count(of: " ") > 0 {
conjugationToDisplay = conjugationToDisplay.capitalize()
} else if deConjugationState != .indicativePerfect {
conjugationToDisplay = conjugationToDisplay.capitalized
}
}
styleBtn(btn: allConjugationBtns[index], title: conjugationToDisplay, radius: keyCornerRadius)
}
Expand Down Expand Up @@ -1653,7 +1715,9 @@ class KeyboardViewController: UIInputViewController {
}
if DeviceType.isPhone
&& key == "a"
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
|| (
Expand All @@ -1671,7 +1735,8 @@ class KeyboardViewController: UIInputViewController {
&& key == "a"
&& !usingExpandedKeyboard
&& (
controllerLanguage == "Portuguese"
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
) {
Expand All @@ -1681,7 +1746,9 @@ class KeyboardViewController: UIInputViewController {
if DeviceType.isPad
&& key == "@"
&& !usingExpandedKeyboard
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate) {
leftPadding = keyWidth / 3
Expand All @@ -1690,7 +1757,9 @@ class KeyboardViewController: UIInputViewController {
if DeviceType.isPad
&& key == "€"
&& !usingExpandedKeyboard
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| commandState == .translate) {
leftPadding = keyWidth / 3
addPadding(to: stackView1, width: leftPadding, key: "€")
Expand Down Expand Up @@ -1786,7 +1855,9 @@ class KeyboardViewController: UIInputViewController {
}
if DeviceType.isPhone
&& key == "l"
&& (controllerLanguage == "Portuguese"
&& (
controllerLanguage == "English"
|| controllerLanguage == "Portuguese"
|| controllerLanguage == "Italian"
|| commandState == .translate
|| (
Expand Down Expand Up @@ -2402,19 +2473,46 @@ class KeyboardViewController: UIInputViewController {
loadKeys()

case "formTopLeft":
returnConjugation(keyPressed: sender, requestedForm: formTopLeft)
if controllerLanguage == "English" && enConjugationState == .present {
enConjugationState = .presSimp
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formTopLeft)
}
loadKeys()

case "formTopRight":
returnConjugation(keyPressed: sender, requestedForm: formTopRight)
if controllerLanguage == "English" {
if enConjugationState == .present {
enConjugationState = .presCont
conjViewShiftButtonsState = .bothInactive
} else if enConjugationState == .past {
enConjugationState = .pastCont
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formTopRight)
}
} else {
returnConjugation(keyPressed: sender, requestedForm: formTopRight)
}
loadKeys()

case "formBottomLeft":
returnConjugation(keyPressed: sender, requestedForm: formBottomLeft)
if controllerLanguage == "English" && enConjugationState == .present {
enConjugationState = .presPerf
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formBottomLeft)
}
loadKeys()

case "formBottomRight":
returnConjugation(keyPressed: sender, requestedForm: formBottomRight)
if controllerLanguage == "English" && enConjugationState == .present {
enConjugationState = .presPerfCont
conjViewShiftButtonsState = .bothInactive
} else {
returnConjugation(keyPressed: sender, requestedForm: formBottomRight)
}
loadKeys()

case "formLeft":
Expand Down
4 changes: 2 additions & 2 deletions Keyboards/KeyboardsBase/LanguageDBManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ extension LanguageDBManager {
word = ?
"""
let args = [word]
let outputCols = ["suggestion_0", "suggestion_1", "suggestion_2"]
let outputCols = ["autosuggestion_0", "autosuggestion_1", "autosuggestion_2"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on these! I honestly don't remember when the change for this was made 🤔 Maybe is coming from changes in Scribe-Data's directory structure or something like that :)


return queryDBRow(query: query, outputCols: outputCols, args: StatementArguments(args))
}
Expand All @@ -267,7 +267,7 @@ extension LanguageDBManager {
WHERE
word = ?
"""
let outputCols = ["emoji_0", "emoji_1", "emoji_2"]
let outputCols = ["emoji_keyword_0", "emoji_keyword_1", "emoji_keyword_2"]
let args = [word]

return queryDBRow(query: query, outputCols: outputCols, args: StatementArguments(args))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ var formLabelsDict = [
"SPP": "",
"TPP": "",
"Top": "",
"Bottom": "",
"Middle": "",
"Bottom": "",
"TL": "",
"TR": "",
"BL": "",
Expand Down
Loading