fix(mobile): keep terminal labels canonical

This commit is contained in:
Brennan Benson
2026-08-01 02:10:22 -07:00
parent 96a796365f
commit defce9c74a
2 changed files with 42 additions and 41 deletions
@@ -2,12 +2,12 @@ import { t } from '@/i18n/mobile-i18n'
import type { TerminalAccessoryKey } from './terminal-accessory-keys'
export const TERMINAL_ACCESSORY_KEYS: TerminalAccessoryKey[] = [
{ id: 'escape', label: 'Esc', bytes: '\x1b', accessibilityLabel: t('m.jHe6UUU') },
{ id: 'tab', label: 'Tab', bytes: '\t', accessibilityLabel: t('m.hM5KUAw') },
{ id: 'enter', label: 'Enter', bytes: '\r', accessibilityLabel: t('m.9KFo5zM') },
{ id: 'escape', label: t('m.bNejRmQ'), bytes: '\x1b', accessibilityLabel: t('m.jHe6UUU') },
{ id: 'tab', label: t('m.hM5KUAw'), bytes: '\t', accessibilityLabel: t('m.hM5KUAw') },
{ id: 'enter', label: t('m.9KFo5zM'), bytes: '\r', accessibilityLabel: t('m.9KFo5zM') },
// Why: terminal apps recognize ESC [ Z as the reverse-tab sequence.
{ id: 'shiftTab', label: 'Shift+Tab', bytes: '\x1b[Z', accessibilityLabel: t('m.p7_d2FU') },
{ id: 'space', label: 'Space', bytes: ' ', accessibilityLabel: t('m.l6KJT3M') },
{ id: 'shiftTab', label: t('m.S9DH8y4'), bytes: '\x1b[Z', accessibilityLabel: t('m.p7_d2FU') },
{ id: 'space', label: t('m.l6KJT3M'), bytes: ' ', accessibilityLabel: t('m.l6KJT3M') },
{
id: 'backspace',
label: '⌫',
@@ -17,7 +17,7 @@ export const TERMINAL_ACCESSORY_KEYS: TerminalAccessoryKey[] = [
},
{
id: 'delete',
label: 'Del',
label: t('m.gmy3A7M'),
bytes: '\x1b[3~',
accessibilityLabel: t('m.fNgDk9o'),
repeatable: true
@@ -50,13 +50,13 @@ export const TERMINAL_ACCESSORY_KEYS: TerminalAccessoryKey[] = [
accessibilityLabel: t('m.v5WSGO0'),
repeatable: true
},
{ id: 'ctrlC', label: 'Ctrl+C', bytes: '\x03', accessibilityLabel: t('m.AzHoQzM') },
{ id: 'ctrlD', label: 'Ctrl+D', bytes: '\x04', accessibilityLabel: t('m.PBPnPeQ') },
{ id: 'ctrlL', label: 'Ctrl+L', bytes: '\x0c', accessibilityLabel: t('m.Eqaj8oY') },
{ id: 'ctrlZ', label: 'Ctrl+Z', bytes: '\x1a', accessibilityLabel: t('m.hqWfNmA') },
{ id: 'ctrlR', label: 'Ctrl+R', bytes: '\x12', accessibilityLabel: t('m.mcvHf4o') },
{ id: 'ctrlA', label: 'Ctrl+A', bytes: '\x01', accessibilityLabel: t('m.CKFp_QM') },
{ id: 'ctrlE', label: 'Ctrl+E', bytes: '\x05', accessibilityLabel: t('m.0VWtVO8') },
{ id: 'ctrlW', label: 'Ctrl+W', bytes: '\x17', accessibilityLabel: t('m.Bd9qfdk') },
{ id: 'ctrlU', label: 'Ctrl+U', bytes: '\x15', accessibilityLabel: t('m.HrWsdDM') }
{ id: 'ctrlC', label: t('m.ke03J5M'), bytes: '\x03', accessibilityLabel: t('m.AzHoQzM') },
{ id: 'ctrlD', label: t('m.vFYSo0s'), bytes: '\x04', accessibilityLabel: t('m.PBPnPeQ') },
{ id: 'ctrlL', label: t('m.R6ZcIz8'), bytes: '\x0c', accessibilityLabel: t('m.Eqaj8oY') },
{ id: 'ctrlZ', label: t('m.NIdsbYo'), bytes: '\x1a', accessibilityLabel: t('m.hqWfNmA') },
{ id: 'ctrlR', label: t('m.a2Cb3GE'), bytes: '\x12', accessibilityLabel: t('m.mcvHf4o') },
{ id: 'ctrlA', label: t('m.u9q9lPQ'), bytes: '\x01', accessibilityLabel: t('m.CKFp_QM') },
{ id: 'ctrlE', label: t('m.5m_ucwE'), bytes: '\x05', accessibilityLabel: t('m.0VWtVO8') },
{ id: 'ctrlW', label: t('m.jVVj75Y'), bytes: '\x17', accessibilityLabel: t('m.Bd9qfdk') },
{ id: 'ctrlU', label: t('m.sL5fKGQ'), bytes: '\x15', accessibilityLabel: t('m.HrWsdDM') }
]
+27 -26
View File
@@ -1,4 +1,4 @@
import { t } from '@/i18n/mobile-i18n'
import { mobileI18n, t } from '@/i18n/mobile-i18n'
export { TERMINAL_ACCESSORY_KEYS } from './terminal-accessory-key-catalog'
export type TerminalAccessoryKey = {
id: string
@@ -28,12 +28,13 @@ export type TerminalShortcutSpecialKey = {
}
const ESC = '\x1b'
const canonicalTerminalLabel = mobileI18n.getFixedT('en')
export const TERMINAL_SHORTCUT_MODIFIER_LABELS: Readonly<Record<TerminalShortcutModifier, string>> =
{
ctrl: 'Ctrl',
alt: 'Alt',
shift: 'Shift'
ctrl: canonicalTerminalLabel('m.mthhwXw'),
alt: canonicalTerminalLabel('m.zN_6g9g'),
shift: canonicalTerminalLabel('m.lCZrWn4')
}
const MODIFIER_ORDER: TerminalShortcutModifier[] = ['ctrl', 'alt', 'shift']
@@ -79,33 +80,33 @@ const CTRL_PRINTABLE_BYTES: Record<string, string> = {
}
const SPECIAL_KEY_LABELS: Record<string, string> = {
escape: 'Esc',
tab: 'Tab',
enter: 'Enter',
escape: canonicalTerminalLabel('m.bNejRmQ'),
tab: canonicalTerminalLabel('m.hM5KUAw'),
enter: canonicalTerminalLabel('m.9KFo5zM'),
backspace: '⌫',
delete: 'Del',
insert: 'Ins',
delete: canonicalTerminalLabel('m.gmy3A7M'),
insert: canonicalTerminalLabel('m.bh9E9Gk'),
arrowUp: '↑',
arrowDown: '↓',
arrowLeft: '←',
arrowRight: '→',
home: 'Home',
end: 'End',
pageUp: 'PgUp',
pageDown: 'PgDn',
space: 'Space',
f1: 'F1',
f2: 'F2',
f3: 'F3',
f4: 'F4',
f5: 'F5',
f6: 'F6',
f7: 'F7',
f8: 'F8',
f9: 'F9',
f10: 'F10',
f11: 'F11',
f12: 'F12'
home: canonicalTerminalLabel('m.r2L-IvQ'),
end: canonicalTerminalLabel('m.6UajMWQ'),
pageUp: canonicalTerminalLabel('m.1qkhXPI'),
pageDown: canonicalTerminalLabel('m.Wt9qvqo'),
space: canonicalTerminalLabel('m.l6KJT3M'),
f1: canonicalTerminalLabel('m.wPNSaMQ'),
f2: canonicalTerminalLabel('m.5OQeDMc'),
f3: canonicalTerminalLabel('m.fNbslzw'),
f4: canonicalTerminalLabel('m.dMpOhHI'),
f5: canonicalTerminalLabel('m.MmdqLFU'),
f6: canonicalTerminalLabel('m.xOj4ngY'),
f7: canonicalTerminalLabel('m.EbNp-x4'),
f8: canonicalTerminalLabel('m.DR9i7SU'),
f9: canonicalTerminalLabel('m.rI3MEx0'),
f10: canonicalTerminalLabel('m.d6orzBg'),
f11: canonicalTerminalLabel('m.T7RTOC4'),
f12: canonicalTerminalLabel('m._dDm4ic')
}
const SPECIAL_KEY_ACCESSIBILITY_LABELS: Record<string, string> = {