Skip to content

Commit

Permalink
Localize keyboard button texts
Browse files Browse the repository at this point in the history
(see #4090)
  • Loading branch information
bhousel committed Jun 6, 2017
1 parent 1341c80 commit c22fa60
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 17 deletions.
21 changes: 20 additions & 1 deletion data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,27 @@ en:
start: "Start mapping!"
shortcuts:
title: "Keyboard shortcuts"
key:
alt: Alt
backspace: Backspace
cmd: Cmd
ctrl: Ctrl
delete: Delete
del: Del
end: End
enter: Enter
esc: Esc
home: Home
option: Option
pause: Pause
pgdn: PgDn
pgup: PgUp
return: Return
shift: Shift
space: Space
gesture:
drag: drag
or: "-or-"
drag: drag
browsing:
title: "Browsing"
navigation:
Expand Down
8 changes: 4 additions & 4 deletions data/shortcuts.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}, {
"modifiers": [""],
"shortcuts": ["Left-click"],
"gesture": "shortcuts.drag",
"gesture": "shortcuts.gesture.drag",
"text": "shortcuts.browsing.selecting.lasso"
}, {
"shortcuts": [],
Expand All @@ -90,7 +90,7 @@
"section": "with_selected",
"text": "shortcuts.browsing.with_selected.title"
}, {
"shortcuts": ["Right-click", "Space"],
"shortcuts": ["Right-click", "shortcuts.key.space"],
"text": "shortcuts.browsing.with_selected.edit_menu"
}, {
"modifiers": [""],
Expand All @@ -114,7 +114,7 @@
"shortcuts": ["}", ""],
"text": "shortcuts.browsing.vertex_selected.last"
}, {
"shortcuts": ["\\", "Pause"],
"shortcuts": ["\\", "shortcuts.key.pause"],
"text": "shortcuts.browsing.vertex_selected.change_parent"
}

Expand All @@ -140,7 +140,7 @@
"shortcuts": ["3"],
"text": "shortcuts.editing.drawing.add_area"
}, {
"shortcuts": ["Space"],
"shortcuts": ["shortcuts.key.space"],
"text": "shortcuts.editing.drawing.place_point"
}, {
"shortcuts": [""],
Expand Down
23 changes: 22 additions & 1 deletion dist/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,29 @@
},
"shortcuts": {
"title": "Keyboard shortcuts",
"key": {
"alt": "Alt",
"backspace": "Backspace",
"cmd": "Cmd",
"ctrl": "Ctrl",
"delete": "Delete",
"del": "Del",
"end": "End",
"enter": "Enter",
"esc": "Esc",
"home": "Home",
"option": "Option",
"pause": "Pause",
"pgdn": "PgDn",
"pgup": "PgUp",
"return": "Return",
"shift": "Shift",
"space": "Space"
},
"gesture": {
"drag": "drag"
},
"or": "-or-",
"drag": "drag",
"browsing": {
"title": "Browsing",
"navigation": {
Expand Down
23 changes: 12 additions & 11 deletions modules/ui/cmd.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { t } from '../util/locale';
import { utilDetect } from '../util/detect';

// Translate a MacOS key command into the appropriate Windows/Linux equivalent.
Expand Down Expand Up @@ -41,17 +42,17 @@ uiCmd.display = function(code) {
var detected = utilDetect();
var mac = (detected.os === 'mac');
var replacements = {
'⌘': mac ? '⌘ Cmd' : 'Ctrl',
'⇧': mac ? '⇧ Shift' : 'Shift',
'⌥': mac ? '⌥ Option' : 'Alt',
'⌫': mac ? '⌫ Delete' : 'Backspace',
'⌦': mac ? '⌦ Del' : 'Del',
'↖': mac ? '↖ PgUp' : 'PgUp',
'↘': mac ? '↘ PgDn' : 'PgDn',
'⇞': mac ? '⇞ Home' : 'Home',
'⇟': mac ? '⇟ End' : 'End',
'↵': mac ? '↵ Return' : 'Enter',
'⎋': mac ? '⎋ Esc' : 'Esc',
'⌘': mac ? '⌘ ' + t('shortcuts.key.cmd') : t('shortcuts.key.ctrl'),
'⇧': mac ? '⇧ ' + t('shortcuts.key.shift') : t('shortcuts.key.shift'),
'⌥': mac ? '⌥ ' + t('shortcuts.key.option') : t('shortcuts.key.alt'),
'⌫': mac ? '⌫ ' + t('shortcuts.key.delete') : t('shortcuts.key.backspace'),
'⌦': mac ? '⌦ ' + t('shortcuts.key.del') : t('shortcuts.key.del'),
'↖': mac ? '↖ ' + t('shortcuts.key.pgup') : t('shortcuts.key.pgup'),
'↘': mac ? '↘ ' + t('shortcuts.key.pgdn') : t('shortcuts.key.pgdn'),
'⇞': mac ? '⇞ ' + t('shortcuts.key.home') : t('shortcuts.key.home'),
'⇟': mac ? '⇟ ' + t('shortcuts.key.end') : t('shortcuts.key.end'),
'↵': mac ? '↵ ' + t('shortcuts.key.return') : t('shortcuts.key.enter'),
'⎋': mac ? '⎋ ' + t('shortcuts.key.esc') : t('shortcuts.key.esc'),
};

return replacements[code] || code;
Expand Down

0 comments on commit c22fa60

Please sign in to comment.