From 0a376790b0b9d16ecef961714d5cbbae0b670369 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Mon, 21 Aug 2023 12:44:12 +0200 Subject: [PATCH 01/16] Upadte accent keys - use long press - generalize `AccentKeyButton` - rm accent button from french keyboard, not needed as long press is used --- Sources/SimpleKeyboard/Models/Language.swift | 16 +++++-- Sources/SimpleKeyboard/Views/KeyButton.swift | 43 +++++++++++-------- .../SimpleKeyboard/Views/SimpleKeyboard.swift | 2 +- .../Views/SimpleStandardKeyboard.swift | 8 +--- .../SimpleKeyboardTests.swift | 28 ++++++------ 5 files changed, 56 insertions(+), 41 deletions(-) diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index 587d8e2..e271530 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -23,6 +23,16 @@ public enum Language: CaseIterable { case english, german, spanish, french, russian, hindi + var alternateKeys: [String: String] { + switch self { + case .german: return ["a": "ä", "o": "ö", "u": "ü"] + // spanish also has ü + case .spanish: return ["e": "é", "a": "á", "i": "í", "o": "ó", "u": "ú", "n": "ñ"] + case .french: return ["e": "é", "a": "à", "u": "ù", "i": "î", "o": "ô", "c": "ç"] + default: return [:] + } + } + func rows(areUppercased: Bool) -> [[String]] { var result = [[String]]() switch self { @@ -34,14 +44,14 @@ public enum Language: CaseIterable { ] case .german: result = [ - ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"], - ["a", "s", "d", "f", "g", "h", "j", "k", "l"], + ["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"], // "ü"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l"], // "ö", "ä"], ["y", "x", "c", "v", "b", "n", "m"] ] case .spanish: result = [ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"], - ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ñ"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ü"], ["z", "x", "c", "v", "b", "n", "m"] ] case .french: diff --git a/Sources/SimpleKeyboard/Views/KeyButton.swift b/Sources/SimpleKeyboard/Views/KeyButton.swift index a093b86..bbd2951 100644 --- a/Sources/SimpleKeyboard/Views/KeyButton.swift +++ b/Sources/SimpleKeyboard/Views/KeyButton.swift @@ -15,6 +15,7 @@ extension ClickableKey { func didClick() { #if canImport(UIKit) UIDevice.current.playInputClick() + //haptic #endif } } @@ -45,13 +46,11 @@ struct ShiftKeyButton: View { struct KeyButton: View, ClickableKey { @Binding var text: String var letter: String + var alternateLetter: String? @Environment(\.colorScheme) var colorScheme var body: some View { - Button(action: { - self.text.append(self.letter) - didClick() - }) { + Button(action: { }) { Text(letter) .font(.system(size: 25)) .fixedSize() @@ -64,11 +63,23 @@ struct KeyButton: View, ClickableKey { .cornerRadius(5) .shadow(color: .black, radius: 0, y: 1) } + .highPriorityGesture(TapGesture().onEnded({ _ in + self.text.append(self.letter) + didClick() + })) + .simultaneousGesture(LongPressGesture().onEnded({ _ in + guard let alternateLetter else { return } + self.text.append(alternateLetter) + didClick() + })) } } -struct FRAccentKeyButton: View { +/// Replaces the last typed character with another (special) character. E.g. "a" -> "ä" +struct AccentKeyButton: View { @Binding var text: String + /// The lookup for modified characters all lowercased. E.g. `["a": "ä"]` + var modifiedLetters: [Character: String] var body: some View { Button(action: { @@ -88,22 +99,16 @@ struct FRAccentKeyButton: View { } internal func action() { - var modified = "" - let suffix = self.text.popLast() - switch suffix { - case "a": modified = "à" - case "e": modified = "é" - case "i": modified = "î" - case "u": modified = "û" - case "o": modified = "ô" - case "c": modified = "ç" - default: - modified = "’" - if let suffix = suffix { - self.text.append(suffix) - } + guard let suffix = self.text.popLast() else { + return text.append("’") } + guard var modified = modifiedLetters[Character(suffix.lowercased())] else { + return text.append(String(suffix) + "’") + } + if suffix.isUppercase { + modified = modified.uppercased() + } text.append(modified) } } diff --git a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift index a0e1f27..059e799 100644 --- a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift @@ -40,7 +40,7 @@ public struct SimpleKeyboard: View, ThemeableView { } } HStack { - if let actionButton = actionButton { + if let actionButton { ActionKeyButton(icon: actionButton) { self.action?() } diff --git a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift index 99d67d3..cee95f1 100644 --- a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift @@ -63,10 +63,6 @@ public struct SimpleStandardKeyboard: View, ThemeableView { Spacer(minLength: 2) .frame(maxWidth: 15) .layoutPriority(2) - if settings.language == .french { - FRAccentKeyButton(text: $settings.text) - Spacer() - } DeleteKeyButton(text: self.$settings.text) } } else if idx == 1 { @@ -82,7 +78,7 @@ public struct SimpleStandardKeyboard: View, ThemeableView { let rows = self.settings.language.rows(areUppercased: settings.isUpperCase ?? false)[index] return ForEach(rows, id: \.self) { key in Spacer(minLength: settings.language.spacing) - KeyButton(text: self.$settings.text, letter: key) + KeyButton(text: self.$settings.text, letter: key, alternateLetter: settings.language.alternateKeys[key]) Spacer(minLength: settings.language.spacing) } } @@ -120,7 +116,7 @@ struct SimpleStandardKeyboard_Previews: PreviewProvider { isUpperCase: true)) SimpleStandardKeyboard( settings: KeyboardSettings( - language: .english, + language: .spanish, textInput: nil, theme: .system, actionButton: .search, diff --git a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift index 31d22c4..558f0cd 100644 --- a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift +++ b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift @@ -163,17 +163,21 @@ final class SimpleKeyboardTests: XCTestCase { XCTAssertNotNil(SimpleStandardKeyboard_Previews.previews) } - func test_french_accent_key() { - let frButton = FRAccentKeyButton(text: $tester.text) - XCTAssertNotNil(frButton) - - for char in "aeiouc" { - tester.text.append(char) - frButton.action() - let modChar = String(tester.text.suffix(1)) - print(modChar) - XCTAssertNotEqual(modChar, String(char)) - } + func test_accent_key() { + let accButton = AccentKeyButton(text: $tester.text, modifiedLetters: ["a": "à"]) + XCTAssertNotNil(accButton) + + tester.text.append("a") + accButton.action() + let modChar = String(tester.text.suffix(1)) + print(modChar) + XCTAssertEqual(modChar, String("à")) + + tester.text.append("A") + accButton.action() + let modChar2 = String(tester.text.suffix(1)) + print(modChar2) + XCTAssertEqual(modChar2, String("À")) } func test_corner_radius() { @@ -207,7 +211,7 @@ final class SimpleKeyboardTests: XCTestCase { ("standard_keyboard_action_works", test_standard_keyboard_action_works), ("standard_keyboard_works", test_simple_keyboard_works), ("test_keyboard_preview", test_keyboard_preview), - ("test_french_accent_key", test_french_accent_key), + ("test_accent_key", test_accent_key), ("test_corner_radius", test_corner_radius), ("test_theming_modifier", test_theming_modifier) ] From 389744eed9f2f899833810629f9a74b73184c3fa Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Mon, 21 Aug 2023 12:51:21 +0200 Subject: [PATCH 02/16] Add haptic feedback --- Sources/SimpleKeyboard/Views/KeyButton.swift | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Sources/SimpleKeyboard/Views/KeyButton.swift b/Sources/SimpleKeyboard/Views/KeyButton.swift index bbd2951..f6f0148 100644 --- a/Sources/SimpleKeyboard/Views/KeyButton.swift +++ b/Sources/SimpleKeyboard/Views/KeyButton.swift @@ -14,17 +14,18 @@ protocol ClickableKey { extension ClickableKey { func didClick() { #if canImport(UIKit) + let generator = UIImpactFeedbackGenerator(style: .light) + generator.impactOccurred() UIDevice.current.playInputClick() - //haptic #endif } } -struct ShiftKeyButton: View { +struct ShiftKeyButton: View, ClickableKey { @Binding var isUpperCase: Bool! var body: some View { - Button(action: { self.isUpperCase?.toggle() }) { + Button(action: { self.isUpperCase?.toggle(); didClick() }) { if #available(iOS 15, macOS 12, *) { AnyView(Image(systemName: isUpperCase ? "shift.fill" : "shift") .dynamicTypeSize(.large)) @@ -76,7 +77,7 @@ struct KeyButton: View, ClickableKey { } /// Replaces the last typed character with another (special) character. E.g. "a" -> "ä" -struct AccentKeyButton: View { +struct AccentKeyButton: View, ClickableKey { @Binding var text: String /// The lookup for modified characters all lowercased. E.g. `["a": "ä"]` var modifiedLetters: [Character: String] @@ -99,6 +100,7 @@ struct AccentKeyButton: View { } internal func action() { + defer { didClick() } guard let suffix = self.text.popLast() else { return text.append("’") } @@ -141,13 +143,14 @@ struct SpaceKeyButton: View, ClickableKey { } } -struct DeleteKeyButton: View { +struct DeleteKeyButton: View, ClickableKey { @Binding var text: String var body: some View { Button(action: { guard !self.text.isEmpty else { return } _ = self.text.removeLast() + didClick() }) { if #available(iOS 15, macOS 12, *) { AnyView(Image(systemName: "delete.left").dynamicTypeSize(.large)) @@ -170,7 +173,7 @@ struct DeleteKeyButton: View { } } -struct ActionKeyButton: View { +struct ActionKeyButton: View, ClickableKey { @State var icon: Icon var action: () -> Void @@ -183,7 +186,7 @@ struct ActionKeyButton: View { } var body: some View { - Button(action: self.action) { + Button(action: { self.action(); didClick() }) { iconView .padding() .frame(minWidth: 100, maxWidth: .infinity) @@ -205,7 +208,7 @@ public enum Icon { case .search: if #available(iOS 14, macOS 11, *) { return AnyView(Image(systemName: "magnifyingglass")) - }else { + } else { return AnyView(Text("Search", bundle: .module)) } case .go: return AnyView(Text("Go!", bundle: .module)) From 52ffd18bf93004a56bd150bc72d6903ec95e71b9 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Thu, 31 Aug 2023 23:37:20 +0200 Subject: [PATCH 03/16] =?UTF-8?q?[TESING]=C2=A0Add=20fr=20and=20nl=20l18n,?= =?UTF-8?q?=20using=20GPT!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../l10n/fr.lproj/Localizable.strings | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings index 24ae804..e337e7e 100644 --- a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings @@ -1,11 +1,18 @@ -"space" = "espace"; +/* (No Comment) */ +"Done!" = "Terminé!"; + +/* (No Comment) */ +"Go!" = "Aller!"; -"Up" = "Ma"; +/* (No Comment) */ +"lw" = "lw"; -"lw" = "mi"; +/* (No Comment) */ +"Search" = "Rechercher"; -"Done!" = "Fait!"; +/* (No Comment) */ +"space" = "espace"; -"Search" = "Recherche"; +/* (No Comment) */ +"Up" = "Haut"; -"Go!" = "Allez!"; From b99380a154331ec9b22692fea9bcb7b3f73bc236 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Sun, 3 Sep 2023 21:22:38 +0200 Subject: [PATCH 04/16] improve l18n (automated) - squashed --- .../l10n/en.lproj/Localizable.strings | 15 ++++++++------ .../l10n/fr.lproj/Localizable.strings | 20 ++++--------------- .../l10n/hi.lproj/Localizable.strings | 13 ++++-------- .../l10n/nl.lproj/Localizable.strings | 16 +++++++++++++++ .../l10n/ru.lproj/Localizable.strings | 13 ++++-------- 5 files changed, 37 insertions(+), 40 deletions(-) create mode 100644 Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings diff --git a/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings index 35497c4..6e24c21 100644 --- a/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings @@ -1,11 +1,14 @@ -"space" = "space"; +/* spacebar */ +"space" = "अंतरिक्ष"; -"Up" = "Up"; +/* Uppercase abbreviation for button */ +"Up" = "ऊपर"; -"lw" = "lw"; +/* lowercase abbreviation for button */ +"lw" = "लो"; -"Done!" = "Done!"; +"Done!" = "हो गया!"; -"Search" = "Search"; +"Search" = "खोज"; -"Go!" = "Go!"; +"Go!" = "जाओ!"; diff --git a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings index e337e7e..320f746 100644 --- a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings @@ -1,18 +1,6 @@ -/* (No Comment) */ -"Done!" = "Terminé!"; +/* No comment provided by engineer. */ +"´" = "´"; -/* (No Comment) */ -"Go!" = "Aller!"; - -/* (No Comment) */ -"lw" = "lw"; - -/* (No Comment) */ -"Search" = "Rechercher"; - -/* (No Comment) */ -"space" = "espace"; - -/* (No Comment) */ -"Up" = "Haut"; +/* No comment provided by engineer. */ +"⌫" = "⌫"; diff --git a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings index 29aef02..320f746 100644 --- a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings @@ -1,11 +1,6 @@ -"space" = "अंतरिक्ष बार"; +/* No comment provided by engineer. */ +"´" = "´"; -"Up" = "Up"; +/* No comment provided by engineer. */ +"⌫" = "⌫"; -"lw" = "lw"; - -"Done!" = "किया हुआ!"; - -"Search" = "खोज"; - -"Go!" = "जाओ!"; diff --git a/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings new file mode 100644 index 0000000..a7aab39 --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings @@ -0,0 +1,16 @@ +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + +/* spacebar */ +"space" = "spatie"; +/* Uppercase abbreviation for button (3 char max.) */ +"Up" = "Bov"; +/* lowercase abbreviation for button */ +"lw" = "lw"; + +"Done!" = "Klaar!"; +"Search" = "Zoeken"; +"Go!" = "Ga!"; diff --git a/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings index 8fe946a..320f746 100644 --- a/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings @@ -1,11 +1,6 @@ -"space" = "Лертасте"; +/* No comment provided by engineer. */ +"´" = "´"; -"Up" = "Ве"; +/* No comment provided by engineer. */ +"⌫" = "⌫"; -"lw" = "ни"; - -"Done!" = "Готово!"; - -"Search" = "Поиск"; - -"Go!" = "Вперед!"; From e7c5af7ad73e0629858220b5b77b98541a1677c0 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Sat, 7 Oct 2023 20:32:58 +0200 Subject: [PATCH 05/16] Fix l10n --- .../l10n/en.lproj/Localizable.strings | 12 ++++++------ .../l10n/fr.lproj/Localizable.strings | 14 ++++++++++++++ .../l10n/hi.lproj/Localizable.strings | 14 ++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings index 6e24c21..7611767 100644 --- a/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/en.lproj/Localizable.strings @@ -1,14 +1,14 @@ /* spacebar */ -"space" = "अंतरिक्ष"; +"space" = "space"; /* Uppercase abbreviation for button */ -"Up" = "ऊपर"; +"Up" = "Up"; /* lowercase abbreviation for button */ -"lw" = "लो"; +"lw" = "lw"; -"Done!" = "हो गया!"; +"Done!" = "Done!"; -"Search" = "खोज"; +"Search" = "Search"; -"Go!" = "जाओ!"; +"Go!" = "Go!"; diff --git a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings index 320f746..7ca0d14 100644 --- a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings @@ -4,3 +4,17 @@ /* No comment provided by engineer. */ "⌫" = "⌫"; +/* barre d'espace */ +"space" = "espace"; + +/* Abréviation en majuscules pour le bouton */ +"Up" = "Haut"; + +/* Abréviation en minuscules pour le bouton */ +"lw" = "min"; + +"Done!" = "Terminé !"; + +"Search" = "Rechercher"; + +"Go!" = "Allons-y !"; diff --git a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings index 320f746..88a2b44 100644 --- a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings @@ -4,3 +4,17 @@ /* No comment provided by engineer. */ "⌫" = "⌫"; +/* spacebar */ +"space" = "अंतरिक्ष"; + +/* Uppercase abbreviation for button */ +"Up" = "ऊपर"; + +/* lowercase abbreviation for button */ +"lw" = "लो"; + +"Done!" = "हो गया!"; + +"Search" = "खोज"; + +"Go!" = "जाओ!"; From 7bd68b9e3946acae903b76e0906986625c7f882b Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Sat, 7 Oct 2023 21:17:40 +0200 Subject: [PATCH 06/16] Add support for scandinvaian languages - finish - danish - norwegian - swedish (cherry picked from commit 5b909d4dfbdceddbe9c9e47c5d6e818075e4a05c) --- Sources/SimpleKeyboard/Models/Language.swift | 33 +++++++++++++++++++ .../l10n/da.lproj/Localizable.strings | 12 +++++++ .../l10n/sv.lproj/Localizable.strings | 11 +++++++ 3 files changed, 56 insertions(+) create mode 100644 Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings create mode 100644 Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index e271530..1e1ff19 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -22,6 +22,7 @@ public enum Language: CaseIterable { } case english, german, spanish, french, russian, hindi + case swedish, danish, norwegian, finnish var alternateKeys: [String: String] { switch self { @@ -29,6 +30,11 @@ public enum Language: CaseIterable { // spanish also has ü case .spanish: return ["e": "é", "a": "á", "i": "í", "o": "ó", "u": "ú", "n": "ñ"] case .french: return ["e": "é", "a": "à", "u": "ù", "i": "î", "o": "ô", "c": "ç"] + // Nynorsk uses several letters with diacritic signs: é, è, ê, ó, ò, â, and ô. The diacritic signs are not compulsory + case .danish, .norwegian: return ["e": "é"] + // Though not in the official alphabet, á is a Swedish (old-fashioned) letter. In native Swedish personal names, ü and è and others are also used. + case .swedish: return ["a":"á", "u":"ü", "e": "è"] + case .finnish: return ["s": "š", "z": "ž"] default: return [:] } } @@ -72,6 +78,33 @@ public enum Language: CaseIterable { ["ो", "े", "्", "ि", "ु", "प", "र", "क", "त", "च"], ["ं", "म", "न", "व", "ल", "स", "य"] ] + case .swedish: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + case .danish: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "æ", "ø"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + + case .norwegian: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + + case .finnish: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ø", "æ"], + ["z", "x", "c", "v", "b", "n", "m"] + ] + } if areUppercased { diff --git a/Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings new file mode 100644 index 0000000..07d16db --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/da.lproj/Localizable.strings @@ -0,0 +1,12 @@ +"space" = "mellemrum"; + +"Up" = "St"; + +"lw" = "sm"; + +"Done!" = "Udført!"; + +"Search" = "Søg"; + +"Go!" = "Gå!"; + diff --git a/Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings new file mode 100644 index 0000000..c7cac71 --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/sv.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"space" = "Mellanslag"; + +"Up" = "Upp"; + +"lw" = "lk"; + +"Done!" = "Klart!"; + +"Search" = "Sök"; + +"Go!" = "Gå!"; From 7880aa6e9ba568a23f90b2da5d9d6c65563dcc99 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Sat, 7 Oct 2023 21:31:27 +0200 Subject: [PATCH 07/16] Add missing translations - finnish - norwegian --- .../SimpleKeyboard/l10n/fi.lproj/Localizable.strings | 11 +++++++++++ .../SimpleKeyboard/l10n/no.lproj/Localizable.strings | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings create mode 100644 Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings diff --git a/Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings new file mode 100644 index 0000000..9040dbe --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/fi.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"space" = "Väli"; + +"Up" = "Ylös"; + +"lw" = "lk"; + +"Done!" = "Valmis!"; + +"Search" = "Etsi"; + +"Go!" = "Mene!"; diff --git a/Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings new file mode 100644 index 0000000..83b9e2a --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/no.lproj/Localizable.strings @@ -0,0 +1,11 @@ +"space" = "Mellomrom"; + +"Up" = "Opp"; + +"lw" = "lw"; + +"Done!" = "Ferdig!"; + +"Search" = "Søk"; + +"Go!" = "Gå!"; From 711247b454333021780994edfed6fa1bddf23fad Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Sun, 8 Oct 2023 14:31:00 +0200 Subject: [PATCH 08/16] Add `latinWithAccents` language layout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - can be used for a lot of latinous languaes - supports some common diacritics - uses Unicode combining charactes (U+0300–U+036F) --- Sources/SimpleKeyboard/Models/Language.swift | 28 +++++++++++++++++-- .../Views/SimpleStandardKeyboard.swift | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index 1e1ff19..6e72de2 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -23,6 +23,9 @@ public enum Language: CaseIterable { case english, german, spanish, french, russian, hindi case swedish, danish, norwegian, finnish + + /// General purpose layout using QWERTY with the common diacritics + case latinWithAccents var alternateKeys: [String: String] { switch self { @@ -35,6 +38,17 @@ public enum Language: CaseIterable { // Though not in the official alphabet, á is a Swedish (old-fashioned) letter. In native Swedish personal names, ü and è and others are also used. case .swedish: return ["a":"á", "u":"ü", "e": "è"] case .finnish: return ["s": "š", "z": "ž"] + case .latinWithAccents: + + // 300 = Grave; 301 = Acute; + // 302 = Circumflex; 303 = Tilde; + // 308 = Diaeresis; 30A = Ring; + // 327 = Cedilla; 30C = Caron; + return [ + "\u{0300}": "\u{0301}", + "\u{0302}": "\u{0303}", + "\u{0308}": "\u{030A}", + "\u{0327}": "\u{030C}",] default: return [:] } } @@ -90,14 +104,12 @@ public enum Language: CaseIterable { ["a", "s", "d", "f", "g", "h", "j", "k", "l", "æ", "ø"], ["z", "x", "c", "v", "b", "n", "m"] ] - case .norwegian: result = [ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"], ["z", "x", "c", "v", "b", "n", "m"] ] - case .finnish: result = [ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], @@ -105,10 +117,20 @@ public enum Language: CaseIterable { ["z", "x", "c", "v", "b", "n", "m"] ] + case .latinWithAccents: + result = [ + ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\u{0300}"], + ["a", "s", "d", "f", "g", "h", "j", "k", "l", "\u{0302}", "\u{0308}"], + ["z", "x", "c", "v", "b", "n", "m", "\u{0327}"] + ] } if areUppercased { - result = result.map { $0.map { $0.uppercased() } } + result = result.map { $0.map { + let upper = $0.uppercased() + if $0 != upper { return upper } + return alternateKeys[$0] ?? $0 + } } } return result diff --git a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift index cee95f1..4b6cb4b 100644 --- a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift @@ -116,7 +116,7 @@ struct SimpleStandardKeyboard_Previews: PreviewProvider { isUpperCase: true)) SimpleStandardKeyboard( settings: KeyboardSettings( - language: .spanish, + language: .latinWithAccents, textInput: nil, theme: .system, actionButton: .search, From efbd386dc5980a96d301dee51dba537bf7dda155 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Sun, 8 Oct 2023 14:31:26 +0200 Subject: [PATCH 09/16] Deprecate `AccentKeyButton` --- Sources/SimpleKeyboard/Views/KeyButton.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/SimpleKeyboard/Views/KeyButton.swift b/Sources/SimpleKeyboard/Views/KeyButton.swift index f6f0148..d38246f 100644 --- a/Sources/SimpleKeyboard/Views/KeyButton.swift +++ b/Sources/SimpleKeyboard/Views/KeyButton.swift @@ -77,6 +77,7 @@ struct KeyButton: View, ClickableKey { } /// Replaces the last typed character with another (special) character. E.g. "a" -> "ä" +@available(*, deprecated, message: "Use `Language.alternateKeys` instead") struct AccentKeyButton: View, ClickableKey { @Binding var text: String /// The lookup for modified characters all lowercased. E.g. `["a": "ä"]` From 4489ca7f0edcc1306eca5fc5786900312b4ee952 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Mon, 9 Oct 2023 08:46:10 +0200 Subject: [PATCH 10/16] Add coment for Danish diacitics --- Sources/SimpleKeyboard/Models/Language.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index 6e72de2..5555d12 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -34,6 +34,7 @@ public enum Language: CaseIterable { case .spanish: return ["e": "é", "a": "á", "i": "í", "o": "ó", "u": "ú", "n": "ñ"] case .french: return ["e": "é", "a": "à", "u": "ù", "i": "î", "o": "ô", "c": "ç"] // Nynorsk uses several letters with diacritic signs: é, è, ê, ó, ò, â, and ô. The diacritic signs are not compulsory + // Danish has no compulsory diacritics, but allows the use of an acute accent. Most often, an accent on e. case .danish, .norwegian: return ["e": "é"] // Though not in the official alphabet, á is a Swedish (old-fashioned) letter. In native Swedish personal names, ü and è and others are also used. case .swedish: return ["a":"á", "u":"ü", "e": "è"] From 63515c40ef2c009ae15d1748923f105d94e6da5f Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Mon, 9 Oct 2023 09:30:49 +0200 Subject: [PATCH 11/16] Fix minor codesmells --- Sources/SimpleKeyboard/Models/Language.swift | 11 ++--------- Sources/SimpleKeyboard/Views/KeyButton.swift | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index 5555d12..3bd571d 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -93,7 +93,7 @@ public enum Language: CaseIterable { ["ो", "े", "्", "ि", "ु", "प", "र", "क", "त", "च"], ["ं", "म", "न", "व", "ल", "स", "य"] ] - case .swedish: + case .swedish, .finnish: result = [ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"], @@ -106,12 +106,6 @@ public enum Language: CaseIterable { ["z", "x", "c", "v", "b", "n", "m"] ] case .norwegian: - result = [ - ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], - ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ö", "ä"], - ["z", "x", "c", "v", "b", "n", "m"] - ] - case .finnish: result = [ ["q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "å"], ["a", "s", "d", "f", "g", "h", "j", "k", "l", "ø", "æ"], @@ -129,8 +123,7 @@ public enum Language: CaseIterable { if areUppercased { result = result.map { $0.map { let upper = $0.uppercased() - if $0 != upper { return upper } - return alternateKeys[$0] ?? $0 + return $0 != upper ? upper : alternateKeys[$0] ?? $0 } } } diff --git a/Sources/SimpleKeyboard/Views/KeyButton.swift b/Sources/SimpleKeyboard/Views/KeyButton.swift index d38246f..54d0d5e 100644 --- a/Sources/SimpleKeyboard/Views/KeyButton.swift +++ b/Sources/SimpleKeyboard/Views/KeyButton.swift @@ -51,7 +51,7 @@ struct KeyButton: View, ClickableKey { @Environment(\.colorScheme) var colorScheme var body: some View { - Button(action: { }) { + Button(action: { /* use Gesture */}) { Text(letter) .font(.system(size: 25)) .fixedSize() From c9d9076dae45fcaea7ca42f85209d48fc052a197 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Mon, 9 Oct 2023 13:13:02 +0200 Subject: [PATCH 12/16] Add `KeyboardTheme.clear` - refactor View.keyboardBackground -> KeyboardTheme - use `@ViewBuilder` instead of `return AnyView` - use `Rectangle().fill(.clear)` instead `AnyView(EmptyView())` --- .../SimpleKeyboard/Helper/ThemingModifier.swift | 15 +++++++-------- .../SimpleKeyboard/Helper/View+Background.swift | 13 ++++++++----- Sources/SimpleKeyboard/Views/SimpleKeyboard.swift | 2 +- .../Views/SimpleStandardKeyboard.swift | 13 +++++++++++-- .../SimpleKeyboardTests/SimpleKeyboardTests.swift | 6 ++++-- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Sources/SimpleKeyboard/Helper/ThemingModifier.swift b/Sources/SimpleKeyboard/Helper/ThemingModifier.swift index fe1b681..58fd8cb 100644 --- a/Sources/SimpleKeyboard/Helper/ThemingModifier.swift +++ b/Sources/SimpleKeyboard/Helper/ThemingModifier.swift @@ -7,22 +7,21 @@ import SwiftUI -struct OuterKeyboardThemingModifier: ViewModifier { +struct OuterKeyboardThemingModifier: ViewModifier { var theme: KeyboardTheme - var backroundColor: Background func body(content: Content) -> some View { - if theme == .system { - content - .padding(10) - .background(backroundColor) - } else if theme == .floating { + if theme == .floating { content .cornerRadius(25, corners: [.bottomLeft, .bottomRight]) .padding(10) - .background(backroundColor) + .background(theme.keyboardBackground) .cornerRadius(25) .padding(10) + } else { + content + .padding(10) + .background(theme.keyboardBackground) } } } diff --git a/Sources/SimpleKeyboard/Helper/View+Background.swift b/Sources/SimpleKeyboard/Helper/View+Background.swift index 4da6051..3ab5ee6 100644 --- a/Sources/SimpleKeyboard/Helper/View+Background.swift +++ b/Sources/SimpleKeyboard/Helper/View+Background.swift @@ -8,7 +8,7 @@ import SwiftUI public enum KeyboardTheme { - case system, floating + case system, floating, clear } protocol ThemeableView { @@ -24,12 +24,15 @@ private typealias PlatformColor = NSColor extension NSColor { static var systemGray3: NSColor { NSColor.systemGray } } #endif -extension View where Self: ThemeableView { +extension KeyboardTheme { + @ViewBuilder var keyboardBackground: some View { - if #available(iOS 15.0, macOS 12.0, *) { - return AnyView(EmptyView().background(.ultraThinMaterial)) + if self == .clear { + Color.clear + } else if #available(iOS 15.0, macOS 12.0, *) { + Rectangle().fill(.clear).background(.ultraThinMaterial) } else { - return AnyView(Color(PlatformColor.systemGray3.withAlphaComponent(0.75))) + Color(PlatformColor.systemGray3.withAlphaComponent(0.75)) } } } diff --git a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift index 059e799..90175b8 100644 --- a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift @@ -52,7 +52,7 @@ public struct SimpleKeyboard: View, ThemeableView { public var body: some View { if isShown { - content.modifier(OuterKeyboardThemingModifier(theme: theme, backroundColor: keyboardBackground)) + content.modifier(OuterKeyboardThemingModifier(theme: theme)) } } } diff --git a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift index 4b6cb4b..67d1a48 100644 --- a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift @@ -9,6 +9,15 @@ import SwiftUI public struct SimpleStandardKeyboard: View, ThemeableView { var theme: KeyboardTheme { settings.theme } + + @ViewBuilder + var bgColor: some View { + if #available(iOS 16, *) { + Rectangle().fill(.clear).background(.ultraThinMaterial) + } else { + Color.clear + } + } @ObservedObject var settings: KeyboardSettings @@ -94,7 +103,7 @@ public struct SimpleStandardKeyboard: View, ThemeableView { spaceRow } .transition(.move(edge: .bottom).combined(with: .opacity)) - .modifier(OuterKeyboardThemingModifier(theme: theme, backroundColor: keyboardBackground)) + .modifier(OuterKeyboardThemingModifier(theme: theme)) } } } @@ -118,7 +127,7 @@ struct SimpleStandardKeyboard_Previews: PreviewProvider { settings: KeyboardSettings( language: .latinWithAccents, textInput: nil, - theme: .system, + theme: .clear, actionButton: .search, showNumbers: true, showSpace: false, diff --git a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift index 558f0cd..685e8ca 100644 --- a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift +++ b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift @@ -193,10 +193,12 @@ final class SimpleKeyboardTests: XCTestCase { } func test_theming_modifier() { - let mod = OuterKeyboardThemingModifier(theme: .floating, backroundColor: Color.black) - let mod2 = OuterKeyboardThemingModifier(theme: .system, backroundColor: Color.black) + let mod = OuterKeyboardThemingModifier(theme: .floating) + let mod2 = OuterKeyboardThemingModifier(theme: .system) + let mod3 = OuterKeyboardThemingModifier(theme: .clear) XCTAssertNotNil(EmptyView().modifier(mod)) XCTAssertNotNil(EmptyView().modifier(mod2)) + XCTAssertNotNil(EmptyView().modifier(mod3)) } static var allTests = [ From e1c6062c20a9a6371792964f78644d916e16fa57 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Mon, 9 Oct 2023 13:13:02 +0200 Subject: [PATCH 13/16] Add `KeyboardTheme.clear` - refactor View.keyboardBackground -> KeyboardTheme - use `@ViewBuilder` instead of `return AnyView` - use `Rectangle().fill(.clear)` instead `AnyView(EmptyView())` --- .../SimpleKeyboard/Helper/ThemingModifier.swift | 15 +++++++-------- .../SimpleKeyboard/Helper/View+Background.swift | 13 ++++++++----- Sources/SimpleKeyboard/Views/SimpleKeyboard.swift | 2 +- .../Views/SimpleStandardKeyboard.swift | 4 ++-- .../SimpleKeyboardTests/SimpleKeyboardTests.swift | 6 ++++-- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/Sources/SimpleKeyboard/Helper/ThemingModifier.swift b/Sources/SimpleKeyboard/Helper/ThemingModifier.swift index fe1b681..58fd8cb 100644 --- a/Sources/SimpleKeyboard/Helper/ThemingModifier.swift +++ b/Sources/SimpleKeyboard/Helper/ThemingModifier.swift @@ -7,22 +7,21 @@ import SwiftUI -struct OuterKeyboardThemingModifier: ViewModifier { +struct OuterKeyboardThemingModifier: ViewModifier { var theme: KeyboardTheme - var backroundColor: Background func body(content: Content) -> some View { - if theme == .system { - content - .padding(10) - .background(backroundColor) - } else if theme == .floating { + if theme == .floating { content .cornerRadius(25, corners: [.bottomLeft, .bottomRight]) .padding(10) - .background(backroundColor) + .background(theme.keyboardBackground) .cornerRadius(25) .padding(10) + } else { + content + .padding(10) + .background(theme.keyboardBackground) } } } diff --git a/Sources/SimpleKeyboard/Helper/View+Background.swift b/Sources/SimpleKeyboard/Helper/View+Background.swift index 4da6051..3ab5ee6 100644 --- a/Sources/SimpleKeyboard/Helper/View+Background.swift +++ b/Sources/SimpleKeyboard/Helper/View+Background.swift @@ -8,7 +8,7 @@ import SwiftUI public enum KeyboardTheme { - case system, floating + case system, floating, clear } protocol ThemeableView { @@ -24,12 +24,15 @@ private typealias PlatformColor = NSColor extension NSColor { static var systemGray3: NSColor { NSColor.systemGray } } #endif -extension View where Self: ThemeableView { +extension KeyboardTheme { + @ViewBuilder var keyboardBackground: some View { - if #available(iOS 15.0, macOS 12.0, *) { - return AnyView(EmptyView().background(.ultraThinMaterial)) + if self == .clear { + Color.clear + } else if #available(iOS 15.0, macOS 12.0, *) { + Rectangle().fill(.clear).background(.ultraThinMaterial) } else { - return AnyView(Color(PlatformColor.systemGray3.withAlphaComponent(0.75))) + Color(PlatformColor.systemGray3.withAlphaComponent(0.75)) } } } diff --git a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift index 059e799..90175b8 100644 --- a/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleKeyboard.swift @@ -52,7 +52,7 @@ public struct SimpleKeyboard: View, ThemeableView { public var body: some View { if isShown { - content.modifier(OuterKeyboardThemingModifier(theme: theme, backroundColor: keyboardBackground)) + content.modifier(OuterKeyboardThemingModifier(theme: theme)) } } } diff --git a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift index 4b6cb4b..f7f2156 100644 --- a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift @@ -94,7 +94,7 @@ public struct SimpleStandardKeyboard: View, ThemeableView { spaceRow } .transition(.move(edge: .bottom).combined(with: .opacity)) - .modifier(OuterKeyboardThemingModifier(theme: theme, backroundColor: keyboardBackground)) + .modifier(OuterKeyboardThemingModifier(theme: theme)) } } } @@ -118,7 +118,7 @@ struct SimpleStandardKeyboard_Previews: PreviewProvider { settings: KeyboardSettings( language: .latinWithAccents, textInput: nil, - theme: .system, + theme: .clear, actionButton: .search, showNumbers: true, showSpace: false, diff --git a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift index 558f0cd..685e8ca 100644 --- a/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift +++ b/Tests/SimpleKeyboardTests/SimpleKeyboardTests.swift @@ -193,10 +193,12 @@ final class SimpleKeyboardTests: XCTestCase { } func test_theming_modifier() { - let mod = OuterKeyboardThemingModifier(theme: .floating, backroundColor: Color.black) - let mod2 = OuterKeyboardThemingModifier(theme: .system, backroundColor: Color.black) + let mod = OuterKeyboardThemingModifier(theme: .floating) + let mod2 = OuterKeyboardThemingModifier(theme: .system) + let mod3 = OuterKeyboardThemingModifier(theme: .clear) XCTAssertNotNil(EmptyView().modifier(mod)) XCTAssertNotNil(EmptyView().modifier(mod2)) + XCTAssertNotNil(EmptyView().modifier(mod3)) } static var allTests = [ From 8b4e30ea591843de5dbde06c1fe01f59412af9f5 Mon Sep 17 00:00:00 2001 From: Henrik Storch Date: Tue, 10 Oct 2023 12:01:12 +0200 Subject: [PATCH 14/16] Improve/fix translations - i18n (cherry picked from commit d7b7f1c7cb7c424386f500b453345d8673dbf5fd) --- .../l10n/de.lproj/Localizable.strings | 6 +++--- .../l10n/es.lproj/Localizable.strings | 12 ++++++++--- .../l10n/fr.lproj/Localizable.strings | 20 +++++++++++-------- .../l10n/hi.lproj/Localizable.strings | 18 ++++++++++------- .../l10n/nl.lproj/Localizable.strings | 20 +++++++++++++------ .../l10n/ru.lproj/Localizable.strings | 18 +++++++++++++++++ 6 files changed, 67 insertions(+), 27 deletions(-) diff --git a/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings index 7b2fb6b..7446de8 100644 --- a/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/de.lproj/Localizable.strings @@ -4,15 +4,15 @@ /* (No Comment) */ "Go!" = "Los!"; -/* lower case */ +/* lowercase abbreviation for button */ "lw" = "kl"; /* (No Comment) */ "Search" = "Suchen"; -/* (No Comment) */ +/* spacebar */ "space" = "Leertaste"; -/* Upper Case */ +/* Uppercase abbreviation for button */ "Up" = "Gr"; diff --git a/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings index d9ea0be..844126e 100644 --- a/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/es.lproj/Localizable.strings @@ -1,18 +1,24 @@ +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + /* (No Comment) */ "Done!" = "¡Hecho!"; /* (No Comment) */ "Go!" = "ir"; -/* lower case */ +/* lowercase abbreviation for button */ "lw" = "mi"; /* (No Comment) */ "Search" = "buscar"; -/* (No Comment) */ +/* spacebar */ "space" = "espacio"; -/* Upper Case */ +/* Uppercase abbreviation for button */ "Up" = "Ma"; diff --git a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings index 7ca0d14..44fa38f 100644 --- a/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/fr.lproj/Localizable.strings @@ -4,17 +4,21 @@ /* No comment provided by engineer. */ "⌫" = "⌫"; -/* barre d'espace */ -"space" = "espace"; +/* (No Comment) */ +"Done!" = "Terminé !"; -/* Abréviation en majuscules pour le bouton */ -"Up" = "Haut"; +/* (No Comment) */ +"Go!" = "Allons-y !"; -/* Abréviation en minuscules pour le bouton */ +/* lowercase abbreviation for button */ "lw" = "min"; -"Done!" = "Terminé !"; - +/* (No Comment) */ "Search" = "Rechercher"; -"Go!" = "Allons-y !"; +/* spacebar */ +"space" = "espace"; + +/* Uppercase abbreviation for button */ +"Up" = "Haut"; + diff --git a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings index 88a2b44..1792e07 100644 --- a/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/hi.lproj/Localizable.strings @@ -4,17 +4,21 @@ /* No comment provided by engineer. */ "⌫" = "⌫"; -/* spacebar */ -"space" = "अंतरिक्ष"; +/* (No Comment) */ +"Done!" = "हो गया!"; -/* Uppercase abbreviation for button */ -"Up" = "ऊपर"; +/* (No Comment) */ +"Go!" = "जाओ!"; /* lowercase abbreviation for button */ "lw" = "लो"; -"Done!" = "हो गया!"; - +/* (No Comment) */ "Search" = "खोज"; -"Go!" = "जाओ!"; +/* spacebar */ +"space" = "अंतरिक्ष"; + +/* Uppercase abbreviation for button */ +"Up" = "ऊपर"; + diff --git a/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings index a7aab39..6f402a8 100644 --- a/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/nl.lproj/Localizable.strings @@ -4,13 +4,21 @@ /* No comment provided by engineer. */ "⌫" = "⌫"; -/* spacebar */ -"space" = "spatie"; -/* Uppercase abbreviation for button (3 char max.) */ -"Up" = "Bov"; +/* (No Comment) */ +"Done!" = "Klaar!"; + +/* (No Comment) */ +"Go!" = "Ga!"; + /* lowercase abbreviation for button */ "lw" = "lw"; -"Done!" = "Klaar!"; +/* (No Comment) */ "Search" = "Zoeken"; -"Go!" = "Ga!"; + +/* spacebar */ +"space" = "spatie"; + +/* Uppercase abbreviation for button */ +"Up" = "Bov"; + diff --git a/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings index 320f746..6073dd7 100644 --- a/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings +++ b/Sources/SimpleKeyboard/l10n/ru.lproj/Localizable.strings @@ -4,3 +4,21 @@ /* No comment provided by engineer. */ "⌫" = "⌫"; +/* (No Comment) */ +"Done!" = "Готово!"; + +/* (No Comment) */ +"Go!" = "Вперед!"; + +/* lowercase abbreviation for button */ +"lw" = "Лw"; + +/* (No Comment) */ +"Search" = "Поиск"; + +/* spacebar */ +"space" = "пробел"; + +/* Uppercase abbreviation for button */ +"Up" = "Уп"; + From 829846f9204dfc473b305a85d2b3cdbc88ce5131 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 13 Oct 2023 10:54:34 +0200 Subject: [PATCH 15/16] Fix #available on macOS --- Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift index 67d1a48..0145271 100644 --- a/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift +++ b/Sources/SimpleKeyboard/Views/SimpleStandardKeyboard.swift @@ -12,7 +12,7 @@ public struct SimpleStandardKeyboard: View, ThemeableView { @ViewBuilder var bgColor: some View { - if #available(iOS 16, *) { + if #available(iOS 15.0, macOS 12.0, *) { Rectangle().fill(.clear).background(.ultraThinMaterial) } else { Color.clear From 7a24985c02922df8e0bd5791de2753beaa000c06 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 5 Jan 2024 08:53:37 +1300 Subject: [PATCH 16/16] Update l18n - add Korean - update yeartext --- Sources/SimpleKeyboard/Models/Language.swift | 8 +++++++ .../l10n/ko.lproj/Localizable.strings | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings diff --git a/Sources/SimpleKeyboard/Models/Language.swift b/Sources/SimpleKeyboard/Models/Language.swift index 3bd571d..13d80ae 100644 --- a/Sources/SimpleKeyboard/Models/Language.swift +++ b/Sources/SimpleKeyboard/Models/Language.swift @@ -23,6 +23,7 @@ public enum Language: CaseIterable { case english, german, spanish, french, russian, hindi case swedish, danish, norwegian, finnish + case korean /// General purpose layout using QWERTY with the common diacritics case latinWithAccents @@ -39,6 +40,7 @@ public enum Language: CaseIterable { // Though not in the official alphabet, á is a Swedish (old-fashioned) letter. In native Swedish personal names, ü and è and others are also used. case .swedish: return ["a":"á", "u":"ü", "e": "è"] case .finnish: return ["s": "š", "z": "ž"] + case .korean: return ["ㅂ":"ㅃ", "ㅈ":"ㅉ", "ㄷ":"ㄸ", "ㄱ":"ㄲ", "ㅅ":"ㅆ", "ㅐ":"ㅒ", "ㅔ":"ㅖ"] case .latinWithAccents: // 300 = Grave; 301 = Acute; @@ -118,6 +120,12 @@ public enum Language: CaseIterable { ["a", "s", "d", "f", "g", "h", "j", "k", "l", "\u{0302}", "\u{0308}"], ["z", "x", "c", "v", "b", "n", "m", "\u{0327}"] ] + case .korean: + result = [ + ["ㅂ","ㅈ","ㄷ","ㄱ","ㅅ","ㅛ","ㅕ","ㅑ","ㅐ","ㅔ"], + ["ㅁ","ㄴ","ㅇ","ㄹ","ㅎ","ㅗ","ㅓ","ㅏ","ㅣ"], + ["ㅋ","ㅌ","ㅊ","ㅍ","ㅠ","ㅜ","ㅡ"] + ] } if areUppercased { diff --git a/Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings b/Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings new file mode 100644 index 0000000..ac00cfd --- /dev/null +++ b/Sources/SimpleKeyboard/l10n/ko.lproj/Localizable.strings @@ -0,0 +1,24 @@ +/* No comment provided by engineer. */ +"´" = "´"; + +/* No comment provided by engineer. */ +"⌫" = "⌫"; + +/* (No Comment) */ +"Done!" = "완료!"; + +/* (No Comment) */ +"Go!" = "진행!"; + +/* lowercase abbreviation for button */ +"lw" = "lw"; + +/* (No Comment) */ +"Search" = "검색"; + +/* spacebar */ +"space" = "공백"; + +/* Uppercase abbreviation for button */ +"Up" = "위"; +