mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
* convert iD.Detect() iife to a module * iD.Detect() should return loaded locale (except for 'en') (The previous code was a hack to replace the detected locale with the loaded locale. Now that Detect is a module, we can not replace the detected locale from external code, but we can have Detect() return the locale we really want)
35 lines
780 B
JavaScript
35 lines
780 B
JavaScript
import { Detect } from '../util/detect';
|
|
|
|
// Translate a MacOS key command into the appropriate Windows/Linux equivalent.
|
|
// For example, ⌘Z -> Ctrl+Z
|
|
export function cmd(code) {
|
|
var detected = Detect();
|
|
|
|
if (detected.os === 'mac') {
|
|
return code;
|
|
}
|
|
|
|
if (detected.os === 'win') {
|
|
if (code === '⌘⇧Z') return 'Ctrl+Y';
|
|
}
|
|
|
|
var result = '',
|
|
replacements = {
|
|
'⌘': 'Ctrl',
|
|
'⇧': 'Shift',
|
|
'⌥': 'Alt',
|
|
'⌫': 'Backspace',
|
|
'⌦': 'Delete'
|
|
};
|
|
|
|
for (var i = 0; i < code.length; i++) {
|
|
if (code[i] in replacements) {
|
|
result += replacements[code[i]] + '+';
|
|
} else {
|
|
result += code[i];
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|