Merge lp:~nikwen/ubuntu-terminal-app/layout-i18n into lp:~ubuntu-terminal-dev/ubuntu-terminal-app/reboot

Proposed by Niklas Wenzel
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 106
Merged at revision: 112
Proposed branch: lp:~nikwen/ubuntu-terminal-app/layout-i18n
Merge into: lp:~ubuntu-terminal-dev/ubuntu-terminal-app/reboot
Diff against target: 776 lines (+298/-75)
11 files modified
po/com.ubuntu.terminal.pot (+93/-1)
src/app/qml/KeyboardRows/JsonTranslator.qml (+115/-0)
src/app/qml/KeyboardRows/KeyboardLayout.qml (+31/-9)
src/app/qml/KeyboardRows/Layouts/ControlKeys.json (+1/-7)
src/app/qml/KeyboardRows/Layouts/FunctionKeys.json (+14/-27)
src/app/qml/KeyboardRows/Layouts/Nano.json (+0/-12)
src/app/qml/KeyboardRows/Layouts/ScrollKeys.json (+8/-9)
src/app/qml/KeyboardRows/Layouts/SimpleCommands.json (+1/-2)
src/app/qml/KeyboardRows/jsonParser.js (+22/-6)
src/app/qml/TerminalSettings.qml (+8/-2)
src/app/qml/ubuntu-terminal-app.qml (+5/-0)
To merge this branch: bzr merge lp:~nikwen/ubuntu-terminal-app/layout-i18n
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Alan Pope 🍺🐧🐱 πŸ¦„ (community) Approve
Review via email: mp+264620@code.launchpad.net

Commit message

Add the ability to translate strings from json profiles

Description of the change

Add the ability to translate strings from json profiles

To post a comment you must log in.
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Just found something while looking through the diff. Will fix it. :)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Should be fixed now. :)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Looks good, thanks Niklas!

review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Pope 🍺🐧🐱 πŸ¦„ (popey) wrote :

Looks like a couple of merge conflicts.

Revision history for this message
Niklas Wenzel (nikwen) wrote :

I'll get to them. Thank you for reviewing this one as well. :)

104. By Niklas Wenzel

Merge master

105. By Niklas Wenzel

Update JsonTranslator to the new UITK as well

Revision history for this message
Niklas Wenzel (nikwen) wrote :

I resolved the conflicts. Should be ready for merging now. :)

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Oh no! I found a bug!

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
106. By Niklas Wenzel

Fix error due to which the layout descriptions would not appear in the KeyboardBar

Revision history for this message
Niklas Wenzel (nikwen) wrote :

Fixed now. :)

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Niklas Wenzel (nikwen) wrote :

