Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(i18n): migrate to i18next with locale resources

hairyf164ec3935b13
diff --git a/package.json b/package.json
index 47a25280..9f7edcf4 100644
--- a/package.json
+++ b/package.json
@@ -17,9 +17,11 @@
},
"dependencies": {
"@tauri-apps/api": "^2.11.1",
+ "i18next": "^26.3.6",
"lucide-react": "^1.31.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
+ "react-i18next": "^17.0.11",
"tailwind-variants": "^3.3.1",
"valtio-define": "^1.4.1"
},
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 049ca123..cc762afb 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -16,6 +16,9 @@ importers:
'@tauri-apps/api':
specifier: ^2.11.1
version: 2.11.1
+ i18next:
+ specifier: ^26.3.6
+ version: 26.3.6([email protected])
lucide-react:
specifier: ^1.31.0
version: 1.31.0([email protected])
@@ -25,6 +28,9 @@ importers:
react-dom:
specifier: ^18.3.1
version: 18.3.1([email protected])
+ react-i18next:
+ specifier: ^17.0.11
tailwind-variants:
specifier: ^3.3.1
version: 3.3.1([email protected])
@@ -226,6 +232,10 @@ packages:
peerDependencies:
'@babel/core': ^7.0.0-0
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==}
+ engines: {node: '>=6.9.0'}
+
resolution: {integrity: sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==}
engines: {node: '>=6.9.0'}
@@ -1627,6 +1637,17 @@ packages:
resolution: {integrity: sha512-kig+rMn/QOVRvr7c86gQ8lWXq+Hkv6CbAH1hLu+RG338StTpE8Z0b44SDVaqVu7HGKf27frdmUYEs9hTUX/cLQ==}
+ resolution: {integrity: sha512-0zHsZJrK7S3K2aucXWL6ycoYJ/iNtIcFHC/nYQgFklPtrv5LpJctIiSCroWZWeuoXvuyFdzp6KzjJQ+OT5MfFw==}
+
+ resolution: {integrity: sha512-Bu5Z2nAXgfVyM8xvW3jk9EKRIuX37PudsrBViThNFx7CR7aaYTpP01cxNB/E4c4UUzTDiAZRstEhsRfPOL/8xA==}
+ peerDependencies:
+ typescript: ^5 || ^6 || ^7
+ peerDependenciesMeta:
+ typescript:
+ optional: true
+
resolution: {integrity: sha512-SLX4H/vtcYlYnL7XqnuJKHU7Z8517TgsW9nmQiGOgMCjQ8V/deLYu6bEmbGoXe7WMMhc9+EUGyFFneHja8KabA==}
engines: {node: '>=18'}
@@ -2100,6 +2121,22 @@ packages:
peerDependencies:
react: ^18.3.1
+ resolution: {integrity: sha512-cDtkXgxjuFTWUH6V+aQn1Ve5vDiUztCNPWW5GtSHDccsgRXO1nE6QFWCEmc1KAutrb3OUv87wFShJL5RhUwPXg==}
+ peerDependencies:
+ i18next: '>= 26.2.0'
+ react: '>= 16.8.0'
+ react-dom: '*'
+ react-native: '*'
+ typescript: ^5 || ^6 || ^7
+ peerDependenciesMeta:
+ react-dom:
+ optional: true
+ react-native:
+ optional: true
+ typescript:
+ optional: true
+
resolution: {integrity: sha512-z6F7K9bV85EfseRCp2bzrpyQ0Gkw1uLoCel9XBVWPg/TjRj94SkJzUTGfOa4bs7iJvBWtQG0Wq7wnI0syw3EBQ==}
engines: {node: '>=0.10.0'}
@@ -2291,6 +2328,11 @@ packages:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
+ resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==}
+ peerDependencies:
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
@@ -2570,6 +2612,8 @@ snapshots:
'@babel/core': 7.29.7
'@babel/helper-plugin-utils': 7.29.7
+ '@babel/[email protected]': {}
+
dependencies:
'@babel/code-frame': 7.29.7
@@ -3975,6 +4019,12 @@ snapshots:
+
+ optionalDependencies:
+ typescript: 5.8.3
+
dependencies:
reserved-identifiers: 1.2.0
@@ -4592,6 +4642,17 @@ snapshots:
react: 18.3.1
scheduler: 0.23.2
+ dependencies:
+ '@babel/runtime': 7.29.7
+ html-parse-stringify: 4.0.1
+ i18next: 26.3.6([email protected])
+ react: 18.3.1
+ use-sync-external-store: 1.6.0([email protected])
+ optionalDependencies:
+ react-dom: 18.3.1([email protected])
+ typescript: 5.8.3
+
@@ -4797,6 +4858,10 @@ snapshots:
dependencies:
punycode: 2.3.1
+ dependencies:
+ react: 18.3.1
+
diff --git a/src-tauri/src/bridge/cmd.rs b/src-tauri/src/bridge/cmd.rs
index c82ab6b3..3a9d7072 100644
--- a/src-tauri/src/bridge/cmd.rs
+++ b/src-tauri/src/bridge/cmd.rs
@@ -265,7 +265,7 @@ pub fn set_language(app_handle: AppHandle, lang: String) {
setting.language = lang.clone();
config::set_store_dat_setting(&app_handle, setting);
config::i18n::set_language(match lang.as_str() {
- "en" => config::i18n::Lang::En,
+ "en" | "en-US" => config::i18n::Lang::En,
_ => config::i18n::Lang::Zh,
});
}
diff --git a/src/app.tsx b/src/app.tsx
index 9bc0c978..fabaa30e 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -7,6 +7,7 @@ import HarnessWebview from './components/harness-webview'
import SidebarToggle from './components/sidebar-toggle'
import { useDshTheme } from './hooks/use-dsh-theme'
import { store } from './store'
+import './i18n'
/**
* 应用根组件:只负责首次启动与整体布局。
diff --git a/src/components/debug-sidebar.tsx b/src/components/debug-sidebar.tsx
index ca7eb88f..f0f83820 100644
--- a/src/components/debug-sidebar.tsx
+++ b/src/components/debug-sidebar.tsx
@@ -1,8 +1,9 @@
import { invoke } from '@tauri-apps/api/core'
import { useEffect, useState } from 'react'
+import { useTranslation } from 'react-i18next'
import { useStore } from 'valtio-define'
import { harness } from '../store/modules/harness'
-import { setting, useI18n } from '../store/modules/setting'
+import { setting } from '../store/modules/setting'
import {
button,
codeBlock,
@@ -55,7 +56,7 @@ function Spinner() {
* 直接引用 harness store 的方法,不再接收 onClose/onRestart 等回调 props。
*/
export default function DebugSidebar() {
- const { t, language, setLanguage } = useI18n()
+ const { t, i18n } = useTranslation()
const { sidebarOpen } = useStore(setting)
const { serviceRunning, busyAction } = useStore(harness)
const [info, setInfo] = useState<RuntimeInfo | null>(null)
@@ -379,11 +380,11 @@ export default function DebugSidebar() {
</span>
<select
className={select()}
- value={language}
- onChange={e => setLanguage(e.target.value as 'en' | 'zh')}
+ value={i18n.language}
+ onChange={e => i18n.changeLanguage(e.target.value)}
>
- <option value="zh">中文</option>
- <option value="en">English</option>
+ <option value="zh-CN">中文</option>
+ <option value="en-US">English</option>
</select>
</div>
</div>
diff --git a/src/components/download-toast.tsx b/src/components/download-toast.tsx
index 45331646..e1529607 100644
--- a/src/components/download-toast.tsx
+++ b/src/components/download-toast.tsx
@@ -1,12 +1,12 @@
import { invoke } from '@tauri-apps/api/core'
+import { useTranslation } from 'react-i18next'
import { useStore } from 'valtio-define'
import { download } from '../store/modules/download'
-import { useI18n } from '../store/modules/setting'
import { button, toast } from './primitives'
/** 右下角"下载已保存/失败"提示条:状态与关闭操作直接来自 download store */
export default function DownloadToast() {
- const { t } = useI18n()
+ const { t } = useTranslation()
const { notice } = useStore(download)
if (!notice) {
diff --git a/src/components/harness-updater.tsx b/src/components/harness-updater.tsx
index 8532fe10..8bf5c898 100644
--- a/src/components/harness-updater.tsx
+++ b/src/components/harness-updater.tsx
@@ -1,11 +1,11 @@
+import { useTranslation } from 'react-i18next'
import { useStore } from 'valtio-define'
-import { useI18n } from '../store/modules/setting'
import { updater } from '../store/modules/updater'
import { button, toast } from './primitives'
/** 右下角"发现新版本"提示条:状态与操作直接来自 updater store */
export default function HarnessUpdater() {
- const { t } = useI18n()
+ const { t } = useTranslation()
const { updateInfo, updating } = useStore(updater)
if (!updateInfo || updating) {
diff --git a/src/components/harness-webview.tsx b/src/components/harness-webview.tsx
index 1237a3bd..b75e1342 100644
--- a/src/components/harness-webview.tsx
+++ b/src/components/harness-webview.tsx
@@ -1,8 +1,8 @@
/* eslint-disable react/dom-no-unsafe-iframe-sandbox */
import { CircleAlert } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
import { useStore } from 'valtio-define'
import { harness } from '../store/modules/harness'
-import { useI18n } from '../store/modules/setting'
import Loadable from './loadable'
import Setup from './setup'
@@ -12,7 +12,7 @@ import Setup from './setup'
* 状态与方法全部来自 harness store,不再接收 props。
*/
export default function HarnessWebview() {
- const { t } = useI18n()
+ const { t } = useTranslation()
const {
status,
serviceHealthy,
diff --git a/src/components/loadable.tsx b/src/components/loadable.tsx
index 19043454..57d678ba 100644
--- a/src/components/loadable.tsx
+++ b/src/components/loadable.tsx
@@ -1,6 +1,6 @@
import type { LucideIcon } from 'lucide-react'
import type { ReactNode } from 'react'
-import { useI18n } from '../store/modules/setting'
+import { useTranslation } from 'react-i18next'
import { button } from './primitives'
const LOG_LIMIT = 5
@@ -46,7 +46,7 @@ export default function Loadable({
onRetry,
children,
}: LoadableProps) {
- const { t } = useI18n()
+ const { t } = useTranslation()
const error = errorMsg != null
const wordmark = title ?? t('app.wordmark')
const hint = error ? errorMsg : subtitle ?? t('status.loading_plugins')
diff --git a/src/components/setup.tsx b/src/components/setup.tsx
index 5469256c..95562b30 100644
--- a/src/components/setup.tsx
+++ b/src/components/setup.tsx
@@ -1,9 +1,9 @@
import type { LucideIcon } from 'lucide-react'
import type { SetupStatus } from '../store/modules/harness'
import { CircleAlert, CircleCheck, Download, Rocket, ScanSearch } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
import { useStore } from 'valtio-define'
import { harness } from '../store/modules/harness'
-import { useI18n } from '../store/modules/setting'
import Loadable from './loadable'
// 各阶段对应不同图标,保持与 logo 一致的黑白中性色调
@@ -21,7 +21,7 @@ const STATUS_ICONS: Record<SetupStatus, LucideIcon> = {
* 状态与重试动作直接从 harness store 读取,不再接收 props。
*/
export default function Setup() {
- const { t } = useI18n()
+ const { t } = useTranslation()
const { status, installer, errorMsg } = useStore(harness)
const error = status === 'error'
const installing = status === 'installing'
diff --git a/src/components/sidebar-toggle.tsx b/src/components/sidebar-toggle.tsx
index a184f24e..40b934c2 100644
--- a/src/components/sidebar-toggle.tsx
+++ b/src/components/sidebar-toggle.tsx
@@ -1,6 +1,7 @@
import { Wrench } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
import { useStore } from 'valtio-define'
-import { setting, useI18n } from '../store/modules/setting'
+import { setting } from '../store/modules/setting'
import { updater } from '../store/modules/updater'
import { toggle } from './primitives'
@@ -9,7 +10,7 @@ import { toggle } from './primitives'
* 不再接收 lifted/onClick 等 props。
*/
export default function SidebarToggle() {
- const { t } = useI18n()
+ const { t } = useTranslation()
const { sidebarOpen } = useStore(setting)
const { updateInfo, updating } = useStore(updater)
diff --git a/src/i18n/en.ts b/src/i18n/en.ts
deleted file mode 100644
index edb97bfb..00000000
--- a/src/i18n/en.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import type { Translations } from './types'
-
-export const en: Translations = {
- app: {
- title: 'DeepSeek Harness Desktop',
- wordmark: 'HARNESS',
- retry: 'Retry',
- ready: 'DeepSeek Harness is ready!',
- open_editor: 'Open DeepSeek Harness',
- expand_sidebar: 'Expand sidebar',
- restart: 'Restart',
- shutdown: 'Stop',
- open_browser: 'Open in Browser',
- copy_url: 'Copy URL',
- reveal_dir: 'Open Data Folder',
- refresh: 'Refresh',
- },
- status: {
- checking: 'Checking system environment...',
- installing: 'Installing dependencies...',
- updating: 'Updating DeepSeek Harness...',
- preparing_engine: 'Preparing Node.js runtime... {{progress}}%',
- downloading_harness: 'Downloading DeepSeek Harness... {{progress}}%',
- extracting: 'Extracting resource package...',
- starting: 'Starting DeepSeek Harness service...',
- ready: 'Service is ready',
- error: 'Startup failed',
- loading: 'Loading plugins…',
- loading_plugins: 'Loading plugins…',
- },
- update: {
- available: 'A new version {{tag}} is available. Update now?',
- now: 'Update Now',
- later: 'Later',
- },
- download: {
- saved: 'Session log saved',
- saved_to: 'Saved to',
- failed: 'Session log download failed',
- show_in_folder: 'Open',
- close: 'Close',
- },
- errors: {
- service_start_timeout: 'DeepSeek Harness startup timeout. Please check whether port {{port}} is occupied or the startup is too slow.',
- install_verify_failed: 'Package downloaded but installation verification failed.',
- network_timeout: 'Network download timeout. Please check your network connection.',
- unknown: 'Unknown error',
- },
- ui: {
- service_url: 'Service URL',
- port: 'Port',
- auto_start: 'Auto-start on launch',
- cli_link: 'CLI Integration',
- cli_link_enabled: 'Enable dsh command',
- cli_link_status_ok: 'Enabled — type dsh in a new terminal',
- cli_link_status_partial: 'Enabled but PATH registration incomplete — try saving again',
- cli_link_status_unknown: 'Status unknown',
- cli_link_hint: 'Run dsh --help in a new terminal',
- app_info: 'App Information',
- current_version: 'Current Version',
- dsh_version: 'Harness Version',
- node_version: 'Node.js Runtime',
- data_dir: 'Data Directory',
- logs: 'Service Logs',
- no_logs: '(no logs yet)',
- save: 'Save',
- saved: 'Saved',
- loading_interface: 'Loading DeepSeek Harness interface...',
- iframe_error: 'Cannot load the DeepSeek Harness interface.',
- ensure_running: 'Please make sure the service is running at {{url}}.',
- language: 'Language',
- actions: 'Actions',
- connection_status: 'Connection',
- running: 'Running',
- stopped: 'Stopped',
- settings: 'Settings',
- waiting_logs: 'Waiting for installation logs...',
- install_log: 'Installation log',
- },
- buttons: {
- retry: 'Retry',
- save: 'Save',
- copy: 'Copy',
- clear_logs: 'Clear Logs',
- refresh_logs: 'Refresh',
- },
- messages: {
- copy_success: 'URL copied to clipboard',
- copy_failed: 'Failed to copy URL',
- config_saved: 'Configuration saved',
- save_failed: 'Failed to save configuration',
- cli_link_enabled: 'dsh command enabled — open a new terminal to use it',
- cli_link_disabled: 'dsh command removed',
- start_failed: 'Failed to start service',
- stop_failed: 'Failed to stop service',
- restarting: 'Restarting service...',
- logs_cleared: 'Logs cleared',
- },
-}
diff --git a/src/i18n/index.detector.ts b/src/i18n/index.detector.ts
new file mode 100644
index 00000000..a612ce55
--- /dev/null
+++ b/src/i18n/index.detector.ts
@@ -0,0 +1,33 @@
+import type { LanguageDetectorModule } from 'i18next'
+import { invoke } from '@tauri-apps/api/core'
+import { store } from '../store'
+import { resources } from './index.resource'
+
+/** 语言偏好持久化 key,与 setting store 保持同步 */
+export const LANGUAGE_STORAGE_KEY = 'deepseek-harness-desktop-language'
+
+/** 同步语言探测:优先 localStorage 用户选择,其次浏览器语言 */
+export const languageDetector: LanguageDetectorModule = {
+ type: 'languageDetector',
+ detect: () => {
+ // TODO: check store loaded
+ let selectedLanguage = store.setting.language
+ if (selectedLanguage)
+ return selectedLanguage
+
+ // If no saved language, use device locale or fallback
+ const deviceLocale = navigator.language.toLowerCase().startsWith('zh') ? 'zh-CN' : 'en-US'
+
+ // try exact locale match first
+ if (deviceLocale in resources)
+ selectedLanguage = deviceLocale
+ else
+ selectedLanguage = 'zh-CN'
+
+ return selectedLanguage
+ },
+ cacheUserLanguage: (language: string) => {
+ invoke('set_language', { lang: language.startsWith('zh') ? 'zh' : 'en' })
+ store.setting.language = language
+ },
+}
diff --git a/src/i18n/index.resource.ts b/src/i18n/index.resource.ts
new file mode 100644
index 00000000..0d3eca03
--- /dev/null
+++ b/src/i18n/index.resource.ts
@@ -0,0 +1,7 @@
+import en_US from './locales/en-US.json'
+import zh_CN from './locales/zh-CN.json'
+
+export const resources = {
+ 'en-US': { translation: en_US },
+ 'zh-CN': { translation: zh_CN },
+} as const
diff --git a/src/i18n/index.ts b/src/i18n/index.ts
index 7a910e29..4dd274a2 100644
--- a/src/i18n/index.ts
+++ b/src/i18n/index.ts
@@ -1,8 +1,22 @@
-import type { Language, Translations } from './types'
-import { en } from './en'
-import { zh } from './zh'
+import i18next from 'i18next'
+import { initReactI18next } from 'react-i18next'
+import { languageDetector } from './index.detector'
+import { resources } from './index.resource'
-export const translations: Record<Language, Translations> = { en, zh }
-
-export { type Language, type Translations }
-export { en, zh }
+export const i18n = i18next
+ .use(languageDetector)
+ .use(initReactI18next)
+ .init({
+ fallbackLng: {
+ 'en-*': ['en-US'],
+ 'zh-*': ['zh-CN'],
+ 'default': ['en-US'],
+ },
+ resources,
+ interpolation: { escapeValue: false },
+ react: { useSuspense: false },
+ // 仅使用扁平 dot-notation key(见 AGENTS.md),禁用嵌套解析
+ keySeparator: false,
+ nsSeparator: false,
+ initAsync: false,
+ })
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
new file mode 100644
index 00000000..8cf94838
--- /dev/null
+++ b/src/i18n/locales/en-US.json
@@ -0,0 +1,88 @@
+{
+ "app.title": "DeepSeek Harness Desktop",
+ "app.wordmark": "HARNESS",
+ "app.retry": "Retry",
+ "app.ready": "DeepSeek Harness is ready!",
+ "app.open_editor": "Open DeepSeek Harness",
+ "app.expand_sidebar": "Expand sidebar",
+ "app.restart": "Restart",
+ "app.shutdown": "Stop",
+ "app.open_browser": "Open in Browser",
+ "app.copy_url": "Copy URL",
+ "app.reveal_dir": "Open Data Folder",
+ "app.refresh": "Refresh",
+
+ "status.checking": "Checking system environment...",
+ "status.installing": "Installing dependencies...",
+ "status.updating": "Updating DeepSeek Harness...",
+ "status.preparing_engine": "Preparing Node.js runtime... {{progress}}%",
+ "status.downloading_harness": "Downloading DeepSeek Harness... {{progress}}%",
+ "status.extracting": "Extracting resource package...",
+ "status.starting": "Starting DeepSeek Harness service...",
+ "status.ready": "Service is ready",
+ "status.error": "Startup failed",
+ "status.loading": "Loading plugins…",
+ "status.loading_plugins": "Loading plugins…",
+
+ "update.available": "A new version {{tag}} is available. Update now?",
+ "update.now": "Update Now",
+ "update.later": "Later",
+
+ "download.saved": "Session log saved",
+ "download.saved_to": "Saved to",
+ "download.failed": "Session log download failed",
+ "download.show_in_folder": "Open",
+ "download.close": "Close",
+
+ "errors.service_start_timeout": "DeepSeek Harness startup timeout. Please check whether port {{port}} is occupied or the startup is too slow.",
+ "errors.install_verify_failed": "Package downloaded but installation verification failed.",
+ "errors.network_timeout": "Network download timeout. Please check your network connection.",
+ "errors.unknown": "Unknown error",
+
+ "ui.service_url": "Service URL",
+ "ui.port": "Port",
+ "ui.auto_start": "Auto-start on launch",
+ "ui.cli_link": "CLI Integration",
+ "ui.cli_link_enabled": "Enable dsh command",
+ "ui.cli_link_status_ok": "Enabled — type dsh in a new terminal",
+ "ui.cli_link_status_partial": "Enabled but PATH registration incomplete — try saving again",
+ "ui.cli_link_status_unknown": "Status unknown",
+ "ui.cli_link_hint": "Run dsh --help in a new terminal",
+ "ui.app_info": "App Information",
+ "ui.current_version": "Current Version",
+ "ui.dsh_version": "Harness Version",
+ "ui.node_version": "Node.js Runtime",
+ "ui.data_dir": "Data Directory",
+ "ui.logs": "Service Logs",
+ "ui.no_logs": "(no logs yet)",
+ "ui.save": "Save",
+ "ui.saved": "Saved",
+ "ui.loading_interface": "Loading DeepSeek Harness interface...",
+ "ui.iframe_error": "Cannot load the DeepSeek Harness interface.",
+ "ui.ensure_running": "Please make sure the service is running at {{url}}.",
+ "ui.language": "Language",
+ "ui.actions": "Actions",
+ "ui.connection_status": "Connection",
+ "ui.running": "Running",
+ "ui.stopped": "Stopped",
+ "ui.settings": "Settings",
+ "ui.waiting_logs": "Waiting for installation logs...",
+ "ui.install_log": "Installation log",
+
+ "buttons.retry": "Retry",
+ "buttons.save": "Save",
+ "buttons.copy": "Copy",
+ "buttons.clear_logs": "Clear Logs",
+ "buttons.refresh_logs": "Refresh",
+
+ "messages.copy_success": "URL copied to clipboard",
+ "messages.copy_failed": "Failed to copy URL",
+ "messages.config_saved": "Configuration saved",
+ "messages.save_failed": "Failed to save configuration",
+ "messages.cli_link_enabled": "dsh command enabled — open a new terminal to use it",
+ "messages.cli_link_disabled": "dsh command removed",
+ "messages.start_failed": "Failed to start service",
+ "messages.stop_failed": "Failed to stop service",
+ "messages.restarting": "Restarting service...",
+ "messages.logs_cleared": "Logs cleared"
+}
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
new file mode 100644
index 00000000..fe47cdf8
--- /dev/null
+++ b/src/i18n/locales/zh-CN.json
@@ -0,0 +1,88 @@
+{
+ "app.title": "DeepSeek Harness 桌面版",
+ "app.wordmark": "HARNESS",
+ "app.retry": "重试",
+ "app.ready": "DeepSeek Harness 已就绪!",
+ "app.open_editor": "打开 DeepSeek Harness",
+ "app.expand_sidebar": "展开侧边栏",
+ "app.restart": "重启",
+ "app.shutdown": "停止",
+ "app.open_browser": "在浏览器中打开",
+ "app.copy_url": "复制地址",
+ "app.reveal_dir": "打开数据目录",
+ "app.refresh": "刷新",
+
+ "status.checking": "正在检查系统环境...",
+ "status.installing": "正在安装依赖...",
+ "status.updating": "正在更新 DeepSeek Harness...",
+ "status.preparing_engine": "正在准备 Node.js 运行时... {{progress}}%",
+ "status.downloading_harness": "正在下载 DeepSeek Harness... {{progress}}%",
+ "status.extracting": "正在解压资源包...",
+ "status.starting": "正在启动 DeepSeek Harness 服务...",
+ "status.ready": "服务已就绪",
+ "status.error": "启动失败",
+ "status.loading": "Loading plugins…",
+ "status.loading_plugins": "Loading plugins…",
+
+ "update.available": "发现新版本 {{tag}},是否立即更新?",
+ "update.now": "立即更新",
+ "update.later": "稍后",
+
+ "download.saved": "Session 日志已保存",
+ "download.saved_to": "已保存到",
+ "download.failed": "Session 日志下载失败",
+ "download.show_in_folder": "打开",
+ "download.close": "关闭",
+
+ "errors.service_start_timeout": "DeepSeek Harness 启动超时,请检查端口 {{port}} 是否被占用或启动过慢。",
+ "errors.install_verify_failed": "资源包已下载,但安装校验失败。",
+ "errors.network_timeout": "网络下载超时,请检查网络连接后重试。",
+ "errors.unknown": "未知错误",
+
+ "ui.service_url": "服务地址",
+ "ui.port": "端口",
+ "ui.auto_start": "启动时自动运行",
+ "ui.cli_link": "命令行集成",
+ "ui.cli_link_enabled": "启用 dsh 命令",
+ "ui.cli_link_status_ok": "已启用 — 新开终端后输入 dsh 即可使用",
+ "ui.cli_link_status_partial": "已开启,但 PATH 注册不完整,请重新保存",
+ "ui.cli_link_status_unknown": "状态未知",
+ "ui.cli_link_hint": "在新终端中运行 dsh --help 查看用法",
+ "ui.app_info": "应用信息",
+ "ui.current_version": "当前版本",
+ "ui.dsh_version": "Harness 版本",
+ "ui.node_version": "Node.js 运行时",
+ "ui.data_dir": "数据目录",
+ "ui.logs": "服务日志",
+ "ui.no_logs": "(暂无日志)",
+ "ui.save": "保存",
+ "ui.saved": "已保存",
+ "ui.loading_interface": "正在加载 DeepSeek Harness 界面...",
+ "ui.iframe_error": "无法加载 DeepSeek Harness 界面。",
+ "ui.ensure_running": "请确认服务正在 {{url}} 运行。",
+ "ui.language": "语言",
+ "ui.actions": "操作",
+ "ui.connection_status": "连接状态",
+ "ui.running": "运行中",
+ "ui.stopped": "已停止",
+ "ui.settings": "设置",
+ "ui.waiting_logs": "等待安装日志...",
+ "ui.install_log": "安装日志",
+
+ "buttons.retry": "重试",
+ "buttons.save": "保存",
+ "buttons.copy": "复制",
+ "buttons.clear_logs": "清空日志",
+ "buttons.refresh_logs": "刷新",
+
+ "messages.copy_success": "地址已复制到剪贴板",
+ "messages.copy_failed": "复制地址失败",
+ "messages.config_saved": "配置已保存",
+ "messages.save_failed": "保存配置失败",
+ "messages.cli_link_enabled": "已启用 dsh 命令,新开终端后生效",
+ "messages.cli_link_disabled": "已移除 dsh 命令",
+ "messages.start_failed": "启动服务失败",
+ "messages.stop_failed": "停止服务失败",
+ "messages.restarting": "正在重启服务...",
+ "messages.logs_cleared": "日志已清空"
+}
diff --git a/src/i18n/types.ts b/src/i18n/types.ts
deleted file mode 100644
index 79b91070..00000000
--- a/src/i18n/types.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-export type Language = 'en' | 'zh'
-
-export interface Translations {
- app: {
- title: string
- wordmark: string
- retry: string
- ready: string
- open_editor: string
- expand_sidebar: string
- restart: string
- shutdown: string
- open_browser: string
- copy_url: string
- reveal_dir: string
- refresh: string
- }
- status: {
- checking: string
- installing: string
- updating: string
- preparing_engine: string
- downloading_harness: string
- extracting: string
- starting: string
- ready: string
- error: string
- loading: string
- loading_plugins: string
- }
- update: {
- available: string
- now: string
- later: string
- }
- download: {
- saved: string
- saved_to: string
- failed: string
- show_in_folder: string
- close: string
- }
- errors: {
- service_start_timeout: string
- install_verify_failed: string
- network_timeout: string
- unknown: string
- }
- ui: {
- service_url: string
- port: string
- auto_start: string
- cli_link: string
- cli_link_enabled: string
- cli_link_status_ok: string
- cli_link_status_partial: string
- cli_link_status_unknown: string
- cli_link_hint: string
- app_info: string
- current_version: string
- dsh_version: string
- node_version: string
- data_dir: string
- logs: string
- no_logs: string
- save: string
- saved: string
- loading_interface: string
- iframe_error: string
- ensure_running: string
- language: string
- actions: string
- connection_status: string
- running: string
- stopped: string
- settings: string
- waiting_logs: string
- install_log: string
- }
- buttons: {
- retry: string
- save: string
- copy: string
- clear_logs: string
- refresh_logs: string
- }
- messages: {
- copy_success: string
- copy_failed: string
- config_saved: string
- save_failed: string
- cli_link_enabled: string
- cli_link_disabled: string
- start_failed: string
- stop_failed: string
- restarting: string
- logs_cleared: string
- }
-}
diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts
deleted file mode 100644
index daa32c27..00000000
--- a/src/i18n/zh.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import type { Translations } from './types'
-
-export const zh: Translations = {
- app: {
- title: 'DeepSeek Harness 桌面版',
- wordmark: 'HARNESS',
- retry: '重试',
- ready: 'DeepSeek Harness 已就绪!',
- open_editor: '打开 DeepSeek Harness',
- expand_sidebar: '展开侧边栏',
- restart: '重启',
- shutdown: '停止',
- open_browser: '在浏览器中打开',
- copy_url: '复制地址',
- reveal_dir: '打开数据目录',
- refresh: '刷新',
- },
- status: {
- checking: '正在检查系统环境...',
- installing: '正在安装依赖...',
- updating: '正在更新 DeepSeek Harness...',
- preparing_engine: '正在准备 Node.js 运行时... {{progress}}%',
- downloading_harness: '正在下载 DeepSeek Harness... {{progress}}%',
- extracting: '正在解压资源包...',
- starting: '正在启动 DeepSeek Harness 服务...',
- ready: '服务已就绪',
- error: '启动失败',
- loading: 'Loading plugins…',
- loading_plugins: 'Loading plugins…',
- },
- update: {
- available: '发现新版本 {{tag}},是否立即更新?',
- now: '立即更新',
- later: '稍后',
- },
- download: {
- saved: 'Session 日志已保存',
- saved_to: '已保存到',
- failed: 'Session 日志下载失败',
- show_in_folder: '打开',
- close: '关闭',
- },
- errors: {
- service_start_timeout: 'DeepSeek Harness 启动超时,请检查端口 {{port}} 是否被占用或启动过慢。',
- install_verify_failed: '资源包已下载,但安装校验失败。',
- network_timeout: '网络下载超时,请检查网络连接后重试。',
- unknown: '未知错误',
- },
- ui: {
- service_url: '服务地址',
- port: '端口',
- auto_start: '启动时自动运行',
- cli_link: '命令行集成',
- cli_link_enabled: '启用 dsh 命令',
- cli_link_status_ok: '已启用 — 新开终端后输入 dsh 即可使用',
- cli_link_status_partial: '已开启,但 PATH 注册不完整,请重新保存',
- cli_link_status_unknown: '状态未知',
- cli_link_hint: '在新终端中运行 dsh --help 查看用法',
- app_info: '应用信息',
- current_version: '当前版本',
- dsh_version: 'Harness 版本',
- node_version: 'Node.js 运行时',
- data_dir: '数据目录',
- logs: '服务日志',
- no_logs: '(暂无日志)',
- save: '保存',
- saved: '已保存',
- loading_interface: '正在加载 DeepSeek Harness 界面...',
- iframe_error: '无法加载 DeepSeek Harness 界面。',
- ensure_running: '请确认服务正在 {{url}} 运行。',
- language: '语言',
- actions: '操作',
- connection_status: '连接状态',
- running: '运行中',
- stopped: '已停止',
- settings: '设置',
- waiting_logs: '等待安装日志...',
- install_log: '安装日志',
- },
- buttons: {
- retry: '重试',
- save: '保存',
- copy: '复制',
- clear_logs: '清空日志',
- refresh_logs: '刷新',
- },
- messages: {
- copy_success: '地址已复制到剪贴板',
- copy_failed: '复制地址失败',
- config_saved: '配置已保存',
- save_failed: '保存配置失败',
- cli_link_enabled: '已启用 dsh 命令,新开终端后生效',
- cli_link_disabled: '已移除 dsh 命令',
- start_failed: '启动服务失败',
- stop_failed: '停止服务失败',
- restarting: '正在重启服务...',
- logs_cleared: '日志已清空',
- },
-}
diff --git a/src/store/index.ts b/src/store/index.ts
index 70e16f4a..6a9953f6 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -20,6 +20,6 @@ export type {
SetupStatus,
SidebarBusyAction,
} from './modules/harness'
-export { setting, useI18n } from './modules/setting'
+export { setting } from './modules/setting'
export { updater } from './modules/updater'
export type { DshUpdateInfo } from './modules/updater'
diff --git a/src/store/modules/setting/index.ts b/src/store/modules/setting/index.ts
index eb463b49..c73e18e3 100644
--- a/src/store/modules/setting/index.ts
+++ b/src/store/modules/setting/index.ts
@@ -1,97 +1,27 @@
-import type { Language, Translations } from '../../../i18n'
-import { invoke } from '@tauri-apps/api/core'
-import { defineStore, useStore } from 'valtio-define'
-import { translations } from '../../../i18n'
-
-const STORAGE_KEY = 'deepseek-harness-desktop-language'
-
-/** 初始语言:优先取 localStorage,其次浏览器语言 */
-function getInitialLanguage(): Language {
- const saved = localStorage.getItem(STORAGE_KEY) as Language | null
- if (saved === 'en' || saved === 'zh') {
- return saved
- }
- return navigator.language.toLowerCase().startsWith('zh') ? 'zh' : 'en'
-}
-
-/** 按 keyPath(如 'ui.running')取翻译文案,支持 {{param}} 插值 */
-function getTranslation(obj: Translations, keyPath: string, params?: Record<string, string | number>): string {
- const keys = keyPath.split('.')
- let value: unknown = obj
-
- for (const key of keys) {
- if (value && typeof value === 'object' && key in value) {
- value = (value as Record<string, unknown>)[key]
- }
- else {
- return keyPath
- }
- }
-
- if (typeof value !== 'string') {
- return keyPath
- }
-
- if (params) {
- return value.replace(/\{\{(\w+)\}\}/g, (match, paramName: string) => {
- return params[paramName]?.toString() ?? match
- })
- }
- return value
-}
-
-/** 从 localStorage 恢复侧边栏开关状态 */
-function getInitialSidebarOpen(): boolean {
- const saved = localStorage.getItem('sidebarOpen')
- return saved === null ? false : saved === 'true'
-}
+import { defineStore } from 'valtio-define'
+import { persist } from 'valtio-define/plugins'
/**
- * 设置模块:语言偏好与文案翻译 + 侧边栏开关等纯 UI 状态(由原 i18n / ui 模块合并而来)。
- * 组件通过 useI18n() 订阅语言变化;store 内部动作直接调用 setting.t(...)。
+ * 设置模块:语言偏好(i18n 由 src/i18n 统一管理,组件直接用 react-i18next 的 useTranslation)
+ * + 侧边栏开关等纯 UI 状态。store 内部动作直接调用 setting.t(...)。
*/
export const setting = defineStore({
state: () => ({
- language: getInitialLanguage() as Language,
- sidebarOpen: getInitialSidebarOpen(),
+ sidebarOpen: false,
+ language: null as string | null,
}),
actions: {
- setLanguage(lang: Language) {
- this.language = lang
- localStorage.setItem(STORAGE_KEY, lang)
- // 后端语言设置仅尽力而为
- invoke('set_language', { lang }).catch(() => {})
- },
- t(key: string, params?: Record<string, string | number>): string {
- return getTranslation(translations[this.language], key, params)
- },
toggleSidebar() {
this.sidebarOpen = !this.sidebarOpen
- localStorage.setItem('sidebarOpen', String(this.sidebarOpen))
},
closeSidebar() {
this.sidebarOpen = false
- localStorage.setItem('sidebarOpen', 'false')
},
},
+ persist: {
+ key: 'setting',
+ paths: ['sidebarOpen'],
+ },
})
-// 语言变化时同步 <html lang> 与方向(首次加载也立即生效)
-function applyDocumentLanguage(language: Language) {
- document.documentElement.lang = language
- document.documentElement.dir = 'ltr'
-}
-applyDocumentLanguage(setting.language)
-setting.$subscribeKey('language', (language) => {
- applyDocumentLanguage(language)
-})
-
-/** 订阅 setting store,返回语言与翻译函数(语言切换时自动重渲染) */
-export function useI18n() {
- const { language } = useStore(setting)
- return {
- language,
- setLanguage: setting.setLanguage,
- t: setting.t,
- }
-}
+setting.use(persist({ hydrate: false }))