feat: 前端 UI 国际化,支持中/英/日三语切换
之前语言设置只影响后端 AI 行为,前端 UI 文字始终为中文。 新增轻量 i18n 模块(React Context + 翻译字典),切换语言后所有 UI 文字即时刷新。 - 新增 i18n 核心模块和 zh-CN/en-US/ja-JP 翻译文件(约 72 个 key) - App.tsx 拆分为 App(Provider)+ AppContent(业务),确保 Hook 可访问 Context - 所有组件通过 useI18n().t() 获取翻译文本 - errors.ts 改为接受翻译函数参数 - storage.ts saveConfig 时派发事件通知 locale 变化
This commit is contained in:
86
frontend/src/lib/i18n/en-US.ts
Normal file
86
frontend/src/lib/i18n/en-US.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import type { TranslationMap } from "./index";
|
||||
|
||||
export const enUS: TranslationMap = {
|
||||
// App header
|
||||
"app.title": "AI Vision Assistant",
|
||||
"app.stats.requests": "requests",
|
||||
|
||||
// Connection status
|
||||
"status.connected": "Connected",
|
||||
"status.connecting": "Connecting...",
|
||||
"status.disconnected": "Disconnected",
|
||||
|
||||
// Settings
|
||||
"settings.title": "Settings",
|
||||
"settings.appearance": "Appearance",
|
||||
"settings.theme": "Theme",
|
||||
"settings.theme.desc": "Switch between light and dark theme",
|
||||
"settings.theme.dark": "Dark",
|
||||
"settings.theme.light": "Light",
|
||||
"settings.session": "Session",
|
||||
"settings.tts": "Voice Response",
|
||||
"settings.tts.desc": "Play voice along with AI response",
|
||||
"settings.detail": "Image Quality",
|
||||
"settings.detail.desc": "High quality for text recognition, low saves bandwidth",
|
||||
"settings.detail.low": "Low",
|
||||
"settings.detail.high": "High",
|
||||
"settings.language": "Language",
|
||||
"settings.language.desc": "Interaction language preference",
|
||||
|
||||
// Video indicators
|
||||
"video.observing": "👁️ Observing",
|
||||
"video.listening": "🎤 Listening...",
|
||||
"video.playing": "🔊 Playing...",
|
||||
"video.initVad": "Initializing voice detection...",
|
||||
"video.clickToStart": "Click the button below to start",
|
||||
"video.cameraOff": "Camera is off",
|
||||
"video.cameraOff.hint": "You can type in the chat panel",
|
||||
|
||||
// Controls
|
||||
"controls.connecting": "Connecting...",
|
||||
"controls.start": "🎙️ Start Session",
|
||||
"controls.cameraOff": "Turn off camera",
|
||||
"controls.cameraOn": "Turn on camera",
|
||||
"controls.micOff": "Turn off microphone",
|
||||
"controls.micOn": "Turn on microphone",
|
||||
"controls.observing": "👁️ Observing",
|
||||
"controls.observation": "👁️ Observe",
|
||||
"controls.interrupt": "⏹ Interrupt",
|
||||
"controls.stop": "End Session",
|
||||
|
||||
// Chat panel
|
||||
"chat.title": "Chat",
|
||||
"chat.mode.observation": "Observing",
|
||||
"chat.reconnecting": "Connection lost, reconnecting...",
|
||||
"chat.empty.prompt": "Click the button below to start",
|
||||
"chat.empty.hint": "Type or speak with AI after connecting",
|
||||
"chat.welcome.prompt": "Type below to start chatting",
|
||||
"chat.welcome.hint": "Or enable microphone for voice chat",
|
||||
"chat.userLabel": "You",
|
||||
"chat.input.placeholder": "Type a message...",
|
||||
"chat.send": "Send",
|
||||
|
||||
// Session messages
|
||||
"session.changeDetected": "👁️ Scene change detected",
|
||||
"session.recognizing": "(Recognizing speech...)",
|
||||
"session.noSpeech": "(No speech detected)",
|
||||
"session.interrupted": "(Interrupted)",
|
||||
|
||||
// Errors
|
||||
"error.INVALID_MESSAGE": "Invalid message format, please retry",
|
||||
"error.SESSION_NOT_FOUND": "Session expired, please reconnect",
|
||||
"error.RATE_LIMITED": "Too many requests, please try again later",
|
||||
"error.IMAGE_TOO_LARGE": "Image too large, please reduce resolution",
|
||||
"error.AUDIO_TOO_SHORT": "Audio too short, please try again",
|
||||
"error.LLM_TIMEOUT": "AI response timed out, please retry",
|
||||
"error.LLM_ERROR": "AI service error, please try again later",
|
||||
"error.STT_ERROR": "Speech recognition failed, please retry",
|
||||
"error.TTS_ERROR": "Voice synthesis failed",
|
||||
"error.INTERNAL_ERROR": "Internal server error, please retry",
|
||||
"error.unknown": "Unknown error",
|
||||
|
||||
// Device errors
|
||||
"error.vadInit": "VAD initialization failed",
|
||||
"error.cameraAccess": "Cannot access camera",
|
||||
"error.micAccess": "Cannot access microphone",
|
||||
};
|
||||
Reference in New Issue
Block a user