Thanks for merging. :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.terminal.pot'
2--- po/com.ubuntu.terminal.pot 2015-08-02 13:04:57 +0000
3+++ po/com.ubuntu.terminal.pot 2015-08-09 14:25:46 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: \n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2015-08-02 15:04+0200\n"
9+"POT-Creation-Date: 2015-08-09 16:01+0200\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13@@ -57,6 +57,98 @@
14 msgid "Change Keyboard"
15 msgstr ""
16
17+#. TRANSLATORS: This a keyboard layout name
18+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:18
19+msgid "Control Keys"
20+msgstr ""
21+
22+#. TRANSLATORS: This a keyboard layout name
23+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:21
24+msgid "Function Keys"
25+msgstr ""
26+
27+#. TRANSLATORS: This a keyboard layout name
28+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:24
29+msgid "Scroll Keys"
30+msgstr ""
31+
32+#. TRANSLATORS: This a keyboard layout name
33+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:27
34+msgid "Command Keys"
35+msgstr ""
36+
37+#. TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
38+#. TRANSLATORS: This is the name of the Control key. All letters should be uppercase!
39+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:35
40+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:61
41+msgid "CTRL"
42+msgstr ""
43+
44+#. TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
45+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:38
46+msgid "FNS"
47+msgstr ""
48+
49+#. TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
50+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:41
51+msgid "SCR"
52+msgstr ""
53+
54+#. TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
55+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:44
56+msgid "CMD"
57+msgstr ""
58+
59+#. TRANSLATORS: This is the name of the Alt key. All letters should be uppercase!
60+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:64
61+msgid "ALT"
62+msgstr ""
63+
64+#. TRANSLATORS: This is the name of the Shift key. All letters should be uppercase!
65+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:67
66+msgid "SHIFT"
67+msgstr ""
68+
69+#. TRANSLATORS: This is the name of the Escape key. All letters should be uppercase!
70+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:80
71+msgid "ESC"
72+msgstr ""
73+
74+#. TRANSLATORS: This is the name of the Page Up key. All letters should be uppercase!
75+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:83
76+msgid "PG_UP"
77+msgstr ""
78+
79+#. TRANSLATORS: This is the name of the Page Down key. All letters should be uppercase!
80+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:86
81+msgid "PG_DN"
82+msgstr ""
83+
84+#. TRANSLATORS: This is the name of the Delete key. All letters should be uppercase!
85+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:89
86+msgid "DEL"
87+msgstr ""
88+
89+#. TRANSLATORS: This is the name of the Home key. All letters should be uppercase!
90+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:92
91+msgid "HOME"
92+msgstr ""
93+
94+#. TRANSLATORS: This is the name of the End key. All letters should be uppercase!
95+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:95
96+msgid "END"
97+msgstr ""
98+
99+#. TRANSLATORS: This is the name of the Tab key. All letters should be uppercase!
100+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:98
101+msgid "TAB"
102+msgstr ""
103+
104+#. TRANSLATORS: This is the name of the Enter key. All letters should be uppercase!
105+#: ../src/app/qml/KeyboardRows/JsonTranslator.qml:101
106+msgid "ENTER"
107+msgstr ""
108+
109 #: ../src/app/qml/LayoutsPage.qml:27 ../src/app/qml/SettingsPage.qml:36
110 msgid "Layouts"
111 msgstr ""
112
113=== added file 'src/app/qml/KeyboardRows/JsonTranslator.qml'
114--- src/app/qml/KeyboardRows/JsonTranslator.qml 1970-01-01 00:00:00 +0000
115+++ src/app/qml/KeyboardRows/JsonTranslator.qml 2015-08-09 14:25:46 +0000
116@@ -0,0 +1,115 @@
117+import QtQuick 2.4
118+import Ubuntu.Components 1.2
119+
120+Item {
121+
122+ // Enum for translation types
123+ readonly property int name: 0
124+ readonly property int shortName: 1
125+ readonly property int modifier: 2
126+ readonly property int key: 3
127+
128+ // The first parameter has to be one of the readonly properties above
129+ function getTranslatedNameById(type, id) {
130+ switch(type) {
131+ case name:
132+ if (id === "ctrl_keys") {
133+ // TRANSLATORS: This a keyboard layout name
134+ return i18n.tr("Control Keys");
135+ } else if (id === "fn_keys") {
136+ // TRANSLATORS: This a keyboard layout name
137+ return i18n.tr("Function Keys");
138+ } else if (id === "scroll_keys") {
139+ // TRANSLATORS: This a keyboard layout name
140+ return i18n.tr("Scroll Keys");
141+ } else if (id === "simple_cmds") {
142+ // TRANSLATORS: This a keyboard layout name
143+ return i18n.tr("Command Keys");
144+ }
145+
146+ return "";
147+ case shortName:
148+ var translation = "";
149+ if (id === "ctrl_keys") {
150+ // TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
151+ translation = i18n.tr("CTRL");
152+ } else if (id === "fn_keys") {
153+ // TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
154+ translation = i18n.tr("FNS");
155+ } else if (id === "scroll_keys") {
156+ // TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
157+ translation = i18n.tr("SCR");
158+ } else if (id === "simple_cmds") {
159+ // TRANSLATORS: This the short display name of a keyboard layout. It should be no longer than 4 characters!
160+ translation = i18n.tr("CMD");
161+ }
162+
163+ if (translation !== "") {
164+ // Shorten the string if the translation is longer than 4 characters
165+ if (translation.length <= 4) {
166+ return translation;
167+ } else {
168+ return translation.substring(0, 4);
169+ }
170+ }
171+
172+ return "";
173+ case modifier:
174+ var translation = "";
175+ if (id === "Control") {
176+ // TRANSLATORS: This is the name of the Control key. All letters should be uppercase!
177+ translation = i18n.tr("CTRL");
178+ } else if (id === "Alt") {
179+ // TRANSLATORS: This is the name of the Alt key. All letters should be uppercase!
180+ translation = i18n.tr("ALT");
181+ } else if (id === "Shift") {
182+ // TRANSLATORS: This is the name of the Shift key. All letters should be uppercase!
183+ translation = i18n.tr("SHIFT");
184+ }
185+
186+ if (translation !== "") {
187+ // Always return the translation in uppercase letters
188+ return translation.toUpperCase();
189+ }
190+
191+ return id;
192+ case key:
193+ var translation = "";
194+ if (id === "esc_key") {
195+ // TRANSLATORS: This is the name of the Escape key. All letters should be uppercase!
196+ translation = i18n.tr("ESC");
197+ } else if (id === "pg_up_key") {
198+ // TRANSLATORS: This is the name of the Page Up key. All letters should be uppercase!
199+ translation = i18n.tr("PG_UP");
200+ } else if (id === "pg_dn_key") {
201+ // TRANSLATORS: This is the name of the Page Down key. All letters should be uppercase!
202+ translation = i18n.tr("PG_DN");
203+ } else if (id === "del_key") {
204+ // TRANSLATORS: This is the name of the Delete key. All letters should be uppercase!
205+ translation = i18n.tr("DEL");
206+ } else if (id === "home_key") {
207+ // TRANSLATORS: This is the name of the Home key. All letters should be uppercase!
208+ translation = i18n.tr("HOME");
209+ } else if (id === "end_key") {
210+ // TRANSLATORS: This is the name of the End key. All letters should be uppercase!
211+ translation = i18n.tr("END");
212+ } else if (id === "tab_key") {
213+ // TRANSLATORS: This is the name of the Tab key. All letters should be uppercase!
214+ translation = i18n.tr("TAB");
215+ } else if (id === "enter_key") {
216+ // TRANSLATORS: This is the name of the Enter key. All letters should be uppercase!
217+ translation = i18n.tr("ENTER");
218+ }
219+
220+ if (translation !== "") {
221+ // Always return the translation in uppercase letters
222+ return translation.toUpperCase();
223+ }
224+
225+ return id;
226+ default:
227+ return "";
228+ }
229+ }
230+
231+}
232
233=== modified file 'src/app/qml/KeyboardRows/KeyboardLayout.qml'
234--- src/app/qml/KeyboardRows/KeyboardLayout.qml 2015-07-13 20:25:21 +0000
235+++ src/app/qml/KeyboardRows/KeyboardLayout.qml 2015-08-09 14:25:46 +0000
236@@ -7,6 +7,8 @@
237 id: keyboardRow
238 keyWidth: units.gu(5)
239
240+ readonly property variant modifiers: ["Control", "Alt", "Shift"]
241+
242 // This label is used to compute the maximum width of all the controls.
243 Label {
244 id: hiddenLabel
245@@ -23,7 +25,7 @@
246 function createActionString(action) {
247 switch(action.type){
248 case "key":
249- return createKeyActionString(action.key, action.mod, action.text);
250+ return createKeyActionString(action.key, action.mod, action.text, action.id);
251 case "string":
252 return createStringActionString(action.string, action.text);
253 }
254@@ -42,12 +44,11 @@
255 return result + "]";
256 }
257
258- function createKeyActionString(key, mod, text) {
259- if (["Control", "Alt", "Shift"].indexOf(mod) === -1)
260+ function createKeyActionString(key, mod, text, id) {
261+ if (modifiers.indexOf(mod) === -1)
262 mod = "No";
263
264- var textString = text ? "text: \"" + text + "\";" : "";
265- return "Action { " + textString + " onTriggered: simulateKey(Qt.Key_"+ key + ", Qt." + mod + "Modifier); }";
266+ return "Action { text: \"" + createKeyText(key, mod, text, id) + "\"; onTriggered: simulateKey(Qt.Key_"+ key + ", Qt." + mod + "Modifier); }";
267 }
268
269 function createStringActionString(string, text) {
270@@ -68,6 +69,17 @@
271 return objectString;
272 }
273
274+ function createKeyText(key, mod, text, id) {
275+ if (id) {
276+ return translator.getTranslatedNameById(translator.key, id);
277+ } else if (text) {
278+ return text;
279+ } else if (key) {
280+ return ((mod && modifiers.indexOf(mod) !== -1) ? translator.getTranslatedNameById(translator.modifier, mod) + "+" : "") + key;
281+ } else
282+ return "";
283+ }
284+
285 function loadProfile(profileObject) {
286 dropProfile();
287
288@@ -76,28 +88,38 @@
289 // This function might raise exceptions which are handled in KeyboardBar.qml
290 var profile = profileObject;
291
292- name = profile.name;
293- short_name = profile.short_name;
294+ name = "";
295+ short_name = "";
296+ if (profile.id) {
297+ name = translator.getTranslatedNameById(translator.name, profile.id);
298+ short_name = translator.getTranslatedNameById(translator.shortName, profile.id);
299+ }
300+ if (name === "")
301+ name = profile.name;
302+ if (short_name === "")
303+ short_name = profile.short_name;
304
305 var layoutModel = []
306 for (var i = 0; i < profile.buttons.length; i++) {
307 var button = profile.buttons[i];
308+ var keyText = createKeyText(button.main_action.key, button.main_action.mod, button.main_action.text, button.main_action.id);
309 var mainActionString = createActionString(button.main_action);
310
311 var otherActionsString = button.other_actions
312 ? createOtherActionsString(button.other_actions)
313 : "[]";
314
315- var entryString = createEntryString(button.main_action.text, mainActionString, otherActionsString);
316+ var entryString = createEntryString(keyText, mainActionString, otherActionsString);
317
318 layoutModel.push(Qt.createQmlObject(entryString, keyboardRow));
319
320- hiddenLabel.text = button.main_action.text;
321+ hiddenLabel.text = keyText;
322 maxWidth = Math.max(hiddenLabel.width, maxWidth);
323 }
324
325 keyWidth = maxWidth + units.gu(3);
326 model = layoutModel;
327 }
328+
329 Component.onDestruction: dropProfile();
330 }
331
332=== modified file 'src/app/qml/KeyboardRows/Layouts/ControlKeys.json'
333--- src/app/qml/KeyboardRows/Layouts/ControlKeys.json 2015-04-21 09:44:54 +0000
334+++ src/app/qml/KeyboardRows/Layouts/ControlKeys.json 2015-08-09 14:25:46 +0000
335@@ -1,12 +1,10 @@
336 {
337- "name" : "Control Keys",
338- "short_name" : "CTRL",
339+ "id" : "ctrl_keys",
340
341 "buttons": [
342 {
343 "main_action" : {
344 "type": "key",
345- "text" : "CTRL+R",
346 "key" : "R",
347 "mod" : "Control"
348 }
349@@ -14,7 +12,6 @@
350 {
351 "main_action" : {
352 "type": "key",
353- "text" : "CTRL+C",
354 "key" : "C",
355 "mod" : "Control"
356 }
357@@ -22,7 +19,6 @@
358 {
359 "main_action" : {
360 "type": "key",
361- "text" : "CTRL+A",
362 "key" : "A",
363 "mod" : "Control"
364 }
365@@ -30,7 +26,6 @@
366 {
367 "main_action" : {
368 "type": "key",
369- "text" : "CTRL+Z",
370 "key" : "Z",
371 "mod" : "Control"
372 }
373@@ -38,7 +33,6 @@
374 {
375 "main_action" : {
376 "type": "key",
377- "text" : "CTRL+D",
378 "key" : "D",
379 "mod" : "Control"
380 }
381
382=== modified file 'src/app/qml/KeyboardRows/Layouts/FunctionKeys.json'
383--- src/app/qml/KeyboardRows/Layouts/FunctionKeys.json 2015-02-03 21:43:38 +0000
384+++ src/app/qml/KeyboardRows/Layouts/FunctionKeys.json 2015-08-09 14:25:46 +0000
385@@ -1,96 +1,83 @@
386 {
387- "name" : "Function Keys",
388- "short_name" : "FNS",
389+ "id" : "fn_keys",
390
391 "buttons": [
392 {
393 "main_action" : {
394 "type": "key",
395- "text" : "ESC",
396+ "id" : "esc_key",
397 "key" : "Escape"
398 }
399 },
400 {
401 "main_action" : {
402 "type": "key",
403- "text" : "F1",
404 "key" : "F1"
405 }
406 },
407 {
408 "main_action" : {
409 "type": "key",
410- "text" : "F2",
411 "key" : "F2"
412 }
413 },
414 {
415 "main_action" : {
416 "type": "key",
417- "text" : "F3",
418 "key" : "F3"
419 }
420 },
421 {
422 "main_action" : {
423 "type": "key",
424- "text" : "F4",
425 "key" : "F4"
426 }
427 },
428 {
429 "main_action" : {
430 "type": "key",
431- "text" : "F5",
432 "key" : "F5"
433 }
434 },
435 {
436 "main_action" : {
437 "type": "key",
438- "text" : "F6",
439 "key" : "F6"
440 }
441 },
442 {
443 "main_action" : {
444 "type": "key",
445- "text" : "F7",
446 "key" : "F7"
447 }
448 },
449 {
450 "main_action" : {
451 "type": "key",
452- "text" : "F8",
453 "key" : "F8"
454 }
455 },
456 {
457 "main_action" : {
458 "type": "key",
459- "text" : "F9",
460 "key" : "F9"
461 }
462 },
463 {
464 "main_action" : {
465 "type": "key",
466- "text" : "F10",
467- "key" : "F10"
468- }
469- },
470- {
471- "main_action" : {
472- "type": "key",
473- "text" : "F10",
474- "key" : "F10"
475- }
476- },
477- {
478- "main_action" : {
479- "type": "key",
480- "text" : "F11",
481+ "key" : "F10"
482+ }
483+ },
484+ {
485+ "main_action" : {
486+ "type": "key",
487+ "key" : "F10"
488+ }
489+ },
490+ {
491+ "main_action" : {
492+ "type": "key",
493 "key" : "F11"
494 }
495 }
496
497=== modified file 'src/app/qml/KeyboardRows/Layouts/Nano.json'
498--- src/app/qml/KeyboardRows/Layouts/Nano.json 2015-03-25 21:08:22 +0000
499+++ src/app/qml/KeyboardRows/Layouts/Nano.json 2015-08-09 14:25:46 +0000
500@@ -6,7 +6,6 @@
501 {
502 "main_action" : {
503 "type": "key",
504- "text" : "CTRL+G",
505 "key" : "G",
506 "mod" : "Control"
507 }
508@@ -14,7 +13,6 @@
509 {
510 "main_action" : {
511 "type": "key",
512- "text" : "CTRL+O",
513 "key" : "O",
514 "mod" : "Control"
515 }
516@@ -22,7 +20,6 @@
517 {
518 "main_action" : {
519 "type": "key",
520- "text" : "CTRL+R",
521 "key" : "R",
522 "mod" : "Control"
523 }
524@@ -30,7 +27,6 @@
525 {
526 "main_action" : {
527 "type": "key",
528- "text" : "CTRL+Y",
529 "key" : "Y",
530 "mod" : "Control"
531 }
532@@ -38,7 +34,6 @@
533 {
534 "main_action" : {
535 "type": "key",
536- "text" : "CTRL+K",
537 "key" : "K",
538 "mod" : "Control"
539 }
540@@ -46,7 +41,6 @@
541 {
542 "main_action" : {
543 "type": "key",
544- "text" : "CTRL+C",
545 "key" : "C",
546 "mod" : "Control"
547 }
548@@ -55,7 +49,6 @@
549 {
550 "main_action" : {
551 "type": "key",
552- "text" : "CTRL+X",
553 "key" : "X",
554 "mod" : "Control"
555 }
556@@ -63,7 +56,6 @@
557 {
558 "main_action" : {
559 "type": "key",
560- "text" : "CTRL+J",
561 "key" : "J",
562 "mod" : "Control"
563 }
564@@ -71,7 +63,6 @@
565 {
566 "main_action" : {
567 "type": "key",
568- "text" : "CTRL+W",
569 "key" : "W",
570 "mod" : "Control"
571 }
572@@ -79,7 +70,6 @@
573 {
574 "main_action" : {
575 "type": "key",
576- "text" : "CTRL+V",
577 "key" : "V",
578 "mod" : "Control"
579 }
580@@ -87,7 +77,6 @@
581 {
582 "main_action" : {
583 "type": "key",
584- "text" : "CTRL+U",
585 "key" : "U",
586 "mod" : "Control"
587 }
588@@ -95,7 +84,6 @@
589 {
590 "main_action" : {
591 "type": "key",
592- "text" : "CTRL+T",
593 "key" : "T",
594 "mod" : "Control"
595 }
596
597=== modified file 'src/app/qml/KeyboardRows/Layouts/ScrollKeys.json'
598--- src/app/qml/KeyboardRows/Layouts/ScrollKeys.json 2015-06-02 09:49:00 +0000
599+++ src/app/qml/KeyboardRows/Layouts/ScrollKeys.json 2015-08-09 14:25:46 +0000
600@@ -1,54 +1,53 @@
601 {
602- "name" : "Scroll Keys",
603- "short_name" : "SCR",
604+ "id" : "scroll_keys",
605
606 "buttons": [
607 {
608 "main_action" : {
609 "type": "key",
610- "text" : "PG_UP",
611+ "id" : "pg_up_key",
612 "key" : "PageUp"
613 }
614 },
615 {
616 "main_action" : {
617 "type": "key",
618- "text" : "PG_DN",
619+ "id" : "pg_dn_key",
620 "key" : "PageDown"
621 }
622 },
623 {
624 "main_action" : {
625 "type": "key",
626- "text" : "DEL",
627+ "id" : "del_key",
628 "key" : "Delete"
629 }
630 },
631 {
632 "main_action" : {
633 "type": "key",
634- "text" : "HOME",
635+ "id" : "home_key",
636 "key" : "Home"
637 }
638 },
639 {
640 "main_action" : {
641 "type": "key",
642- "text" : "END",
643+ "id" : "end_key",
644 "key" : "End"
645 }
646 },
647 {
648 "main_action" : {
649 "type": "key",
650- "text" : "TAB",
651+ "id" : "tab_key",
652 "key" : "Tab"
653 }
654 },
655 {
656 "main_action" : {
657 "type": "key",
658- "text" : "ENTER",
659+ "id" : "enter_key",
660 "key" : "Enter"
661 }
662 },
663
664=== modified file 'src/app/qml/KeyboardRows/Layouts/SimpleCommands.json'
665--- src/app/qml/KeyboardRows/Layouts/SimpleCommands.json 2015-03-06 11:05:22 +0000
666+++ src/app/qml/KeyboardRows/Layouts/SimpleCommands.json 2015-08-09 14:25:46 +0000
667@@ -1,6 +1,5 @@
668 {
669- "name" : "Commands Key",
670- "short_name" : "CMD",
671+ "id" : "simple_cmds",
672
673 "buttons": [
674 {
675
676=== modified file 'src/app/qml/KeyboardRows/jsonParser.js'
677--- src/app/qml/KeyboardRows/jsonParser.js 2015-02-14 12:46:38 +0000
678+++ src/app/qml/KeyboardRows/jsonParser.js 2015-08-09 14:25:46 +0000
679@@ -27,8 +27,16 @@
680 raiseException("type is missing in", actionObject);
681 if (!isAllowed(actionObject.type, ["key", "string"]))
682 raiseException("type must be either key or string in", actionObject);
683- if (!actionObject.text)
684- raiseException("text is missing in", actionObject);
685+ if (!(actionObject.type === "key" ? actionObject.key : actionObject.string))
686+ raiseException(actionObject.type + " is missing in", actionObject);
687+ if (actionObject.id && actionObject.text)
688+ raiseException("Should not define id and text together in", actionObject);
689+ if (!actionObject.id && !actionObject.text && !(actionObject.type === "key" && actionObject.key)) // We can also build the text from the key
690+ raiseException("text or id is missing in", actionObject);
691+
692+
693+ // No need to check for "if (!actionObject.id && !actionObject.text)" as we will
694+ // build the displayed text from the keys in that case
695
696 switch (actionObject.type) {
697 case "key":
698@@ -58,10 +66,18 @@
699 }
700
701 function validateLayout(layoutObject) {
702- if (!layoutObject.name)
703- raiseException("name is missing in ", layoutObject);
704- if (!layoutObject.short_name)
705- raiseException("short_name is missing in", layoutObject);
706+ if (!layoutObject.id) {
707+ if (!layoutObject.name)
708+ raiseException("name or id is missing in", layoutObject);
709+ if (!layoutObject.short_name)
710+ raiseException("short_name or id is missing in", layoutObject);
711+ } else {
712+ if (layoutObject.name)
713+ raiseException("Should not define id and name together in", layoutObject);
714+ if (layoutObject.short_name)
715+ raiseException("Should not define id and short_name together in", layoutObject);
716+ }
717+
718 if (!layoutObject.buttons)
719 raiseException("buttons is missing in", layoutObject);
720
721
722=== modified file 'src/app/qml/TerminalSettings.qml'
723--- src/app/qml/TerminalSettings.qml 2015-07-13 20:25:21 +0000
724+++ src/app/qml/TerminalSettings.qml 2015-08-09 14:25:46 +0000
725@@ -50,7 +50,7 @@
726 } catch (e) {}
727
728 function isProfileVisible(profilePath) {
729- return !(visibleProfiles[profilePath] == false);
730+ return !(visibleProfiles[profilePath] === false);
731 }
732
733 for (var i = 0; i < keyboardLayouts.length; i++) {
734@@ -60,12 +60,18 @@
735 try {
736 var profileObject = Parser.parseJson(fileIO.read(filePath));
737
738+ var name = "";
739+ if (profileObject.id)
740+ name = translator.getTranslatedNameById(translator.name, profileObject.id);
741+ if (name === "")
742+ name = profileObject.name;
743+
744 profilesList.append(
745 {
746 file: filePath,
747 profileVisible: isVisible,
748 object: profileObject,
749- name: profileObject.name
750+ name: name
751 });
752 } catch (e) {
753 console.error("Error in profile", filePath);
754
755=== modified file 'src/app/qml/ubuntu-terminal-app.qml'
756--- src/app/qml/ubuntu-terminal-app.qml 2015-07-13 20:25:21 +0000
757+++ src/app/qml/ubuntu-terminal-app.qml 2015-08-09 14:25:46 +0000
758@@ -1,6 +1,7 @@
759 import QtQuick 2.4
760 import QtGraphicalEffects 1.0
761 import Ubuntu.Components 1.2
762+import "KeyboardRows"
763
764 import QMLTermWidget 1.0
765
766@@ -31,6 +32,10 @@
767 Component.onCompleted: addTab();
768 }
769
770+ JsonTranslator {
771+ id: translator
772+ }
773+
774 PageStack {
775 id: pageStack
776 Component.onCompleted: push(terminalPage)

Subscribers

People subscribed via source and target branches