-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathHEInterfaceVariables.swift
More file actions
245 lines (211 loc) · 11 KB
/
HEInterfaceVariables.swift
File metadata and controls
245 lines (211 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
// SPDX-License-Identifier: GPL-3.0-or-later
/*
* Constants and functions to load the Hebrew Scribe keyboard.
*/
import UIKit
// MARK: Constants
public enum HEKeyboardConstants {
static let defaultCurrencyKey = "₪"
static let currencyKeys = ["₪", "€", "£", "$"]
}
struct HEKeyboardProvider: KeyboardProviderProtocol {
// MARK: iPhone Layouts
static func genPhoneLetterKeys() -> [[String]] {
return KeyboardBuilder()
.addRow(["פ", "ם", "ן", "ו", "ט", "א", "ר", "ק", "delete"])
.addRow(["ף", "ך", "ל", "ח", "י", "ע", "כ", "ג", "ד", "ש"])
.addRow(["ץ", "ת", "צ", "מ", "נ", "ה", "ב", "ס", "ז"])
.addRow(["123", "selectKeyboard", "space", "return"])
.build()
}
static func genPhoneNumberKeys(currencyKey: String) -> [[String]] {
return KeyboardBuilder()
.addRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"])
.addRow(["-", "/", ":", ";", "(", ")", "$", "&", "@", "\""])
.addRow(["#+=", ".", ",", "?", "!", "'", "delete"])
.addRow(["אבג", "selectKeyboard", "space", "return"])
.replaceKey(row: 1, column: 6, to: currencyKey)
.build()
}
static func genPhoneSymbolKeys(currencyKeys: [String]) -> [[String]] {
let keyboardBuilder = KeyboardBuilder()
.addRow(["[", "]", "{", "}", "#", "%", "^", "*", "+", "="])
.addRow(["_", "\\", "|", "~", "<", ">", "€", "£", "¥", "·"])
.addRow(["123", ".", ",", "?", "!", "'", "delete"])
.addRow(["אבג", "selectKeyboard", "space", "return"])
if currencyKeys.count < 3 {
return keyboardBuilder.build()
} else {
return
keyboardBuilder
.replaceKey(row: 1, column: 6, to: currencyKeys[0])
.replaceKey(row: 1, column: 7, to: currencyKeys[1])
.replaceKey(row: 1, column: 8, to: currencyKeys[2])
.build()
}
}
// MARK: iPad Layouts
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 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()
}
}
// MARK: Expanded iPad Layouts
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()
}
}
// MARK: Get Keys
func getHEKeys() {
guard let userDefaults = UserDefaults(suiteName: "group.be.scri.userDefaultsContainer")
else {
fatalError("Unable to access shared user defaults")
}
var currencyKey = HEKeyboardConstants.defaultCurrencyKey
var currencyKeys = HEKeyboardConstants.currencyKeys
let dictionaryKey = controllerLanguage + "defaultCurrencySymbol"
if let currencyValue = userDefaults.string(forKey: dictionaryKey) {
currencyKey = currencyValue
} else {
userDefaults.setValue(currencyKey, forKey: dictionaryKey)
}
if let index = currencyKeys.firstIndex(of: currencyKey) {
currencyKeys.remove(at: index)
}
if DeviceType.isPhone {
letterKeys = HEKeyboardProvider.genPhoneLetterKeys()
numberKeys = HEKeyboardProvider.genPhoneNumberKeys(currencyKey: currencyKey)
symbolKeys = HEKeyboardProvider.genPhoneSymbolKeys(currencyKeys: currencyKeys)
allKeys =
Array(letterKeys.joined()) + Array(numberKeys.joined()) + Array(symbolKeys.joined())
} else {
// Use the expanded keys layout if the iPad is wide enough and has no home button.
if usingExpandedKeyboard {
letterKeys = HEKeyboardProvider.genPadExpandedLetterKeys()
symbolKeys = HEKeyboardProvider.genPadExpandedSymbolKeys()
allKeys = Array(letterKeys.joined()) + Array(symbolKeys.joined())
} else {
letterKeys = HEKeyboardProvider.genPadLetterKeys()
numberKeys = HEKeyboardProvider.genPadNumberKeys(currencyKey: currencyKey)
symbolKeys = HEKeyboardProvider.genPadSymbolKeys(currencyKeys: currencyKeys)
letterKeys.removeFirst(1)
allKeys =
Array(letterKeys.joined()) + Array(numberKeys.joined()) + Array(symbolKeys.joined())
}
}
}
// MARK: Provide Layout
func setHEKeyboardLayout() {
getHEKeys()
currencySymbol = ""
currencySymbolAlternates = roubleAlternateKeys
spaceBar = "רווח"
language = "עברית"
invalidCommandMsgWikidata = "אין מידע"
invalidCommandTextWikidata1 =
"ויקידאטים הוא גרף ידע שנערך בשיתוף פעולה ומתוחזק על ידי קרן ויקימדיה. הוא משמש כמקור לנתונים פתוחים עבור פרויקטים כמו ויקיפדיה ועוד רבים אחרים."
invalidCommandTextWikidata2 =
"סקריב משתמש בנתוני השפה של ויקידאטים עבור רבים מתכונות הליבה שלו. אנו מקבלים מידע כמו מגדרים של שמות עצם, צימוד פעלים ועוד!"
invalidCommandTextWikidata3 =
"ניתן ליצור חשבון ב-wikidata.org כדי להצטרף לקהילה התומכת בסקריב ובפרויקטים רבים אחרים. עזרו לנו להביא מידע חופשי לעולם!"
invalidCommandMsgWiktionary = "אין מידע"
invalidCommandTextWiktionary1 =
"ויקימיילון הוא מילון שנערך בשיתוף פעולה ומתוחזק על ידי קרן ויקימדיה. הוא משמש כמקור לנתונים לשוניים בחינם עבור פרויקטים כמו ויקיפדיה ועוד רבים אחרים."
invalidCommandTextWiktionary2 =
"סקריב משתמש בנתוני ויקימיילון כדי לספק תרגומים לפקודת התרגום שלו. הנתונים שלנו נגזרים מזוגות השפות הרבים שיצרה קהילת ויקימיילון!"
invalidCommandTextWiktionary3 =
"ניתן ליצור חשבון ב-wiktionary.org כדי להצטרף לקהילה התומכת בסקריב ובפרויקטים רבים אחרים. עזרו לנו להביא מידע חופשי לעולם!"
baseAutosuggestions = ["אתמ", "אני", "היי"]
numericAutosuggestions = ["", "", ""]
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 = "לְהַטוֹת"
conjugatePlaceholder = "לְהַטוֹת"
conjugatePrompt = commandPromptSpacing + " :נְטִיָה"
conjugatePromptAndCursor = conjugatePrompt + commandCursor
conjugatePromptAndPlaceholder = conjugatePromptAndCursor + " " + conjugatePlaceholder
conjugatePromptAndColorPlaceholder = NSMutableAttributedString(
string: conjugatePromptAndPlaceholder
)
conjugatePromptAndColorPlaceholder.setColorForText(
textForAttribute: conjugatePlaceholder,
withColor: UIColor(cgColor: commandBarPlaceholderColorCG)
)
pluralKeyLbl = "רַבִּים"
pluralPlaceholder = "רַבִּים"
pluralPrompt = commandPromptSpacing + " :רַבִּים"
pluralPromptAndCursor = pluralPrompt + commandCursor
pluralPromptAndPlaceholder = pluralPromptAndCursor + " " + pluralPlaceholder
pluralPromptAndColorPlaceholder = NSMutableAttributedString(string: pluralPromptAndPlaceholder)
pluralPromptAndColorPlaceholder.setColorForText(
textForAttribute: pluralPlaceholder,
withColor: UIColor(cgColor: commandBarPlaceholderColorCG)
)
alreadyPluralMsg = "כבר בצורת רבים"
}