feat(i18n): add toast i18n with en/zh locale and plugin config support
- Add src/locales/ with en baseline and zh overrides (Partial<Record> fallback) - Add src/shared/i18n.ts with initI18n/t/setLocale/getLocale (LANG env auto-detect) - Add I18nConfigSchema with locale field to plugin config - Internationalize 13 hardcoded strings in task-toast-manager - Add 18 unit tests for i18n module - Pin manager tests to en locale for determinism
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
const locales = {
|
||||
"toast.new_background_task": "New Background Task",
|
||||
"toast.new_task_executed": "New Task Executed",
|
||||
"toast.task_completed": "Task Completed",
|
||||
"toast.task_completion_message": "\"{{description}}\" finished in {{duration}}",
|
||||
"toast.task_completion_remaining": "Still running: {{running}} | Queued: {{queued}}",
|
||||
"toast.status_queued": "Queued",
|
||||
"toast.task_list_running": "Running ({{count}}):",
|
||||
"toast.task_list_queued": "Queued ({{count}}):",
|
||||
"toast.task_list_new": " ← NEW",
|
||||
"toast.fallback_prefix": "[FALLBACK] Model: {{model}}{{suffix}}",
|
||||
"toast.fallback_inherited": " (inherited from parent)",
|
||||
"toast.fallback_system_default": " (system default fallback)",
|
||||
"toast.fallback_runtime": " (runtime fallback)",
|
||||
"toast.concurrency_info": " [{{total}}/{{limit}}]",
|
||||
} as const
|
||||
|
||||
export type TranslationKey = keyof typeof locales
|
||||
export default locales
|
||||
@@ -0,0 +1,12 @@
|
||||
import en, { type TranslationKey } from "./en"
|
||||
import zh from "./zh"
|
||||
|
||||
export type { TranslationKey }
|
||||
export type SupportedLocale = "en" | "zh"
|
||||
export type LocaleMessages = Record<TranslationKey, string>
|
||||
|
||||
type LocaleMap = Record<SupportedLocale, LocaleMessages>
|
||||
export const locales: LocaleMap = {
|
||||
en,
|
||||
zh,
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import en, { type TranslationKey } from "./en"
|
||||
|
||||
const overrides: Partial<Record<TranslationKey, string>> = {
|
||||
"toast.new_background_task": "新后台任务",
|
||||
"toast.new_task_executed": "新任务已执行",
|
||||
"toast.task_completed": "任务完成",
|
||||
"toast.task_completion_message": "\"{{description}}\" 完成,耗时 {{duration}}",
|
||||
"toast.task_completion_remaining": "仍在运行: {{running}} | 排队中: {{queued}}",
|
||||
"toast.status_queued": "排队中",
|
||||
"toast.task_list_running": "运行中 ({{count}}):",
|
||||
"toast.task_list_queued": "排队中 ({{count}}):",
|
||||
"toast.task_list_new": " ← 新任务",
|
||||
"toast.fallback_prefix": "[回退] 模型: {{model}}{{suffix}}",
|
||||
"toast.fallback_inherited": " (继承自父级)",
|
||||
"toast.fallback_system_default": " (系统默认回退)",
|
||||
"toast.fallback_runtime": " (运行时回退)",
|
||||
"toast.concurrency_info": " [{{total}}/{{limit}}]",
|
||||
}
|
||||
|
||||
const locales = {
|
||||
...en,
|
||||
...overrides,
|
||||
} satisfies Record<TranslationKey, string>
|
||||
|
||||
export default locales
|
||||
Reference in New Issue
Block a user