feat(i18n): add multi-language support (ja/ko/vi/ru/zh-TW) with system auto-detection

- Extend AppLanguage to 7 locales: zh-CN, zh-TW, en, ja, ko, vi, ru
- Auto-detect system language via navigator.languages; fallback to English
- Add BCP47 locale mapping for date formatting and sorting
- Create 50 translation JSON files (5 languages × 10 namespaces, 1137 keys each)
- Update language selector with native language names
- Extend locale key parity test to cover all 7 languages (70 assertions)
- Add VNC/RDP desktop, serial terminal, AI agent, port forwarding, and SFTP features
- Add credential encryption, host metrics, session backup crypto, and zmodem bridge
- Update Rust backend: desktop services, host metrics, SSH/SFTP enhancements
This commit is contained in:
Logan.Li committed 2026-08-12 00:07:48 +08:00
1 parent fea6d8db04
commit b0d0e3a5f3
301 files changed
+28002 -2705

No files matched your search

+16 -1
View File
@@ -4,8 +4,16 @@
import '@testing-library/jest-dom'
import { vi } from 'vitest'
import i18n from '../src/i18n'
import { useSettingsStore } from '../src/stores/settingsStore'
import type { DesktopApiContract } from '../src/desktop'
void i18n.changeLanguage('zh-CN')
useSettingsStore.setState((state) => ({
settings: { ...state.settings, language: 'zh-CN' },
isLoaded: state.isLoaded,
}))
// Mock native desktop API
export const mockDesktopApi: DesktopApiContract = {
takePendingSshLinks: vi.fn().mockResolvedValue([]),
@@ -16,14 +24,17 @@ export const mockDesktopApi: DesktopApiContract = {
nativeBackend: 'Tauri 2 / Rust',
sshBackend: 'libssh2 / ssh2 0.9',
dataPath: '/tmp/opsxshell-data.json',
credentialPath: '/tmp/.opsxshsell/master.key',
credentialPath: '/tmp/.opsxshell/master.key',
}),
// SSH
sshConnect: vi.fn().mockResolvedValue({ success: true, connectionId: 'test-conn-1' }),
sshDisconnect: vi.fn().mockResolvedValue({ success: true }),
sshExec: vi.fn().mockResolvedValue({ success: true, result: '', exitCode: 0 }),
sshExecCancel: vi.fn().mockResolvedValue({ success: true }),
sshHostMetrics: vi.fn().mockResolvedValue({ success: true, metrics: { disks: [] } }),
sshKeepalive: vi.fn().mockResolvedValue({ success: true }),
sshCreateShell: vi.fn().mockResolvedValue({ success: true, shellId: 'test-shell-1' }),
sshShellOpenOutput: vi.fn().mockResolvedValue({ success: true, data: [] }),
sshShellWrite: vi.fn().mockResolvedValue({ success: true }),
sshShellResize: vi.fn().mockResolvedValue({ success: true }),
sshCloseShell: vi.fn().mockResolvedValue({ success: true }),
@@ -37,7 +48,9 @@ export const mockDesktopApi: DesktopApiContract = {
sftpConnect: vi.fn().mockResolvedValue({ success: true, sftpId: 'test-sftp-1' }),
sftpListDirectory: vi.fn().mockResolvedValue({ success: true, files: [] }),
sftpUpload: vi.fn().mockResolvedValue({ success: true }),
sftpUploadDir: vi.fn().mockResolvedValue({ success: true }),
sftpDownload: vi.fn().mockResolvedValue({ success: true }),
sftpDownloadDir: vi.fn().mockResolvedValue({ success: true }),
sftpRename: vi.fn().mockResolvedValue({ success: true }),
sftpDelete: vi.fn().mockResolvedValue({ success: true }),
sftpMkdir: vi.fn().mockResolvedValue({ success: true }),
@@ -106,6 +119,7 @@ export const mockDesktopApi: DesktopApiContract = {
localMkdir: vi.fn().mockResolvedValue({ success: true }),
getHomePath: vi.fn().mockResolvedValue({ success: true, path: '/Users/test' }),
getDownloadsPath: vi.fn().mockResolvedValue('/Users/test/Downloads'),
openDownloadsFolder: vi.fn().mockResolvedValue(undefined),
// App
getVersion: vi.fn().mockResolvedValue('1.0.0'),
@@ -132,6 +146,7 @@ export const mockDesktopApi: DesktopApiContract = {
localResize: vi.fn().mockResolvedValue({ success: true }),
localKill: vi.fn().mockResolvedValue({ success: true }),
onLocalData: vi.fn(),
onLocalExit: vi.fn(),
// Event listeners
onShellData: vi.fn(),