diff --git a/Keyboards/LanguageKeyboards/Hebrew/HEInterfaceVariables.swift b/Keyboards/LanguageKeyboards/Hebrew/HEInterfaceVariables.swift index 2766750e..2dd74d02 100644 --- a/Keyboards/LanguageKeyboards/Hebrew/HEInterfaceVariables.swift +++ b/Keyboards/LanguageKeyboards/Hebrew/HEInterfaceVariables.swift @@ -17,16 +17,11 @@ * along with this program. If not, see . */ -// HEInterfaceVariablesTemp.swift -// Scribe - import UIKit public enum HebrewKeyboardConstants { static let defaultCurrencyKey = "₪" static let currencyKeys = ["₪", "€", "£", "$"] - - } struct HebrewKeyboardProvider: KeyboardProviderProtocol { @@ -36,7 +31,7 @@ struct HebrewKeyboardProvider: KeyboardProviderProtocol { .addRow(["פ", "ם", "ן", "ו", "ט", "א", "ר", "ק", "delete"]) .addRow(["ף", "ך", "ל", "ח", "י", "ע", "כ", "ג", "ד", "ש"]) .addRow(["ץ", "ת", "צ", "מ", "נ", "ה", "ב", "ס", "ז"]) - .addRow(["123", "selectKeyboard", "רווח", "הכנס"]) + .addRow(["123", "selectKeyboard", "space", "return"]) .build() } @@ -45,7 +40,7 @@ struct HebrewKeyboardProvider: KeyboardProviderProtocol { .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]) .addRow(["-", "/", ":", ";", "(", ")", "$", "&", "@", "\""]) .addRow(["#+=", ".", ",", "?", "!", "'", "delete"]) - .addRow(["אבג", "selectKeyboard", "רווח", "הכנס"]) + .addRow(["אבג", "selectKeyboard", "space", "return"]) .replaceKey(row: 1, column: 6, to: currencyKey) .build() } @@ -55,7 +50,7 @@ struct HebrewKeyboardProvider: KeyboardProviderProtocol { .addRow(["[", "]", "{", "}", "#", "%", "^", "*", "+", "="]) .addRow(["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "·"]) .addRow(["123", ".", ",", "?", "!", "'", "delete"]) - .addRow(["אבג", "selectKeyboard", "רווח", "הכנס"]) + .addRow(["אבג", "selectKeyboard", "space", "return"]) if currencyKeys.count < 3 { return keyboardBuilder.build() @@ -67,80 +62,78 @@ struct HebrewKeyboardProvider: KeyboardProviderProtocol { .build() } } - + // iPad keyboard layouts. - static func genPadLetterKeys() -> [[String]] { - return KeyboardBuilder() - .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "+"]) - .addRow([",", ".", "פ", "ם", "ן", "ו", "ט", "א", "ר", "ק", "delete"]) - .addRow(["ף", "ך", "ל", "ח", "י", "ע", "כ", "ג", "ד", "ש"]) - .addRow(["ץ", "ת", "צ", "מ", "נ", "ה", "ב", "ס", "ז", "הכנס"]) - .addRow(["selectKeyboard", ".?123", "רווח", ".?123", "hideKeyboard"]) - .build() - } - - static func genPadNumberKeys(currencyKey: String) -> [[String]] { - return KeyboardBuilder() - .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"]) - .addRow(["!", "@", "#", "&", "_", "-", "'", "\"", "(", ")", "הכנס"]) - .addRow(["#+=", "%", "...", "&", ";", ":", "=", "+", "/", "?", "#+="]) - .addRow(["selectKeyboard", "אבג", "רווח", "אבג", "hideKeyboard"]) - // .replaceKey(row: 1, column: 4, to: currencyKey) - .build() - } - - static func genPadSymbolKeys(currencyKeys: [String]) -> [[String]] { - let keyboardBuilder = KeyboardBuilder() - .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "delete"]) - .addRow(["^", "€", "$", "£", "[", "]", "'", "\"", "<", ">", "הכנס"]) - .addRow(["123", "§", "|", "~", "*", "·", "{", "}", "\\", "~", "123"]) - .addRow(["selectKeyboard", "אבג", "רווח", "אבג", "hideKeyboard"]) - - if currencyKeys.count < 3 { - return keyboardBuilder.build() - } else { - return keyboardBuilder - .replaceKey(row: 1, column: 1, to: currencyKeys[0]) - .replaceKey(row: 1, column: 2, to: currencyKeys[1]) - .replaceKey(row: 1, column: 3, to: currencyKeys[2]) - .build() - } - } - - // Expanded iPad keyboard layouts for wider devices. - static func genPadExpandedLetterKeys() -> [[String]] { - return KeyboardBuilder() - .addRow(["§", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "delete"]) - .addRow([SpecialKeys.indent, "/", "'", "פ", "ם", "ן", "ו", "ט", "א", "ר", "ק", "[", "]", "+"]) - .addRow([SpecialKeys.capsLock, "ף", "ך", "ל", "ח", "י", "ע", "כ", "ג", "ד", "ש", ",", "\"", "הכנס"]) - .addRow(["⇧", ";", "ץ", "ת", "צ", "מ", "נ", "ה", "ב", "ס", "ז", ".", "⇧"]) - .addRow(["selectKeyboard", ".?123", "רווח", ".?123", "hideKeyboard"]) - .build() - } + static func genPadLetterKeys() -> [[String]] { + return KeyboardBuilder() + .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "+"]) + .addRow([",", ".", "פ", "ם", "ן", "ו", "ט", "א", "ר", "ק", "delete"]) + .addRow(["ף", "ך", "ל", "ח", "י", "ע", "כ", "ג", "ד", "ש"]) + .addRow(["ץ", "ת", "צ", "מ", "נ", "ה", "ב", "ס", "ז", "return"]) + .addRow(["selectKeyboard", ".?123", "space", ".?123", "hideKeyboard"]) + .build() + } - static func genPadExpandedSymbolKeys() -> [[String]] { - return KeyboardBuilder() - .addRow(["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"]) - .addRow([SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "—"]) - .addRow([SpecialKeys.capsLock, "°", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "€", "הכנס"]) - .addRow(["⇧", "…", "?", "!", "~", "≠", "'", "\"", "_", ",", ".", "-", "⇧"]) - .addRow(["selectKeyboard", "אבג", "רווח", "אבג", "hideKeyboard"]) + static func genPadNumberKeys(currencyKey: String) -> [[String]] { + return KeyboardBuilder() + .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "delete"]) + .addRow(["!", "@", "#", "&", "_", "-", "'", "\"", "(", ")", "return"]) + .addRow(["#+=", "%", "...", "&", ";", ":", "=", "+", "/", "?", "#+="]) + .addRow(["selectKeyboard", "אבג", "space", "אבג", "hideKeyboard"]) + // .replaceKey(row: 1, column: 4, to: currencyKey) + .build() + } + + static func genPadSymbolKeys(currencyKeys: [String]) -> [[String]] { + let keyboardBuilder = KeyboardBuilder() + .addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "*", "delete"]) + .addRow(["^", "€", "$", "£", "[", "]", "'", "\"", "<", ">", "return"]) + .addRow(["123", "§", "|", "~", "*", "·", "{", "}", "\\", "~", "123"]) + .addRow(["selectKeyboard", "אבג", "space", "אבג", "hideKeyboard"]) + + if currencyKeys.count < 3 { + return keyboardBuilder.build() + } else { + return keyboardBuilder + .replaceKey(row: 1, column: 1, to: currencyKeys[0]) + .replaceKey(row: 1, column: 2, to: currencyKeys[1]) + .replaceKey(row: 1, column: 3, to: currencyKeys[2]) .build() } } -/// Gets the keys for the Hebrew keyboard. + // Expanded iPad keyboard layouts for wider devices. + static func genPadExpandedLetterKeys() -> [[String]] { + return KeyboardBuilder() + .addRow(["§", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "-", "=", "delete"]) + .addRow([SpecialKeys.indent, "/", "'", "פ", "ם", "ן", "ו", "ט", "א", "ר", "ק", "[", "]", "+"]) + .addRow([SpecialKeys.capsLock, "ף", "ך", "ל", "ח", "י", "ע", "כ", "ג", "ד", "ש", ",", "\"", "return"]) + .addRow(["⇧", ";", "ץ", "ת", "צ", "מ", "נ", "ה", "ב", "ס", "ז", ".", "⇧"]) + .addRow(["selectKeyboard", ".?123", "space", ".?123", "hideKeyboard"]) + .build() + } + static func genPadExpandedSymbolKeys() -> [[String]] { + return KeyboardBuilder() + .addRow(["`", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "<", ">", "delete"]) + .addRow([SpecialKeys.indent, "[", "]", "{", "}", "#", "%", "^", "*", "+", "=", "\"", "|", "—"]) + .addRow([SpecialKeys.capsLock, "°", "/", ":", ";", "(", ")", "$", "&", "@", "£", "¥", "€", "return"]) + .addRow(["⇧", "…", "?", "!", "~", "≠", "'", "\"", "_", ",", ".", "-", "⇧"]) + .addRow(["selectKeyboard", "אבג", "space", "אבג", "hideKeyboard"]) + .build() + } +} +/// Gets the keys for the Hebrew keyboard. func getHEKeys() { guard let userDefaults = UserDefaults(suiteName: "group.be.scri.userDefaultsContainer") else { fatalError() } - + var currencyKey = HebrewKeyboardConstants.defaultCurrencyKey var currencyKeys = HebrewKeyboardConstants.currencyKeys let dictionaryKey = controllerLanguage + "defaultCurrencySymbol" - + if let currencyValue = userDefaults.string(forKey: dictionaryKey) { currencyKey = currencyValue } else { @@ -149,13 +142,13 @@ func getHEKeys() { if let index = currencyKeys.firstIndex(of: currencyKey) { currencyKeys.remove(at: index) } - + if DeviceType.isPhone { letterKeys = HebrewKeyboardProvider.genPhoneLetterKeys() numberKeys = HebrewKeyboardProvider.genPhoneNumberKeys(currencyKey: currencyKey) symbolKeys = HebrewKeyboardProvider.genPhoneSymbolKeys(currencyKeys: currencyKeys) allKeys = Array(letterKeys.joined()) + Array(numberKeys.joined()) + Array(symbolKeys.joined()) - + leftKeyChars = ["ק", "1", "-", "[", "_"] rightKeyChars = ["פ", "0", "\"", "=", "·"] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } @@ -164,25 +157,24 @@ func getHEKeys() { if usingExpandedKeyboard { letterKeys = HebrewKeyboardProvider.genPadExpandedLetterKeys() symbolKeys = HebrewKeyboardProvider.genPadExpandedSymbolKeys() - + allKeys = Array(letterKeys.joined()) + Array(symbolKeys.joined()) } else { letterKeys = HebrewKeyboardProvider.genPadLetterKeys() numberKeys = HebrewKeyboardProvider.genPadNumberKeys(currencyKey: currencyKey) symbolKeys = HebrewKeyboardProvider.genPadSymbolKeys(currencyKeys: currencyKeys) - + letterKeys.removeFirst(1) - + allKeys = Array(letterKeys.joined()) + Array(numberKeys.joined()) + Array(symbolKeys.joined()) } - + leftKeyChars = ["1", "ק"] - rightKeyChars = ["הכנס", "hideKeyboard"] + rightKeyChars = [] centralKeyChars = allKeys.filter { !leftKeyChars.contains($0) && !rightKeyChars.contains($0) } } } - func setHEKeyboardLayout() { getHEKeys() @@ -194,31 +186,28 @@ func setHEKeyboardLayout() { baseAutosuggestions = ["אתמ", "אני", "היי"] numericAutosuggestions = ["", "", ""] - translateKeyLbl = "Translate" - translatePlaceholder = "Translate" + translateKeyLbl = "לְתַרְגֵם" + translatePlaceholder = "לְתַרְגֵם" translatePrompt = commandPromptSpacing + "he -› \(getControllerLanguageAbbr()): " translatePromptAndCursor = translatePrompt + commandCursor translatePromptAndPlaceholder = translatePromptAndCursor + " " + translatePlaceholder translatePromptAndColorPlaceholder = NSMutableAttributedString(string: translatePromptAndPlaceholder) translatePromptAndColorPlaceholder.setColorForText(textForAttribute: translatePlaceholder, withColor: UIColor(cgColor: commandBarPlaceholderColorCG)) - conjugateKeyLbl = "Conjugate" - conjugatePlaceholder = "Conjugate" - conjugatePrompt = commandPromptSpacing + "Conjucation: " + conjugateKeyLbl = "לְהַטוֹת" + conjugatePlaceholder = "לְהַטוֹת" + conjugatePrompt = commandPromptSpacing + " :נְטִיָה" conjugatePromptAndCursor = conjugatePrompt + commandCursor conjugatePromptAndPlaceholder = conjugatePromptAndCursor + " " + conjugatePlaceholder conjugatePromptAndColorPlaceholder = NSMutableAttributedString(string: conjugatePromptAndPlaceholder) conjugatePromptAndColorPlaceholder.setColorForText(textForAttribute: conjugatePlaceholder, withColor: UIColor(cgColor: commandBarPlaceholderColorCG)) - pluralKeyLbl = "Plural" - pluralPlaceholder = "Plural" - pluralPrompt = commandPromptSpacing + "Plural: " + pluralKeyLbl = "רַבִּים" + pluralPlaceholder = "רַבִּים" + pluralPrompt = commandPromptSpacing + " :רַבִּים" pluralPromptAndCursor = pluralPrompt + commandCursor pluralPromptAndPlaceholder = pluralPromptAndCursor + " " + pluralPlaceholder pluralPromptAndColorPlaceholder = NSMutableAttributedString(string: pluralPromptAndPlaceholder) pluralPromptAndColorPlaceholder.setColorForText(textForAttribute: pluralPlaceholder, withColor: UIColor(cgColor: commandBarPlaceholderColorCG)) - alreadyPluralMsg = "Already in plural form" + alreadyPluralMsg = "כבר בצורת רבים" } - - -// Created by Daniel Geva on 2024/08/30.