-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtooltips.ts
More file actions
343 lines (340 loc) · 12.3 KB
/
Copy pathtooltips.ts
File metadata and controls
343 lines (340 loc) · 12.3 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
// English tooltip/caption catalog, keyed by the ids used throughout the app
// (for example "rule_up", "C0", "T14"). The keys and English values are derived
// from locales/tooltips.json and regenerated by scripts/tooltipgen.mjs.
//
// This file holds English source strings only. Translations live in _loc.table:
// resolveTooltip() runs the English string through ui.loc(), which returns the
// translation when a per-language build supplies a table, and the English string
// unchanged otherwise.
//
// The N* sample-name ids from locales/tooltips.json are excluded here; they are
// not resolved at runtime by any file in the pxt.json files list.
namespace microcode {
// English source strings keyed by tooltip id. English content does not
// depend on _loc, so this literal is safe at module-init time. Localization
// is applied only by resolveTooltip(), at call time.
const tooltipTable: { [id: string]: string } = {
"tagline": "for micro:bit V2",
"sensors": "when...",
"actuators": "do...",
"when": "when",
"do": "do",
"connect": "connect",
"rule": "rule",
"add_rule": "add rule",
"delete_rule": "delete rule",
"delete": "delete",
"rule_up": "move rule up",
"rule_down": "move rule down",
"disk": "save",
"load": "load",
"settings": "settings",
"page": "page",
"run": "run program",
"stop": "stop program",
"C0": "edit",
"C1": "samples",
"T10": "start page",
"T11": "press",
"T12": "release",
"T13": "move",
"T14": "timer",
"T15": "light (external)",
"T16": "temperature",
"T17": "radio receive",
"T18": "sound",
"T19": "variable X set",
"T20": "variable Y set",
"T21": "variable Z set",
"T22": "magnet",
"T23": "slider",
"T24": "dial",
"T25": "wall",
"T26": "line",
"T27": "light",
"T28": "moisture",
"T29": "distance",
"T30": "reflected light",
"T40": "switch page",
"T41": "play sound",
"T43": "music",
"T44": "show image",
"T45": "radio send",
"T46": "radio set group",
"T47": "LED",
"T48": "set variable X",
"T49": "set variable Y",
"T50": "set variable Z",
"T51": "show number",
"T52": "robot",
"T53": "servo set angle",
"T54": "relay",
"T55": "servo power",
"T70": "touch pin 0",
"T71": "touch pin 1",
"T72": "touch pin 2",
"T73": "button A",
"T74": "button B",
"T75": "key 1",
"T76": "key 2",
"T77": "logo",
"T78": "1",
"T79": "2",
"T80": "3",
"T81": "4",
"T82": "5",
"T83": "1/4 second",
"T84": "1 second",
"T85": "1 random second",
"T86": "5 seconds",
"T87": "loud",
"T88": "quiet",
"T89": "NA1",
"T90": "shake",
"T91": "tilt up",
"T92": "tilt down",
"T93": "tilt left",
"T94": "tilt right",
"T95": "variable X",
"T96": "variable Y",
"T97": "variable Z",
"T98": "turn left",
"T99": "turn right",
"T100": "up",
"T101": "down",
"T103": "right",
"T104": "both",
"T105": "none",
"T106": "lost left",
"T107": "lost right",
"T108": "face up",
"T109": "face down",
"T110": "active",
"T111": "unactive",
"T150": "page 1",
"T151": "page 2",
"T152": "page 3",
"T153": "page 4",
"T154": "page 5",
"T160": "image",
"T161": "NA5",
"T162": "NA6",
"T163": "giggle",
"T164": "happy",
"T165": "hello",
"T166": "mysterious",
"T167": "sad",
"T168": "slide",
"T169": "soaring",
"T170": "spring",
"T171": "twinkle",
"T172": "yawn",
"T176": "radio value",
"T177": "random number",
"T178": "repeat",
"T179": "melody",
"T180": "temp.",
"T181": "NA2",
"T182": "red",
"T183": "green",
"T184": "blue",
"T185": "purple",
"T186": "yellow",
"T187": "black",
"T188": "rainbow",
"T189": "sparkle",
"T190": "forward",
"T191": "reverse",
"T192": "NA3",
"T193": "NA4",
"T194": "stop",
"T195": "fast forward",
"T196": "spin left",
"T197": "spin right",
"T198": "LED red",
"T199": "LED green",
"T200": "LED blue",
"T201": "LED OFF",
"T202": "arm open",
"T203": "arm close",
"T204": "on",
"T205": "off",
"T206": "light value",
"T207": "magnet value",
"T208": "sound value",
"T210": "add",
"T211": "subtract",
"T212": "multiply",
"T213": "divide",
"T220": "equals",
"T221": "not equals",
"T222": "less than",
"T223": "less than or equals",
"T224": "greater than",
"T225": "greater than or equals",
"T255": "enter number",
}
// Returns the English source string for an id, or "" for a missing or
// falsy id.
export function tooltip(id: string): string {
if (!id) return ""
const res = tooltipTable[id]
if (res === undefined) return ""
return res
}
// Returns the localized tooltip string for an id. The English source is
// looked up first, then run through ui.loc; an unknown id yields "" and is
// never passed through loc.
export function resolveTooltip(id: string): string {
const src = tooltip(id)
if (!src) return ""
return ui.loc(src) // locstrings-ignore: catalogued via tooltips.json
}
// Reverse map from English tooltip string to Tid. Used by web-only tooling
// (mcparser.ts), which is excluded from the hardware build; the content is
// English, mirroring the catalog above.
export function tooltip2tid(id: string): number {
let tid: number = undefined
if (!id) return tid
else if (id === "start page") tid = 10
else if (id === "press") tid = 11
else if (id === "release") tid = 12
else if (id === "move") tid = 13
else if (id === "timer") tid = 14
else if (id === "light (external)") tid = 15
else if (id === "temperature") tid = 16
else if (id === "radio receive") tid = 17
else if (id === "sound") tid = 18
else if (id === "variable X set") tid = 19
else if (id === "variable Y set") tid = 20
else if (id === "variable Z set") tid = 21
else if (id === "magnet") tid = 22
else if (id === "slider") tid = 23
else if (id === "dial") tid = 24
else if (id === "wall") tid = 25
else if (id === "line") tid = 26
else if (id === "light") tid = 27
else if (id === "moisture") tid = 28
else if (id === "distance") tid = 29
else if (id === "reflected light") tid = 30
else if (id === "switch page") tid = 40
else if (id === "play sound") tid = 41
else if (id === "music") tid = 43
else if (id === "show image") tid = 44
else if (id === "radio send") tid = 45
else if (id === "radio set group") tid = 46
else if (id === "LED") tid = 47
else if (id === "set variable X") tid = 48
else if (id === "set variable Y") tid = 49
else if (id === "set variable Z") tid = 50
else if (id === "show number") tid = 51
else if (id === "robot") tid = 52
else if (id === "servo set angle") tid = 53
else if (id === "relay") tid = 54
else if (id === "servo power") tid = 55
else if (id === "touch pin 0") tid = 70
else if (id === "touch pin 1") tid = 71
else if (id === "touch pin 2") tid = 72
else if (id === "button A") tid = 73
else if (id === "button B") tid = 74
else if (id === "key 1") tid = 75
else if (id === "key 2") tid = 76
else if (id === "logo") tid = 77
else if (id === "1") tid = 78
else if (id === "2") tid = 79
else if (id === "3") tid = 80
else if (id === "4") tid = 81
else if (id === "5") tid = 82
else if (id === "1/4 second") tid = 83
else if (id === "1 second") tid = 84
else if (id === "1 random second") tid = 85
else if (id === "5 seconds") tid = 86
else if (id === "loud") tid = 87
else if (id === "quiet") tid = 88
else if (id === "NA1") tid = 89
else if (id === "shake") tid = 90
else if (id === "tilt up") tid = 91
else if (id === "tilt down") tid = 92
else if (id === "tilt left") tid = 93
else if (id === "tilt right") tid = 94
else if (id === "variable X") tid = 95
else if (id === "variable Y") tid = 96
else if (id === "variable Z") tid = 97
else if (id === "turn left") tid = 98
else if (id === "turn right") tid = 99
else if (id === "up") tid = 100
else if (id === "down") tid = 101
else if (id === "right") tid = 103
else if (id === "both") tid = 104
else if (id === "none") tid = 105
else if (id === "lost left") tid = 106
else if (id === "lost right") tid = 107
else if (id === "face up") tid = 108
else if (id === "face down") tid = 109
else if (id === "active") tid = 110
else if (id === "unactive") tid = 111
else if (id === "page 1") tid = 150
else if (id === "page 2") tid = 151
else if (id === "page 3") tid = 152
else if (id === "page 4") tid = 153
else if (id === "page 5") tid = 154
else if (id === "image") tid = 160
else if (id === "NA5") tid = 161
else if (id === "NA6") tid = 162
else if (id === "giggle") tid = 163
else if (id === "happy") tid = 164
else if (id === "hello") tid = 165
else if (id === "mysterious") tid = 166
else if (id === "sad") tid = 167
else if (id === "slide") tid = 168
else if (id === "soaring") tid = 169
else if (id === "spring") tid = 170
else if (id === "twinkle") tid = 171
else if (id === "yawn") tid = 172
else if (id === "radio value") tid = 176
else if (id === "random number") tid = 177
else if (id === "repeat") tid = 178
else if (id === "melody") tid = 179
else if (id === "temp.") tid = 180
else if (id === "NA2") tid = 181
else if (id === "red") tid = 182
else if (id === "green") tid = 183
else if (id === "blue") tid = 184
else if (id === "purple") tid = 185
else if (id === "yellow") tid = 186
else if (id === "black") tid = 187
else if (id === "rainbow") tid = 188
else if (id === "sparkle") tid = 189
else if (id === "forward") tid = 190
else if (id === "reverse") tid = 191
else if (id === "NA3") tid = 192
else if (id === "NA4") tid = 193
else if (id === "stop") tid = 194
else if (id === "fast forward") tid = 195
else if (id === "spin left") tid = 196
else if (id === "spin right") tid = 197
else if (id === "LED red") tid = 198
else if (id === "LED green") tid = 199
else if (id === "LED blue") tid = 200
else if (id === "LED OFF") tid = 201
else if (id === "arm open") tid = 202
else if (id === "arm close") tid = 203
else if (id === "on") tid = 204
else if (id === "off") tid = 205
else if (id === "light value") tid = 206
else if (id === "magnet value") tid = 207
else if (id === "sound value") tid = 208
else if (id === "add") tid = 210
else if (id === "subtract") tid = 211
else if (id === "multiply") tid = 212
else if (id === "divide") tid = 213
else if (id === "equals") tid = 220
else if (id === "not equals") tid = 221
else if (id === "less than") tid = 222
else if (id === "less than or equals") tid = 223
else if (id === "greater than") tid = 224
else if (id === "greater than or equals") tid = 225
else if (id === "enter number") tid = 255
return tid
}
}