Files
lms-fe/src/main/remoteShell.ts
T
chyoo d44180db67 feat: add Korean-English localization and light theme
Localize studio, curriculum, visualization and loading interfaces. Add persistent language and theme settings, refine module loading states, and normalize remote shell locales.
2026-09-29 13:27:11 +09:00

29 lines
1.2 KiB
TypeScript

function quote(value: string): string {
return `'${value.replace(/'/g, `'"'"'`)}'`
}
// SSH may forward LANG/LC_* through the user's SendEnv configuration.
// Undefined entries also remove inherited keys when merged by the command runner.
export function remoteShellEnvironment(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
const result = { ...env }
for (const key of Object.keys(result)) {
if (key === 'LANGUAGE' || key.startsWith('LC_')) result[key] = undefined
}
return { ...result, LANG: 'C', LC_ALL: 'C' }
}
export function remoteShellCommand(command: string): string {
const script = [
'selected_locale=C',
// Probe under C so an inherited, unavailable locale cannot break the probe.
'available_locales=$(locale -a 2>/dev/null) || available_locales=',
'for candidate in $available_locales; do',
' case "$candidate" in C.utf8|C.UTF-8) selected_locale=$candidate; break ;;',
' *utf8|*UTF-8|*utf-8) if [ "$selected_locale" = C ]; then selected_locale=$candidate; fi ;;',
' esac',
'done',
`exec env LANG="$selected_locale" LC_ALL="$selected_locale" LANGUAGE=C /bin/bash --noprofile --norc -c ${quote(command)}`,
].join('\n')
return `env LANG=C LC_ALL=C LANGUAGE=C /bin/sh -c ${quote(script)}`
}