Skip to content

Commit

Permalink
#67 #68 Add baseline French and Portuguese keyboards without commands
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Dec 4, 2021
1 parent 3d3dcd5 commit f746b0b
Show file tree
Hide file tree
Showing 8 changed files with 457 additions and 15 deletions.
2 changes: 2 additions & 0 deletions Keyboards/KeyboardsBase/CommandVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ var tenseFPP: String = ""
var tenseSPP: String = ""
var tenseTPP: String = ""

let languagesWithCapitalizedNouns = ["German"]

var verbToConjugate: String = ""
var verbConjugated: String = ""

Expand Down
2 changes: 1 addition & 1 deletion Keyboards/KeyboardsBase/InterfaceVariables.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public enum FrenchKeyboardConstants {
]

static let symbolKeysPad = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "delete"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"],
["~", "", "[", "]", "{", "}", "^", "$", "£", "¥", "return"],
["123", "§", "<", ">", "|", "\\", "...", "·", "?", "'", "123"],
["ABC", "selectKeyboard", "space", "ABC", "hideKeyboard"] // "undoArrow"
Expand Down
43 changes: 37 additions & 6 deletions Keyboards/KeyboardsBase/KeyboardViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ class KeyboardViewController: UIInputViewController {

/// Sets the keyboard layouts given the chosen keyboard and device type.
func setKeyboardLayouts() {
if controllerLanguage == "German" {
if controllerLanguage == "French" {
if DeviceType.isPhone {
letterKeys = FrenchKeyboardConstants.letterKeysPhone
numberKeys = FrenchKeyboardConstants.numberKeysPhone
symbolKeys = FrenchKeyboardConstants.symbolKeysPhone
} else {
letterKeys = FrenchKeyboardConstants.letterKeysPad
numberKeys = FrenchKeyboardConstants.numberKeysPad
symbolKeys = FrenchKeyboardConstants.symbolKeysPad
}
} else if controllerLanguage == "German" {
if DeviceType.isPhone {
letterKeys = GermanKeyboardConstants.letterKeysPhone
numberKeys = GermanKeyboardConstants.numberKeysPhone
Expand All @@ -42,6 +52,16 @@ class KeyboardViewController: UIInputViewController {
numberKeys = GermanKeyboardConstants.numberKeysPad
symbolKeys = GermanKeyboardConstants.symbolKeysPad
}
} else if controllerLanguage == "Portuguese" {
if DeviceType.isPhone {
letterKeys = PortugueseKeyboardConstants.letterKeysPhone
numberKeys = PortugueseKeyboardConstants.numberKeysPhone
symbolKeys = PortugueseKeyboardConstants.symbolKeysPhone
} else {
letterKeys = PortugueseKeyboardConstants.letterKeysPad
numberKeys = PortugueseKeyboardConstants.numberKeysPad
symbolKeys = PortugueseKeyboardConstants.symbolKeysPad
}
} else if controllerLanguage == "Russian" {
if DeviceType.isPhone {
letterKeys = RussianKeyboardConstants.letterKeysPhone
Expand Down Expand Up @@ -739,7 +759,16 @@ class KeyboardViewController: UIInputViewController {
addPadding(to: stackView3, width: buttonWidth / 3, key: "y")
}
if DeviceType.isPhone && key == "a" && controllerLanguage == "Portuguese" {
addPadding(to: stackView3, width: buttonWidth / 3, key: "a")
addPadding(to: stackView2, width: buttonWidth / 4, key: "a")
}
if DeviceType.isPad && key == "a" && controllerLanguage == "Portuguese" {
addPadding(to: stackView2, width: buttonWidth / 3, key: "a")
}
if DeviceType.isPad && key == "@" && controllerLanguage == "Portuguese" {
addPadding(to: stackView2, width: buttonWidth / 3, key: "@")
}
if DeviceType.isPad && key == "" && controllerLanguage == "Portuguese" {
addPadding(to: stackView2, width: buttonWidth / 3, key: "")
}

keys.append(btn)
Expand Down Expand Up @@ -793,7 +822,7 @@ class KeyboardViewController: UIInputViewController {
addPadding(to: stackView3, width: buttonWidth / 3, key: "m")
}
if DeviceType.isPhone && key == "l" && controllerLanguage == "Portuguese" {
addPadding(to: stackView3, width: buttonWidth / 3, key: "l")
addPadding(to: stackView2, width: buttonWidth / 4, key: "l")
}

// specialKey styling.
Expand Down Expand Up @@ -831,6 +860,8 @@ class KeyboardViewController: UIInputViewController {
btn.widthAnchor.constraint(equalToConstant: numSymButtonWidth * 2).isActive = true
} else if controllerLanguage == "Russian" && row == 2 && DeviceType.isPhone {
btn.widthAnchor.constraint(equalToConstant: numSymButtonWidth * 1.5).isActive = true
} else if key == "return" && controllerLanguage == "Portuguese" && row == 1 && DeviceType.isPad {
btn.widthAnchor.constraint(equalToConstant: numSymButtonWidth * 1.5).isActive = true
} else {
btn.widthAnchor.constraint(equalToConstant: numSymButtonWidth * 1).isActive = true
}
Expand Down Expand Up @@ -930,7 +961,7 @@ class KeyboardViewController: UIInputViewController {
var noun = previewBar?.text!.substring(with: pluralPrompt.count..<((previewBar?.text!.count)!-1))
var queriedWordIsUpperCase: Bool = false
// Check to see if the input was uppercase to return an uppercase plural.
if controllerLanguage == "Russian" || controllerLanguage == "Spanish" {
if !languagesWithCapitalizedNouns.contains(controllerLanguage) {
let firstLetter = noun?.substring(toIdx: 1)
queriedWordIsUpperCase = firstLetter!.isUppercase
noun = noun?.lowercased()
Expand Down Expand Up @@ -960,7 +991,7 @@ class KeyboardViewController: UIInputViewController {
var selectedWord = proxy.selectedText
// Check to see if the input was uppercase to return an uppercase plural.
var queriedWordIsUpperCase: Bool = false
if controllerLanguage == "Russian" || controllerLanguage == "Spanish" {
if !languagesWithCapitalizedNouns.contains(controllerLanguage) {
let firstLetter = selectedWord?.substring(toIdx: 1)
queriedWordIsUpperCase = firstLetter!.isUppercase
selectedWord = selectedWord?.lowercased()
Expand Down Expand Up @@ -1018,7 +1049,7 @@ class KeyboardViewController: UIInputViewController {
if lastWordTyped != "" {
// Check to see if the input was uppercase to return an uppercase plural.
var queriedWordIsUpperCase: Bool = false
if controllerLanguage == "Russian" || controllerLanguage == "Spanish" {
if !languagesWithCapitalizedNouns.contains(controllerLanguage) {
let firstLetter = lastWordTyped?.substring(toIdx: 1)
queriedWordIsUpperCase = firstLetter!.isUppercase
lastWordTyped = lastWordTyped?.lowercased()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// FrenchKeyboardViewController.swift
//

class FrenchKeyboardViewController: KeyboardViewController {}
42 changes: 42 additions & 0 deletions Keyboards/LanguageKeyboards/French/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Français</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Français</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IsASCIICapable</key>
<false/>
<key>PrefersRightToLeft</key>
<false/>
<key>PrimaryLanguage</key>
<string>fr</string>
<key>RequestsOpenAccess</key>
<false/>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.keyboard-service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).KeyboardViewController</string>
</dict>
</dict>
</plist>
42 changes: 42 additions & 0 deletions Keyboards/LanguageKeyboards/Portuguese/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Português</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Português</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>IsASCIICapable</key>
<false/>
<key>PrefersRightToLeft</key>
<false/>
<key>PrimaryLanguage</key>
<string>pt</string>
<key>RequestsOpenAccess</key>
<false/>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.keyboard-service</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).KeyboardViewController</string>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// PortugueseKeyboardViewController.swift
//

class PortugueseKeyboardViewController: KeyboardViewController {}
Loading

0 comments on commit f746b0b

Please sign in to comment.