AI video skill for Claude Code & Codex — cinematic, editable product promos with Remotion: 124 shot recipe cards, 150 motion previews, beat sync, sound design, Motion Workbench & JianYing (CapCut CN) export.
TypeScript agent-skillsai-agentsai-videoclaude-codeclaude-code-skillsclaude-skillscodexmotion-designmotion-graphicsproduct-videopromo-videoremotionvideo-generationvideo-production
feat(workbench): 界面默认英文 + 中英切换按钮 (#86)
Yihaoe2d8928c57ef
diff --git a/references/workbench.md b/references/workbench.mdindex 64322ba..d5de453 100644--- a/references/workbench.md+++ b/references/workbench.md@@ -80,7 +80,7 @@ demo 里的场景常量(`CONFIG` / 顶部 `const`)照这个模式提成 `DEF音效或换了组件即视为新版本;旧存档压进撤销栈,⌘Z 可找回。**分组规则**:同一 `cardId`(或同一 `component` 引用)的单元共用一张「成片单元卡」,-素材库里只出现一次,可以再拖一份上轨;`label` 是时间轨上的显示名。卡 id 为+素材库里只出现一次,可以再拖一份上轨;`label` 是时间轨上的显示名(中英文都行:工作台默认英文界面,展示时按 `workbench/src/i18n.ts` 的词典把中文标签翻成英文,查不到就原样显示)。卡 id 为`proj:<kind>:<cardId|首个单元 id>`;显式 `cardId` 与另一组的首个单元 id 撞名(或单元 id 重复)时,后出现的组加 `~2` 后缀并在控制台警告——请给单元换 id 或写显式 `cardId`,别依赖后缀。diff --git a/workbench/README.md b/workbench/README.mdindex 8b819b8..2f33876 100644--- a/workbench/README.md+++ b/workbench/README.md@@ -1,4 +1,4 @@-# ShotCraft Workbench · 动效工作台+# ShotCraft Workbench · Motion Workbench> 面向使用者的图文指南(各区域与功能、截图)见 [GUIDE.md](GUIDE.md);本文是技术说明。@@ -30,6 +30,12 @@ cd workbench && npm install && npm run dev # http://localhost:5198- **成片拆解导入**:按工程 `src/workbench.ts` 清单一键拆成 镜头 / 转场 / 字幕 / 叠加层 / 音乐 /音效 的多轨工程,落点与原 `<Sequence>` 逐帧一致(`npm run parity` 可证)- **保存**:自动存 localStorage(800ms 防抖),导出/导入工程 JSON,撤销/重做+- **界面语言**:默认英文,顶栏右侧按钮切换中文(与画廊同款约定:按钮显示目标语言,选择记在+ localStorage `shotcraft-workbench-locale`)。界面 chrome 走 `src/i18n.ts` 的字符串表;卡片名 /+ schema 字段名 / 分类 / 轨道名 / 清单里的镜头标签照原文写,展示时按同文件的 zh→en 词典翻译,查不到原样显示;+ demo 卡的英文名与一句话由 gen-index 直接取画廊数据(`nameEn` / `summaryEn`);主题预设名写成「中文 · English」+ 按语言取半段。加界面文案两种语言都要写;+ 改原生卡或模板清单的中文标签要同步词典- **导出成片**:顶栏「导出成片」→ dev server 内起 Remotion CLI 渲当前工程为 MP4 → `exports/`- **Remotion Studio**:`npm run studio`(每张卡 Zod schema 自动生成;`ProjImported` / `ProjOriginal` 对照)- **无损校验**:`npm run parity`——退出码 0 一致 / 1 有差异 / 2 无法比对(缺 python3+Pillow),不假绿@@ -70,6 +76,7 @@ node scripts/open.mjs <dir> --no-open # 不弹浏览器src/types.ts 数据模型:Project → Track → Clip(时间量单位=帧)store.ts zustand 状态(撤销栈 / 自动保存 / ?import=project 自动导入)+ i18n.ts 界面语言(en 默认 / zh):chrome 字符串表 + 内容标签 zh→en 词典 + 主题名双语拆分projectImport.ts 清单 → 多轨工程(镜头/转场/字幕/叠加层/音乐/音效贪心装箱)dnd.ts 素材库 → 时间轨拖拽协议preview/Composition.tsx clip → <Sequence> + TimeRemap(Freeze) / 媒体原生通道 / durationProp 注入diff --git a/workbench/index.html b/workbench/index.htmlindex ae6a8fc..55835e3 100644--- a/workbench/index.html+++ b/workbench/index.html@@ -1,9 +1,9 @@<!doctype html>-<html lang="zh-CN">+<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" />- <title>ShotCraft Workbench · 动效工作台</title>+ <title>ShotCraft Workbench · Motion Workbench</title></head><body><div id="root"></div>diff --git a/workbench/scripts/gen-index.mjs b/workbench/scripts/gen-index.mjsindex e2957f0..db13932 100644--- a/workbench/scripts/gen-index.mjs+++ b/workbench/scripts/gen-index.mjs@@ -136,19 +136,27 @@ for (const d of demos) {if (!style && styles.length === 1 && filesPerSlug.get(d.slug) === 1) style = styles[0];const cardZh = i18n.cardsZh?.[d.slug] ?? d.slug;const name = style ? (i18n.stylesZh?.[style.key] ?? style.key) : `${cardZh} · ${d.stem}`;+ // 英文名与画廊英文模式一致:式 key / 卡 slug;英文一句话来自 translations.js(没有就留空,面板回退到中文)+ const nameEn = style ? style.key : `${d.slug} · ${d.stem}`;+ const summaryEn = (style && i18n.stylesEn?.[style.key]) || i18n.cardsEn?.[d.slug] || undefined;const catKey = card?.category ?? d.category;const preview = style && existsSync(join(mediaDir, `${style.key}.mp4`)) ? `${style.key}.mp4` : undefined;meta[d.stem] = {name,+ nameEn,card: cardZh,category: lib.categories?.[catKey]?.zh ?? catKey,categoryKey: catKey,styleKey: style?.key,preview,summary: style?.description ?? card?.summary,+ summaryEn,};}const catOrder = Object.keys(lib.categories ?? {});+const categoryEn = Object.fromEntries(+ [...new Set(demos.map((d) => meta[d.stem].categoryKey))].map((k) => [lib.categories?.[k]?.zh ?? k, lib.categories?.[k]?.en ?? k]),+);const categories = [...new Set(demos.map((d) => meta[d.stem].categoryKey))].sort((a, b) => (catOrder.indexOf(a) + 1 || 99) - (catOrder.indexOf(b) + 1 || 99)).map((k) => lib.categories?.[k]?.zh ?? k);@@ -156,9 +164,10 @@ writeFileSync(join(wb, "src/cards/demoMeta.ts"),banner +"// demo 组件名 → 中文名 / 所属镜头卡 / 画廊分类 / 预览视频(gallery/media 本地已拉取时)/ 一句话\n" +- `export type DemoMeta = { name: string; card: string; category: string; categoryKey: string; styleKey?: string; preview?: string; summary?: string };\n` ++ `export type DemoMeta = { name: string; nameEn: string; card: string; category: string; categoryKey: string; styleKey?: string; preview?: string; summary?: string; summaryEn?: string };\n` +`export const DEMO_META: Record<string, DemoMeta> = ${JSON.stringify(meta, null, 2)};\n\n` +- `/** 画廊分类(中文,按画廊顺序),只含有 demo 的分类 */\nexport const DEMO_CATEGORIES: string[] = ${JSON.stringify(categories)};\n`,+ `/** 画廊分类(中文,按画廊顺序),只含有 demo 的分类 */\nexport const DEMO_CATEGORIES: string[] = ${JSON.stringify(categories)};\n` ++ `/** 分类中文名 → 英文名(i18n 词典合并用,英文界面按此显示分类) */\nexport const DEMO_CATEGORY_EN: Record<string, string> = ${JSON.stringify(categoryEn)};\n`,);// —— 素材清单:扫描 public/(成片工程素材经符号链接接入;cardpreviews / sfxlib / bgmlib 单列)——diff --git a/workbench/src/App.tsx b/workbench/src/App.tsxindex f85e1ca..d9f0e4a 100644--- a/workbench/src/App.tsx+++ b/workbench/src/App.tsx@@ -6,6 +6,7 @@ import { Timeline } from "./timeline/Timeline";import { resetProject, useStore } from "./store";import { seekTo, togglePlay } from "./playerRef";import type { ProjectData } from "./types";+import { applyLocaleToDocument, useLocale, useT } from "./i18n";const isEditable = (el: EventTarget | null) =>el instanceof HTMLElement &&@@ -41,6 +42,7 @@ const startSplit = (/** 导出成片:提交当前工程给 dev server 的 Remotion 渲染任务,轮询进度 */const ExportButton: React.FC = () => {+ const t = useT();const [job, setJob] = useState<{id: string;status: "running" | "done" | "error";@@ -64,7 +66,7 @@ const ExportButton: React.FC = () => {const r = await fetch("/api/export", { method: "POST", body: JSON.stringify({ project }) });const j = await r.json();if (!r.ok) {- window.alert(j.error ?? "导出启动失败");+ window.alert(j.error ?? t("export.startFailed"));return;}setJob({ id: j.id, status: "running", progress: 0 });@@ -76,7 +78,7 @@ const ExportButton: React.FC = () => {if (job?.status === "running")return (<button className="btn primary" disabled>- 导出中 {Math.round(job.progress * 100)}%+ {t("export.running", { pct: Math.round(job.progress * 100) })}</button>);if (job?.status === "done")@@ -84,34 +86,38 @@ const ExportButton: React.FC = () => {<><buttonclassName="btn"- title="在 Finder 中显示导出的 MP4"+ title={t("export.revealTitle")}onClick={() => fetch(`/api/export/${job.id}/reveal`, { method: "POST" })}>- ✓ 已导出 · 显示文件+ {t("export.done")}</button><button className="btn primary" onClick={start}>- 再次导出+ {t("export.again")}</button></>);if (job?.status === "error")return (<button className="btn danger" title={job.lastLine} onClick={start}>- 导出失败 · 重试+ {t("export.failedRetry")}</button>);return (<buttonclassName="btn primary"- title="用 Remotion 渲染当前工程为 MP4(输出到 workbench/exports/)"+ title={t("export.title")}onClick={start}>- 导出成片+ {t("export.film")}</button>);};export const App: React.FC = () => {+ const t = useT();+ const locale = useLocale((s) => s.locale);+ const toggleLocale = useLocale((s) => s.toggleLocale);+ useEffect(() => applyLocaleToDocument(locale), [locale]);const project = useStore((s) => s.project);const undo = useStore((s) => s.undo);const redo = useStore((s) => s.redo);@@ -170,7 +176,7 @@ export const App: React.FC = () => {if (!p || !Array.isArray(p.tracks)) throw new Error("bad format");useStore.getState().setProject(p);} catch {- window.alert("导入失败:不是合法的工程 JSON");+ window.alert(t("import.invalid"));}});};@@ -186,21 +192,25 @@ export const App: React.FC = () => {spellCheck={false}/><span style={{ flex: 1 }} />- <button className="btn" disabled={!canUndo} onClick={undo} title="撤销(⌘Z)">- ↩ 撤销+ <button className="btn" disabled={!canUndo} onClick={undo} title={t("undo.title")}>+ {t("undo")}</button>- <button className="btn" disabled={!canRedo} onClick={redo} title="重做(⇧⌘Z)">- ↪ 重做+ <button className="btn" disabled={!canRedo} onClick={redo} title={t("redo.title")}>+ {t("redo")}</button><span className="tl-sep" /><ExportButton />- <button className="btn" onClick={exportJson}>导出 JSON</button>- <button className="btn" onClick={() => fileRef.current?.click()}>导入</button>+ <button className="btn" onClick={exportJson}>{t("exportJson")}</button>+ <button className="btn" onClick={() => fileRef.current?.click()}>{t("import")}</button><buttonclassName="btn"- onClick={() => window.confirm("重置为演示工程?当前内容会被覆盖(可撤销)。") && resetProject()}+ onClick={() => window.confirm(t("reset.confirm")) && resetProject()}>- 重置示例+ {t("reset")}+ </button>+ <span className="tl-sep" />+ <button className="btn" onClick={toggleLocale} title={t("lang.switchTitle")}>+ {t("lang.switchLabel")}</button><inputref={fileRef}@@ -221,7 +231,7 @@ export const App: React.FC = () => {</div><divclassName="splitter v"- title="拖拽调整素材库宽度"+ title={t("split.library")}onPointerDown={(e) => {const start = libW;startSplit(e, (dx) => setLibW(clamp(start + dx, 160, 440)));@@ -230,7 +240,7 @@ export const App: React.FC = () => {<PreviewPanel /><divclassName="splitter v"- title="拖拽调整属性面板宽度"+ title={t("split.inspector")}onPointerDown={(e) => {const start = inspW;startSplit(e, (dx) => setInspW(clamp(start - dx, 220, 500)));@@ -243,7 +253,7 @@ export const App: React.FC = () => {<divclassName="splitter h"- title="拖拽调整时间轨高度"+ title={t("split.timeline")}onPointerDown={(e) => {const start = tlH;startSplit(e, (_dx, dy) => setTlH(clamp(start - dy, 150, 600)));diff --git a/workbench/src/cards/demoCards.ts b/workbench/src/cards/demoCards.tsindex 78a43cd..cb36833 100644--- a/workbench/src/cards/demoCards.ts+++ b/workbench/src/cards/demoCards.ts@@ -14,6 +14,7 @@ export const DEMO_CARDS: CardDef[] = DEMO_MODULES.map((m) => {return {id: `demo:${m.stem}`,name: meta?.name ?? m.stem,+ nameEn: meta?.nameEn ?? m.stem,category: meta?.category ?? "动效库",durationInFrames: Math.max(2, Math.round(m.duration)),component: m.component,@@ -21,6 +22,7 @@ export const DEMO_CARDS: CardDef[] = DEMO_MODULES.map((m) => {accent: "#c58a2a",preview: meta?.preview ? `cardpreviews/${meta.preview}` : undefined,summary: meta?.summary,+ summaryEn: meta?.summaryEn,};});diff --git a/workbench/src/cards/manifest.ts b/workbench/src/cards/manifest.tsindex 2f7fa6a..0ebcb19 100644--- a/workbench/src/cards/manifest.ts+++ b/workbench/src/cards/manifest.ts@@ -77,6 +77,7 @@ export type WorkbenchManifest = {export type ManifestTheme = {palette?: Record<string, string>;id: string;+ /** 建议写成「中文 · English」:工作台按界面语言取对应半段;单段名走 i18n 词典,查不到原样显示 */label: string;background?: string;unitDefaults?: Record<string, Record<string, unknown>>;diff --git a/workbench/src/cards/text-basic.tsx b/workbench/src/cards/text-basic.tsxindex 3403a11..9277f11 100644--- a/workbench/src/cards/text-basic.tsx+++ b/workbench/src/cards/text-basic.tsx@@ -21,7 +21,7 @@ interface Props {}const TextBasic: React.FC<Props> = ({- content = "在这里输入文字",+ content = "Type your text here",fontSize = 64,color = "#1d1d1f",bg = "#ffffff",@@ -126,7 +126,7 @@ export const textBasicCard: CardDef = {accent: "#0a84ff",component: TextBasic as React.ComponentType<Record<string, unknown>>,schema: [- { type: "textarea", key: "content", label: "文字内容", default: "在这里输入文字" },+ { type: "textarea", key: "content", label: "文字内容", default: "Type your text here" },{ type: "slider", key: "fontSize", label: "字号", default: 64, min: 16, max: 180, step: 1, unit: "px" },{ type: "color", key: "color", label: "文字颜色", default: "#1d1d1f" },{diff --git a/workbench/src/cards/types.ts b/workbench/src/cards/types.tsindex d2eb418..1c678f4 100644--- a/workbench/src/cards/types.ts+++ b/workbench/src/cards/types.ts@@ -38,8 +38,10 @@ export type PropField =export interface CardDef {themeKey?: string;id: string;- /** 中文名(面板展示) */+ /** 名称:卡片 / 清单里的原文,面板展示时经 i18n.tx 按界面语言翻译 */name: string;+ /** 英文名:demo 卡由 gen-index 从画廊数据生成;没有时展示层走 i18n 词典 */+ nameEn?: string;category: string;/** "audio"/"video":媒体卡——不包 TimeRemap(Freeze 会掐死原生播放),* 裁入/变速经 props 传入,由卡内 trimBefore/playbackRate 实现;@@ -69,6 +71,8 @@ export interface CardDef {preview?: string;/** 一句话说明(素材库 tooltip) */summary?: string;+ /** 英文一句话(demo 卡来自画廊 translations.js 的 stylesEn / cardsEn) */+ summaryEn?: string;}/** 卡片库(demo / 原生卡)统一按 30fps 编排:durationInFrames 与内部时序都以它为准。diff --git a/workbench/src/demoProject.ts b/workbench/src/demoProject.tsindex 2210116..5c80b05 100644--- a/workbench/src/demoProject.ts+++ b/workbench/src/demoProject.ts@@ -1,5 +1,6 @@import type { ProjectData } from "./types";import { uid } from "./types";+import { t } from "./i18n";/** 初始演示工程(未接入成片时):纸底 + 两张 demo 镜头卡顺排 + 字卡 + 解说条。* 同时是 Remotion Studio「Main」合成的 defaultProps 来源——保持纯函数,别引 store。 */@@ -8,7 +9,7 @@ export const demoProject = (): ProjectData => {id: uid("clip"), cardId, start, duration, inOffset: 0, speed: 1, opacity: 1, scale: 1, x: 0, y: 0, props, label,});return {- name: "未命名工程",+ name: t("demo.name"),fps: 30,width: 1920,height: 1080,@@ -16,22 +17,22 @@ export const demoProject = (): ProjectData => {tracks: [{id: uid("track"),- name: "字幕",+ name: t("track.captions"),clips: [clip("inkpress-caption", 70, 60, { text: "COUNT UP · CONFETTI" })],},{id: uid("track"),- name: "镜头",+ name: t("track.shots"),clips: [- clip("inkpress-title-card", 0, 55, { text: "Every shot, *tuned* in one place." }, "字卡"),- clip("demo:CounterConfetti", 55, 138, {}, "数字冲刺纸屑"),- clip("demo:CrashImpactReal", 193, 120, {}, "急推撞停"),- clip("inkpress-title-card", 313, 55, { text: "Drag a card. *Tweak* it. Export." }, "字卡"),+ clip("inkpress-title-card", 0, 55, { text: "Every shot, *tuned* in one place." }),+ clip("demo:CounterConfetti", 55, 138),+ clip("demo:CrashImpactReal", 193, 120),+ clip("inkpress-title-card", 313, 55, { text: "Drag a card. *Tweak* it. Export." }),],},{id: uid("track"),- name: "背景",+ name: t("track.background"),clips: [clip("bg-paper", 0, 368)],},],diff --git a/workbench/src/i18n.ts b/workbench/src/i18n.tsnew file mode 100644index 0000000..6e4cd70--- /dev/null+++ b/workbench/src/i18n.ts@@ -0,0 +1,548 @@+import { create } from "zustand";+import { DEMO_CATEGORY_EN } from "./cards/demoMeta";+import type { CardDef } from "./cards/types";++/** 工作台界面语言。English 是默认;中文是第二语言。+ * 与画廊同一套约定:localStorage 记住选择,切换按钮显示"目标语言"(en 界面上写 中文,zh 界面上写 EN)。+ *+ * 两类文案两套机制:+ * - 界面 chrome(按钮 / 提示 / 弹窗 / 面板标题):`t(key)` 查 STRINGS 表,键名稳定,两种语言都必须有。+ * - 内容标签(卡片名 / schema 字段名 / 分类 / 轨道名 / 成片清单里的镜头标签):卡片和清单里照原文写,+ * 展示时 `tx(text)` 按 LABELS 词典翻译;查不到就原样显示。清单是成片工程自己写的,不强求双语。+ * demo 卡的英文名 / 英文摘要由 gen-index 直接从画廊数据生成(nameEn / summaryEn),不走词典。 */+export type Locale = "en" | "zh";+const STORAGE_KEY = "shotcraft-workbench-locale";++const readSaved = (): Locale => {+ try {+ return typeof localStorage !== "undefined" && localStorage.getItem(STORAGE_KEY) === "zh" ? "zh" : "en";+ } catch {+ return "en";+ }+};+/** 只由工作台 App 调用(useEffect):Remotion Studio / 渲染 bundle 也会加载本模块,不能在这里改页面 */+export const applyLocaleToDocument = (l: Locale) => {+ document.documentElement.lang = l === "zh" ? "zh-CN" : "en";+ document.title = STRINGS[l]["app.title"];+};++export const useLocale = create<{ locale: Locale; setLocale: (l: Locale) => void; toggleLocale: () => void }>((set, get) => ({+ locale: readSaved(),+ setLocale: (l) => {+ try { localStorage.setItem(STORAGE_KEY, l); } catch { /* 隐私模式等:只在本次会话生效 */ }+ set({ locale: l });+ },+ toggleLocale: () => get().setLocale(get().locale === "zh" ? "en" : "zh"),+}));++// —— 界面 chrome ——+const EN = {+ "app.title": "ShotCraft Workbench · Motion Workbench",+ "lang.switchTitle": "Switch the interface to Chinese (中文)",+ "lang.switchLabel": "中文",++ "undo": "↩ Undo",+ "undo.title": "Undo (⌘Z)",+ "redo": "↪ Redo",+ "redo.title": "Redo (⇧⌘Z)",+ "export.film": "Export video",+ "export.title": "Render the current project to MP4 with Remotion (saved to workbench/exports/)",+ "export.running": "Exporting {pct}%",+ "export.done": "✓ Exported · Show file",+ "export.revealTitle": "Show the exported MP4 in Finder",+ "export.again": "Export again",+ "export.failedRetry": "Export failed · Retry",+ "export.startFailed": "Export failed to start",+ "exportJson": "Export JSON",+ "import": "Import",+ "import.invalid": "Import failed: not a valid project JSON",+ "reset": "Reset demo",+ "reset.confirm": "Reset to the demo project? Current content will be replaced (undoable).",+ "split.library": "Drag to resize the library",+ "split.inspector": "Drag to resize the properties panel",+ "split.timeline": "Drag to resize the timeline",++ "tl.split": "✂ Split",+ "tl.split.title": "Split the selected clip at the playhead (S)",+ "tl.dup": "⧉ Duplicate",+ "tl.dup.title": "Duplicate the selected clip (⌘D)",+ "tl.del": "🗑 Delete",+ "tl.del.title": "Delete the selected clip (Delete)",+ "tl.addTrack": "+ Track",+ "tl.addTrack.title": "Add a track (on top)",+ "tl.fit": "⤢ Fit",+ "tl.fit.title": "Zoom to fit all content",+ "tl.zoom": "Zoom",+ "tl.reorder.title": "Drag up or down to reorder tracks (upper tracks cover lower ones)",+ "tl.showTrack": "Show track",+ "tl.hideTrack": "Hide track",+ "tl.deleteTrack": "Delete track",+ "tl.deleteTrack.confirm": "Delete track “{name}” and its {n} clips?",++ "insp.title": "Properties",+ "insp.empty1": "Select a clip on the timeline",+ "insp.empty2": "to edit its text, colors,",+ "insp.empty3": "animation timing, speed and layer.",+ "insp.shortcuts1": "Shortcuts: Space play · S split",+ "insp.shortcuts2": "Delete remove · ⌘Z undo · ⌘D duplicate",+ "insp.contentStyle": "Content & style",+ "insp.timing": "Timing & speed",+ "insp.start": "Start",+ "insp.duration": "Duration",+ "insp.speed": "Speed",+ "insp.inPoint": "In point",+ "insp.restore": "↺ Original duration",+ "insp.restore.title": "Restore the card’s original duration (scaled by the current speed)",+ "insp.fpsMismatch":+ "This card is timed at {src}fps and the project runs at {fps}fps: its duration was converted and speed set to {ratio}× to keep the rhythm. If the card times itself with useVideoConfig().fps (spring etc.), timing still drifts by {inv}×.",+ "insp.layer": "Layer",+ "insp.opacity": "Opacity",+ "insp.scale": "Scale",+ "insp.x": "Offset X",+ "insp.y": "Offset Y",+ "insp.deleteClip": "Delete clip",++ "lib.tab.media": "Media",+ "lib.tab.cards": "Motion",+ "lib.tab.sfx": "Sound",+ "lib.tab.themes": "Themes",+ "lib.cellHint": "Click to preview, drag onto the timeline",+ "lib.tunable": " · tunable",+ "lib.importFilm": "⇣ Import film: {name}",+ "lib.importFilm.title":+ "Split the film by its src/workbench.ts manifest into shot / transition / caption / overlay / SFX / music tracks (undoable)\n{dir}",+ "lib.linkedNoManifest":+ "Linked {dir}, but the project has no src/workbench.ts manifest, so it can’t be split for import (see references/workbench.md)",+ "lib.notLinked": "No film project linked. In workbench/ run: node scripts/open.mjs <project dir>",+ "lib.filmUnits": "Film units (add another copy)",+ "lib.mediaFiles": "Media files (project public/)",+ "lib.video": "Video",+ "lib.image": "Image",+ "lib.projectAudio": "Project audio (public/)",+ "lib.usedIn": "Used ×{n}",+ "lib.unused": "Unused",+ "lib.bgm": "BGM options (assets/audio/bgm)",+ "lib.sfxLib": "SFX library · {cat}",+ "lib.foot.themes": "Theme switches are undoable · saved with the project",+ "lib.foot.cards": "{n} motion cards ({m} tunable)",+ "lib.foot.sfx": " · SFX library {n}",+ "lib.foot.units": " · film units {n}",+ "lib.foot.hint": "Click to preview · drag onto the timeline",++ "prev.audioCard": "🔊 Audio card",+ "prev.tag": "Preview",+ "prev.dragHint": "Drag media onto the timeline to add it",+ "prev.back": "✕ Back to project",+ "prev.toStart": "Go to start",+ "prev.playPause": "Play / Pause (Space)",+ "prev.loop": "Loop",++ "theme.aria": "Film theme",+ "theme.presets": "Presets",+ "theme.hint": "Pick a style, then adjust the colors.",+ "theme.none": "This project provides no themes yet.",+ "theme.mine": "My themes",+ "theme.delete.aria": "Delete {name}",+ "theme.deleted": "Deleted “{name}”",+ "theme.applied": "Applied “{name}”",+ "theme.editor": "Replace colors",+ "theme.reset": "Reset preset",+ "theme.name.aria": "Palette name",+ "theme.name.placeholder": "Palette name (optional)",+ "theme.save": "Save palette",+ "theme.import": "Import palette",+ "theme.export": "Export palette",+ "theme.file.aria": "Import palette file",+ "theme.limit": "50 palettes saved. Delete unused ones first.",+ "theme.saved": "Saved “{name}” (this browser only).",+ "theme.saveFailed": "Save failed: browser storage is unavailable. Export the palette as a backup.",+ "theme.exported": "Palette exported as JSON.",+ "theme.tooBig": "Palette file must be under 64 KB.",+ "theme.imported": "Imported and applied. Click “Save palette” to add it to My themes.",+ "theme.importFailed": "Import failed.",+ "theme.customized": "Customized · ",+ "theme.clickHint": "Click a swatch or type a HEX · ",+ "theme.switchResets": "switching presets resets the palette",+ "theme.note": "Applies to preview and export, undoable. Per-clip color edits take precedence.",+ "theme.paperNote": "The paper theme keeps its original screenshots. Pick another preset to edit the full palette.",+ "theme.noPalette": "Shown here once the project provides an editable palette.",+ "theme.pick.aria": "{label} color picker",+ "theme.hex.aria": "{label} hex value",+ "theme.field.page": "Background",+ "theme.field.surface": "Card",+ "theme.field.text": "Text",+ "theme.field.muted": "Secondary text",+ "theme.field.accent": "Accent",+ "theme.field.field": "Light fill",+ "theme.field.border": "Border",++ "palette.custom": "Custom",+ "palette.needTheme": "Select a theme that supports palettes first.",+ "palette.tooBig": "Palette file is too large; choose a JSON under 64 KB.",+ "palette.badJson": "The file is not valid JSON.",+ "palette.badFormat": "Palette file format is invalid.",+ "palette.badVersion": "Choose a palette JSON exported by ShotCraft (version 1).",+ "palette.badTheme": "This project doesn’t support the palette’s base theme.",+ "palette.noColors": "The palette has no colors field.",+ "palette.badColors": "All color fields are required and must use #RRGGBB.",++ "track.transitions": "Transitions",+ "track.captions": "Captions",+ "track.overlays": "Overlays",+ "track.shots": "Shots",+ "track.music": "Music",+ "track.sfx": "SFX",+ "track.background": "Background",+ "track.new": "Track {n}",++ "demo.name": "Untitled project",+} as const;++export type StringKey = keyof typeof EN;++const ZH: Record<StringKey, string> = {+ "app.title": "ShotCraft Workbench · 动效工作台",+ "lang.switchTitle": "切换为英文界面 (English)",+ "lang.switchLabel": "EN",++ "undo": "↩ 撤销",+ "undo.title": "撤销(⌘Z)",+ "redo": "↪ 重做",+ "redo.title": "重做(⇧⌘Z)",+ "export.film": "导出成片",+ "export.title": "用 Remotion 渲染当前工程为 MP4(输出到 workbench/exports/)",+ "export.running": "导出中 {pct}%",+ "export.done": "✓ 已导出 · 显示文件",+ "export.revealTitle": "在 Finder 中显示导出的 MP4",+ "export.again": "再次导出",+ "export.failedRetry": "导出失败 · 重试",+ "export.startFailed": "导出启动失败",+ "exportJson": "导出 JSON",+ "import": "导入",+ "import.invalid": "导入失败:不是合法的工程 JSON",+ "reset": "重置示例",+ "reset.confirm": "重置为演示工程?当前内容会被覆盖(可撤销)。",+ "split.library": "拖拽调整素材库宽度",+ "split.inspector": "拖拽调整属性面板宽度",+ "split.timeline": "拖拽调整时间轨高度",++ "tl.split": "✂ 分割",+ "tl.split.title": "在播放头处分割选中片段(S)",+ "tl.dup": "⧉ 复制",+ "tl.dup.title": "复制选中片段(⌘D)",+ "tl.del": "🗑 删除",+ "tl.del.title": "删除选中片段(Delete)",+ "tl.addTrack": "+ 轨道",+ "tl.addTrack.title": "新增一条轨道(加在最上层)",+ "tl.fit": "⤢ 适配",+ "tl.fit.title": "缩放到适配全部内容",+ "tl.zoom": "缩放",+ "tl.reorder.title": "按住上下拖动调整轨道层序(上层盖住下层)",+ "tl.showTrack": "显示轨道",+ "tl.hideTrack": "隐藏轨道",+ "tl.deleteTrack": "删除轨道",+ "tl.deleteTrack.confirm": "删除轨道「{name}」及其 {n} 个片段?",++ "insp.title": "属性",+ "insp.empty1": "选中时间轨上的片段后,",+ "insp.empty2": "在这里调整它的文字、颜色、",+ "insp.empty3": "动画节奏、变速与图层属性。",+ "insp.shortcuts1": "快捷键:空格 播放 · S 分割",+ "insp.shortcuts2": "Delete 删除 · ⌘Z 撤销 · ⌘D 复制",+ "insp.contentStyle": "内容与样式",+ "insp.timing": "时间与变速",+ "insp.start": "起点",+ "insp.duration": "时长",+ "insp.speed": "变速",+ "insp.inPoint": "裁入点",+ "insp.restore": "↺ 恢复原始时长",+ "insp.restore.title": "时长恢复为卡片原始时长(按当前变速换算)",+ "insp.fpsMismatch":+ "此卡按 {src}fps 编排,工程 {fps}fps:上轨时已换算时长并以 {ratio}× 变速保持节奏。卡内若按 useVideoConfig().fps 计时(spring 等),节奏仍会偏 {inv}×。",+ "insp.layer": "图层",+ "insp.opacity": "不透明度",+ "insp.scale": "缩放",+ "insp.x": "位移 X",+ "insp.y": "位移 Y",+ "insp.deleteClip": "删除片段",++ "lib.tab.media": "素材",+ "lib.tab.cards": "动效库",+ "lib.tab.sfx": "音效",+ "lib.tab.themes": "主题",+ "lib.cellHint": "点击预览,拖到时间轨添加",+ "lib.tunable": " · 可调参",+ "lib.importFilm": "⇣ 导入成片:{name}",+ "lib.importFilm.title": "把成片按 src/workbench.ts 清单拆成镜头 / 转场 / 字幕 / 叠加层 / 音效 / 音乐的多轨工程(可撤销)\n{dir}",+ "lib.linkedNoManifest": "已链接 {dir},但工程没有 src/workbench.ts 清单,无法拆解导入(写法见 references/workbench.md)",+ "lib.notLinked": "未接入成片工程。在 workbench/ 目录运行:node scripts/open.mjs <成片工程目录>",+ "lib.filmUnits": "成片单元(可再加一份)",+ "lib.mediaFiles": "素材文件(工程 public/)",+ "lib.video": "视频",+ "lib.image": "图片",+ "lib.projectAudio": "本片音频(工程 public/)",+ "lib.usedIn": "片中×{n}",+ "lib.unused": "未用",+ "lib.bgm": "BGM 备选(assets/audio/bgm)",+ "lib.sfxLib": "音效库 · {cat}",+ "lib.foot.themes": "切换主题可撤销 · 随工程自动保存",+ "lib.foot.cards": "动效 {n} 卡({m} 张可调参)",+ "lib.foot.sfx": " · 音效库 {n}",+ "lib.foot.units": " · 成片单元 {n}",+ "lib.foot.hint": "点击预览 · 拖拽到时间轨添加",++ "prev.audioCard": "🔊 音频卡",+ "prev.tag": "素材预览",+ "prev.dragHint": "拖拽素材到时间轨即可添加",+ "prev.back": "✕ 返回工程",+ "prev.toStart": "回到开头",+ "prev.playPause": "播放/暂停(空格)",+ "prev.loop": "循环",++ "theme.aria": "影片主题",+ "theme.presets": "预设主题",+ "theme.hint": "选择一套风格,再调整配色。",+ "theme.none": "当前工程尚未提供主题。",+ "theme.mine": "我的主题",+ "theme.delete.aria": "删除 {name}",+ "theme.deleted": "已删除「{name}」",+ "theme.applied": "已应用「{name}」",+ "theme.editor": "替换配色",+ "theme.reset": "恢复预设",+ "theme.name.aria": "配色名称",+ "theme.name.placeholder": "配色名称(可选)",+ "theme.save": "保存配色",+ "theme.import": "导入配色",+ "theme.export": "导出配色",+ "theme.file.aria": "导入配色文件",+ "theme.limit": "已保存 50 套配色,请先删除不再使用的主题。",+ "theme.saved": "已保存「{name}」,仅保存在此浏览器。",+ "theme.saveFailed": "保存失败:浏览器存储不可用,请导出配色备份。",+ "theme.exported": "配色已导出为 JSON。",+ "theme.tooBig": "配色文件不能超过 64 KB。",+ "theme.imported": "已导入并应用,点击「保存配色」可加入我的主题。",+ "theme.importFailed": "导入失败。",+ "theme.customized": "已自定义 · ",+ "theme.clickHint": "点击色块或输入 HEX · ",+ "theme.switchResets": "切换预设会重置配色",+ "theme.note": "同步预览与导出,可撤销。单独调整过的镜头颜色优先保留。",+ "theme.paperNote": "纸质主题保留原始截图质感。选择其他预设后,可调整整套配色。",+ "theme.noPalette": "工程提供可编辑配色后,会在这里显示。",+ "theme.pick.aria": "{label}取色",+ "theme.hex.aria": "{label}色值",+ "theme.field.page": "背景",+ "theme.field.surface": "卡片",+ "theme.field.text": "文字",+ "theme.field.muted": "次要文字",+ "theme.field.accent": "强调色",+ "theme.field.field": "浅色填充",+ "theme.field.border": "边框",++ "palette.custom": "自定义",+ "palette.needTheme": "请先选择支持配色的主题。",+ "palette.tooBig": "配色文件过大,请选择小于 64 KB 的 JSON。",+ "palette.badJson": "文件不是有效的 JSON。",+ "palette.badFormat": "配色文件格式不正确。",+ "palette.badVersion": "请选择 ShotCraft 导出的配色 JSON(版本 1)。",+ "palette.badTheme": "当前工程不支持这份配色的基础主题。",+ "palette.noColors": "配色缺少颜色字段。",+ "palette.badColors": "颜色字段必须完整,并使用 #RRGGBB 格式。",++ "track.transitions": "转场",+ "track.captions": "字幕",+ "track.overlays": "叠加层",+ "track.shots": "镜头",+ "track.music": "音乐",+ "track.sfx": "音效",+ "track.background": "背景",+ "track.new": "轨道 {n}",++ "demo.name": "未命名工程",+};++export const STRINGS: Record<Locale, Record<StringKey, string>> = { en: EN, zh: ZH };++const fill = (s: string, params?: Record<string, string | number>) =>+ params ? s.replace(/\{(\w+)\}/g, (m, k) => (k in params ? String(params[k]) : m)) : s;++/** 界面文案(非组件代码也能用:读当前语言,不订阅) */+export const t = (key: StringKey, params?: Record<string, string | number>): string =>+ fill(STRINGS[useLocale.getState().locale][key] ?? EN[key], params);++/** 组件里用:订阅语言变化,切换后重渲染 */+export const useT = () => {+ useLocale((s) => s.locale);+ return t;+};++// —— 内容标签词典(zh → en)——+// 键是卡片 / 清单里写的原文;" · " 分隔的复合标签按段翻译。改卡片文案时同步这里,查不到会原样显示(中文),一眼能看出漏了。+const LABELS_ZH_EN: Record<string, string> = {+ // 分类+ "工作台": "Workbench",+ "成片单元": "Film units",+ "音频": "Audio",+ "素材": "Media",+ "背景": "Background",+ "动效库": "Motion library",+ // 轨道 / 单元种类+ "转场": "Transitions",+ "字幕": "Captions",+ "叠加层": "Overlays",+ "镜头": "Shots",+ "音乐": "Music",+ "音效": "SFX",+ "轨道": "Track",+ "组件": "Component",+ // 工作台原生卡+ "通用文字": "Basic text",+ "视频素材": "Video clip",+ "图片素材": "Image",+ "纸底": "Paper",+ "暖白": "Warm white",+ "纯白": "Pure white",+ "墨黑": "Ink black",+ "中心提亮": "Center glow",+ "字卡": "Title card",+ "解说字幕条": "Caption strip",+ "暖白闪转场": "Warm flash cut",+ // schema 字段 / 选项+ "底色": "Fill color",+ "亮斑强度": "Glow strength",+ "文字内容": "Text",+ "字号": "Font size",+ "文字颜色": "Text color",+ "字重": "Weight",+ "常规 400": "Regular 400",+ "半粗 600": "Semibold 600",+ "加粗 700": "Bold 700",+ "特粗 900": "Black 900",+ "字距": "Letter spacing",+ "对齐": "Align",+ "左对齐": "Left",+ "居中": "Center",+ "右对齐": "Right",+ "入场动画": "Entrance",+ "淡入上浮": "Fade up",+ "砸出": "Slam",+ "遮罩揭示": "Mask reveal",+ "打字机": "Typewriter",+ "纯淡入": "Fade",+ "无": "None",+ "入场延迟": "Delay",+ "动画时长": "Animation duration",+ "背景色": "Background color",+ "透明背景": "Transparent background",+ "文件(public/ 下)": "File (under public/)",+ "适配": "Fit",+ "完整显示": "Contain",+ "铺满裁切": "Cover",+ "静音": "Muted",+ "音量": "Volume",+ "文案(*词* = 强调)": "Copy (*word* = accent)",+ "文案(*词* = 琥珀强调)": "Copy (*word* = amber accent)",+ "副标(等宽小字)": "Subtitle (mono)",+ "副标滚动数字": "Subtitle digits",+ "墨色": "Ink",+ "强调色": "Accent",+ "琥珀强调色": "Amber accent",+ "下划线宽": "Underline width",+ "文案": "Copy",+ "解说文案": "Caption copy",+ "底距": "Bottom offset",+ "文字色": "Text color",+ "方点色": "Dot color",+ "全大写": "Uppercase",+ "峰值不透明度": "Peak opacity",+ "暖白色": "Warm white",+ // 模板成片清单(template/src/workbench.ts)的字段与镜头标签+ "字标": "Wordmark",+ "字标字号": "Wordmark size",+ "眉题(打字机)": "Kicker (typewriter)",+ "眉题字号": "Kicker size",+ "悬浮批注": "Floating note",+ "上行": "line 1",+ "下行(斜体+高亮)": "line 2 (italic + highlight)",+ "批注字号": "Note size",+ "灰墨(眉题)": "Muted ink (kicker)",+ "灰墨": "Muted ink",+ "副标灰墨": "Subtitle muted ink",+ "搜索框输入的词": "Search query",+ "琥珀强调色(光标 / 点击涟漪 / 选中框)": "Amber accent (cursor / ripple / selection)",+ "嵌入接缝色": "Seam color",+ "右上角标题": "Top-right title",+ "右上角副标": "Top-right subtitle",+ "右上角眉题": "Top-right kicker",+ "计数器字号": "Counter size",+ "左栏往期周报(每行:周|日期|标题)": "Past weeks (one per line: week|date|title)",+ "副标": "Subtitle",+ "副标字号": "Subtitle size",+ "S1 墨线开场 → 全景 → 主角卡": "S1 Ink line open → wide → hero card",+ "字卡① one place": "Title ① one place",+ "S3 牌堆 → 发牌 → 搜索筛选": "S3 Pile → deal → search & filter",+ "S4 详情页宏观特写": "S4 Detail page macro",+ "字卡② Paper Radar": "Title ② Paper Radar",+ "S6 论文雷达堆叠": "S6 Paper radar stack",+ "字卡③ weekly report": "Title ③ weekly report",+ "S8 周报自己写自己": "S8 Weekly report writes itself",+ "字卡④ same page": "Title ④ same page",+ "S10 合影组装 → 铅印字标": "S10 Group shot → letterpress wordmark",+ // 主题预设名的中文半段(英文半段就是英文名,见 themeLabel)+ "纸质": "Paper",+ "现代浅色": "Modern light",+ "暗黑": "Midnight",+ "清新鼠尾草": "Sage",+ "珊瑚点缀": "Coral",+ "柔和鸢尾": "Iris",+ "深海蓝": "Deep ocean",+ "黑曜紫": "Obsidian violet",+ "复古牛皮纸": "Vintage kraft",+ ...DEMO_CATEGORY_EN,+};+const LABELS_EN_ZH: Record<string, string> = Object.fromEntries(+ Object.entries(LABELS_ZH_EN).map(([zh, en]) => [en, zh]),+);+// 带数字的标签:「轨道 3」「音效 2」「Track 3」「SFX 2」→ 前缀查词典、数字照抄;闪白转场标签单独一条+const PATTERNS: [RegExp, string, RegExp, string][] = [+ [/^闪白 @(\d+)f$/, "Flash @$1f", /^Flash @(\d+)f$/, "闪白 @$1f"],+];+const NUMBERED = /^(.*\S) (\d+)$/;++const translateSegment = (s: string, to: Locale): string => {+ const dict = to === "en" ? LABELS_ZH_EN : LABELS_EN_ZH;+ const hit = dict[s];+ if (hit) return hit;+ for (const [zhRe, enOut, enRe, zhOut] of PATTERNS) {+ if (to === "en" && zhRe.test(s)) return s.replace(zhRe, enOut);+ if (to === "zh" && enRe.test(s)) return s.replace(enRe, zhOut);+ }+ const m = NUMBERED.exec(s);+ if (m && dict[m[1]]) return `${dict[m[1]]} ${m[2]}`;+ return s;+};++/** 内容标签按当前语言展示:中文原文 ↔ 英文;查不到原样返回。" · " 复合标签逐段翻译。 */+export const tx = (s: string | undefined | null): string => {+ if (!s) return "";+ const to = useLocale.getState().locale;+ const whole = translateSegment(s, to);+ if (whole !== s || !s.includes(" · ")) return whole;+ return s.split(" · ").map((seg) => translateSegment(seg, to)).join(" · ");+};+export const useTx = () => {+ useLocale((s) => s.locale);+ return tx;+};++/** 卡片名 / 摘要:demo 卡有画廊生成的英文(nameEn / summaryEn),其余走词典 */+export const cardName = (card: Pick<CardDef, "name" | "nameEn">): string =>+ useLocale.getState().locale === "en" && card.nameEn ? card.nameEn : tx(card.name);+export const cardSummary = (card: Pick<CardDef, "summary" | "summaryEn">): string | undefined =>+ useLocale.getState().locale === "en" ? (card.summaryEn ?? (card.summary ? tx(card.summary) : undefined)) : card.summary;++/** 主题预设名写成「中文 · English」:中文界面取前半,英文界面取后半;单段名走词典 */+export const themeLabel = (label: string): string => {+ const parts = label.split(" · ");+ if (parts.length === 2) return useLocale.getState().locale === "zh" ? parts[0] : parts[1];+ return tx(label);+};diff --git a/workbench/src/palettePresets.ts b/workbench/src/palettePresets.tsindex 66a50cf..e150dce 100644--- a/workbench/src/palettePresets.ts+++ b/workbench/src/palettePresets.ts@@ -1,25 +1,26 @@import type { WorkbenchManifest } from './cards/manifest';import type { ProjectData } from './types';import { selectedTheme, validThemeColors } from './theme';+import { t, themeLabel } from './i18n';export type PalettePreset = {format:'shotcraft-palette';version:1;name:string;baseThemeId:string;colors:Record<string,string>};export const paletteFromProject = (m:WorkbenchManifest | null,p:ProjectData,name:string):PalettePreset => {const theme=selectedTheme(m,p.themeId);- if(!theme?.palette)throw Error('请先选择支持配色的主题。');- return {format:'shotcraft-palette',version:1,name:name.trim().slice(0,60)||`${theme.label.split(' · ')[0]} · 自定义`,baseThemeId:theme.id,colors:{...theme.palette,...validThemeColors(m,p.themeId,p.themeColors)}};+ if(!theme?.palette)throw Error(t("palette.needTheme"));+ return {format:'shotcraft-palette',version:1,name:name.trim().slice(0,60)||`${themeLabel(theme.label)} · ${t("palette.custom")}`,baseThemeId:theme.id,colors:{...theme.palette,...validThemeColors(m,p.themeId,p.themeColors)}};};export const parsePalette = (text:string,m:WorkbenchManifest | null):PalettePreset => {- if(text.length>65536)throw Error('配色文件过大,请选择小于 64 KB 的 JSON。');+ if(text.length>65536)throw Error(t("palette.tooBig"));let value:unknown;- try{value=JSON.parse(text)}catch{throw Error('文件不是有效的 JSON。')}- if(!value||typeof value!=='object')throw Error('配色文件格式不正确。');+ try{value=JSON.parse(text)}catch{throw Error(t("palette.badJson"))}+ if(!value||typeof value!=='object')throw Error(t("palette.badFormat"));const p=value as Partial<PalettePreset>;- if(p.format!=='shotcraft-palette'||p.version!==1||typeof p.name!=='string'||!p.name.trim()||p.name.length>60)throw Error('请选择 ShotCraft 导出的配色 JSON(版本 1)。');+ if(p.format!=='shotcraft-palette'||p.version!==1||typeof p.name!=='string'||!p.name.trim()||p.name.length>60)throw Error(t("palette.badVersion"));const theme=m?.themes?.find(t=>t.id===p.baseThemeId);- if(!theme?.palette)throw Error('当前工程不支持这份配色的基础主题。');- if(!p.colors||typeof p.colors!=='object'||Array.isArray(p.colors))throw Error('配色缺少颜色字段。');+ if(!theme?.palette)throw Error(t("palette.badTheme"));+ if(!p.colors||typeof p.colors!=='object'||Array.isArray(p.colors))throw Error(t("palette.noColors"));const keys=Object.keys(theme.palette);- if(Object.keys(p.colors).length!==keys.length||keys.some(k=>typeof p.colors?.[k]!=='string'||!/^#[0-9a-f]{6}$/i.test(p.colors[k])))throw Error('颜色字段必须完整,并使用 #RRGGBB 格式。');+ if(Object.keys(p.colors).length!==keys.length||keys.some(k=>typeof p.colors?.[k]!=='string'||!/^#[0-9a-f]{6}$/i.test(p.colors[k])))throw Error(t("palette.badColors"));return {format:'shotcraft-palette',version:1,name:p.name.trim(),baseThemeId:theme.id,colors:Object.fromEntries(keys.map(k=>[k,p.colors![k]]))};};export const applyPalette = (p:ProjectData,preset:PalettePreset):ProjectData => ({...p,themeId:preset.baseThemeId,themeColors:{...preset.colors}});diff --git a/workbench/src/panels/Inspector.tsx b/workbench/src/panels/Inspector.tsxindex bdc037c..e76705f 100644--- a/workbench/src/panels/Inspector.tsx+++ b/workbench/src/panels/Inspector.tsx@@ -5,6 +5,7 @@ import { CARDS } from "../cards/registry";import { findClip, useStore } from "../store";import { MANIFEST } from '../cards/projectCards';import { themedProps } from '../theme';+import { cardName, tx, useT, useTx } from "../i18n";/** 单个属性控件:按 schema 字段类型渲染 */const PropControl: React.FC<{@@ -92,7 +93,7 @@ const PropControl: React.FC<{>{field.options.map((o) => (<option key={o.value} value={o.value}>- {o.label}+ {tx(o.label)}</option>))}</select>@@ -119,6 +120,8 @@ const Row: React.FC<{ label: string; children: React.ReactNode }> = ({ label, ch);export const Inspector: React.FC = () => {+ const t = useT();+ const tx = useTx();const project = useStore((s) => s.project);const selectedClipId = useStore((s) => s.selectedClipId);const updateClip = useStore((s) => s.updateClip);@@ -133,18 +136,18 @@ export const Inspector: React.FC = () => {if (!hit) {return (<div className="inspector">- <div className="panel-title">属性</div>+ <div className="panel-title">{t("insp.title")}</div><div className="inspector-empty dim">- 选中时间轨上的片段后,+ {t("insp.empty1")}<br />- 在这里调整它的文字、颜色、+ {t("insp.empty2")}<br />- 动画节奏、变速与图层属性。+ {t("insp.empty3")}<br /><br />- 快捷键:空格 播放 · S 分割+ {t("insp.shortcuts1")}<br />- Delete 删除 · ⌘Z 撤销 · ⌘D 复制+ {t("insp.shortcuts2")}</div></div>);@@ -168,18 +171,18 @@ export const Inspector: React.FC = () => {return (<div className="inspector"><div className="panel-title">- {card?.name ?? clip.cardId}+ {card ? cardName(card) : clip.cardId}<span className="dim" style={{ marginLeft: 8, fontWeight: 400 }}>- {track.name}+ {tx(track.name)}</span></div><div className="inspector-scroll">{card && card.schema.length > 0 && (<section>- <div className="sec-title">内容与样式</div>+ <div className="sec-title">{t("insp.contentStyle")}</div>{card.schema.map((field) => (- <Row key={field.key} label={field.label}>+ <Row key={field.key} label={tx(field.label)}><PropControlfield={field}value={themedProps(MANIFEST, card, project.themeId, clip.props, project.themeColors)[field.key] ?? field.default}@@ -192,8 +195,8 @@ export const Inspector: React.FC = () => {)}<section>- <div className="sec-title">时间与变速</div>- <Row label="起点">+ <div className="sec-title">{t("insp.timing")}</div>+ <Row label={t("insp.start")}><span className="ctl-row"><inputtype="number"@@ -208,7 +211,7 @@ export const Inspector: React.FC = () => {<span className="unit">s</span></span></Row>- <Row label="时长">+ <Row label={t("insp.duration")}><span className="ctl-row"><inputtype="number"@@ -225,7 +228,7 @@ export const Inspector: React.FC = () => {<span className="unit">s</span></span></Row>- <Row label="变速">+ <Row label={t("insp.speed")}><span className="ctl-row"><inputtype="range"@@ -255,7 +258,7 @@ export const Inspector: React.FC = () => {))}</span></Row>- <Row label="裁入点">+ <Row label={t("insp.inPoint")}><span className="ctl-row"><inputtype="number"@@ -276,7 +279,7 @@ export const Inspector: React.FC = () => {<Row label=""><buttonclassName="mini"- title="时长恢复为卡片原始时长(按当前变速换算)"+ title={t("insp.restore.title")}onClick={() => {begin();updateClip(clip.id, {@@ -287,21 +290,20 @@ export const Inspector: React.FC = () => {});}}>- ↺ 恢复原始时长+ {t("insp.restore")}</button></Row>)}{fpsMismatch && (<div className="dim" style={{ fontSize: 11, lineHeight: 1.5, padding: "4px 0 2px" }}>- 此卡按 {srcFps}fps 编排,工程 {fps}fps:上轨时已换算时长并以 {(srcFps / fps).toFixed(2)}× 变速保持节奏。- 卡内若按 useVideoConfig().fps 计时(spring 等),节奏仍会偏 {(fps / srcFps).toFixed(2)}×。+ {t("insp.fpsMismatch", { src: srcFps, fps, ratio: (srcFps / fps).toFixed(2), inv: (fps / srcFps).toFixed(2) })}</div>)}</section><section>- <div className="sec-title">图层</div>- <Row label="不透明度">+ <div className="sec-title">{t("insp.layer")}</div>+ <Row label={t("insp.opacity")}><span className="ctl-row"><inputtype="range"@@ -315,7 +317,7 @@ export const Inspector: React.FC = () => {<span className="slider-val">{Math.round(clip.opacity * 100)}%</span></span></Row>- <Row label="缩放">+ <Row label={t("insp.scale")}><span className="ctl-row"><inputtype="range"@@ -329,7 +331,7 @@ export const Inspector: React.FC = () => {<span className="slider-val">{clip.scale.toFixed(2)}</span></span></Row>- <Row label="位移 X">+ <Row label={t("insp.x")}><span className="ctl-row"><inputtype="number"@@ -341,7 +343,7 @@ export const Inspector: React.FC = () => {<span className="unit">px</span></span></Row>- <Row label="位移 Y">+ <Row label={t("insp.y")}><span className="ctl-row"><inputtype="number"@@ -357,7 +359,7 @@ export const Inspector: React.FC = () => {<section><button className="btn danger" onClick={() => removeClip(clip.id)}>- 删除片段+ {t("insp.deleteClip")}</button></section></div>diff --git a/workbench/src/panels/LibraryPanel.tsx b/workbench/src/panels/LibraryPanel.tsxindex e4f23eb..5e5c4fa 100644--- a/workbench/src/panels/LibraryPanel.tsx+++ b/workbench/src/panels/LibraryPanel.tsx@@ -12,12 +12,13 @@ import { BGM_LIB, MEDIA_ITEMS, SFX_LIB } from "../mediaManifest";import { PROJ_DIR, PROJ_HAS_MANIFEST, PROJ_LINKED } from "../projMeta";import { setDragPayload } from "../dnd";import { ThemePanel } from './ThemePanel';+import { cardName, cardSummary, useT, useTx } from "../i18n";const TABS = [- { id: "media", label: "素材" },- { id: "cards", label: "动效库" },- { id: "sfx", label: "音效" },- { id: "themes", label: "主题" },+ { id: "media", key: "lib.tab.media" },+ { id: "cards", key: "lib.tab.cards" },+ { id: "sfx", key: "lib.tab.sfx" },+ { id: "themes", key: "lib.tab.themes" },] as const;type TabId = (typeof TABS)[number]["id"];@@ -150,6 +151,8 @@ const groupBy = <T,>(items: T[], key: (t: T) => string) => {};export const LibraryPanel: React.FC = () => {+ const t = useT();+ const tx = useTx();const setPreview = useStore((s) => s.setPreview);const [tab, setTab] = useState<TabId>(PROJ_LINKED ? "media" : "cards");// 折叠分组默认收起,点击标题展开@@ -176,7 +179,7 @@ export const LibraryPanel: React.FC = () => {draggableonDragStart={(e) => setDragPayload(e, payload)}onClick={onClick}- title={`${name}${title ? `\n${title}` : ""}\n点击预览,拖到时间轨添加`}+ title={`${name}${title ? `\n${title}` : ""}\n${t("lib.cellHint")}`}>{children}<div className="lib-cell-name">{name}</div>@@ -187,11 +190,11 @@ export const LibraryPanel: React.FC = () => {/** 动效卡网格单元 */const CardCell: React.FC<{ card: CardDef }> = ({ card }) => (<Cell- name={card.name}- meta={`${(card.durationInFrames / cardFps(card)).toFixed(1)}s${card.schema.length > 0 ? " · 可调参" : ""}`}- title={card.summary}+ name={cardName(card)}+ meta={`${(card.durationInFrames / cardFps(card)).toFixed(1)}s${card.schema.length > 0 ? t("lib.tunable") : ""}`}+ title={cardSummary(card)}onClick={() => setPreview({ kind: "card", cardId: card.id })}- payload={{ cardId: card.id, label: card.name }}+ payload={{ cardId: card.id }}>{card.preview ? <LazyLoopVideo src={`/${card.preview}`} /> : <LazyCardLoop card={card} />}</Cell>@@ -210,7 +213,7 @@ export const LibraryPanel: React.FC = () => {draggableonDragStart={(e) => setDragPayload(e, payload)}onClick={onClick}- title={`${name} · 点击预览,拖到时间轨添加`}+ title={`${name} · ${t("lib.cellHint")}`}><span className="lib-dot" style={{ background: dot }} /><span className="lib-name">{name}</span>@@ -251,17 +254,17 @@ export const LibraryPanel: React.FC = () => {return (<div className="library"><div className="lib-tabs">- {TABS.map((t) => (+ {TABS.map((tb) => (<button- key={t.id}- className={`lib-tab${tab === t.id ? " on" : ""}`}- aria-pressed={tab === t.id}+ key={tb.id}+ className={`lib-tab${tab === tb.id ? " on" : ""}`}+ aria-pressed={tab === tb.id}onClick={() => {- setTab(t.id);- if (t.id === 'themes') setPreview(null);+ setTab(tb.id);+ if (tb.id === 'themes') setPreview(null);}}>- {t.label}+ {t(tb.key)}</button>))}</div>@@ -273,30 +276,28 @@ export const LibraryPanel: React.FC = () => {{MANIFEST ? (<buttonclassName="btn wide"- title={`把成片按 src/workbench.ts 清单拆成镜头 / 转场 / 字幕 / 叠加层 / 音效 / 音乐的多轨工程(可撤销)\n${PROJ_DIR}`}+ title={t("lib.importFilm.title", { dir: PROJ_DIR })}onClick={() => importProject()}>- ⇣ 导入成片:{MANIFEST.name}+ {t("lib.importFilm", { name: MANIFEST.name })}</button>) : (<div className="lib-cat" style={{ whiteSpace: "normal", lineHeight: 1.5 }}>- {PROJ_LINKED- ? `已链接 ${PROJ_DIR},但工程没有 src/workbench.ts 清单,无法拆解导入(写法见 references/workbench.md)`- : "未接入成片工程。在 workbench/ 目录运行:node scripts/open.mjs <成片工程目录>"}+ {PROJ_LINKED ? t("lib.linkedNoManifest", { dir: PROJ_DIR }) : t("lib.notLinked")}</div>)}{projectCards.length > 0 && (<>- <div className="lib-cat">成片单元(可再加一份)</div>+ <div className="lib-cat">{t("lib.filmUnits")}</div><div className="lib-grid">{projectCards.map((card) => (<Cellkey={card.id}- name={card.name}- meta={`${(card.durationInFrames / cardFps(card)).toFixed(1)}s${card.schema.length ? " · 可调参" : ""}`}+ name={cardName(card)}+ meta={`${(card.durationInFrames / cardFps(card)).toFixed(1)}s${card.schema.length ? t("lib.tunable") : ""}`}onClick={() => setPreview({ kind: "card", cardId: card.id })}- payload={{ cardId: card.id, label: card.name }}+ payload={{ cardId: card.id }}><LazyCardLoop card={card} /></Cell>@@ -305,7 +306,7 @@ export const LibraryPanel: React.FC = () => {</>)}- {projectVisual.length > 0 && <div className="lib-cat">素材文件(工程 public/)</div>}+ {projectVisual.length > 0 && <div className="lib-cat">{t("lib.mediaFiles")}</div>}{groupBy(projectVisual, (m) => m.dir || "/").map(([dir, items]) => (<Group key={dir} id={`media:${dir}`} label={dir} count={items.length} defaultOpen={items.length <= 12}><div className="lib-grid">@@ -313,7 +314,7 @@ export const LibraryPanel: React.FC = () => {<Cellkey={m.file}name={m.name}- meta={m.kind === "video" ? "视频" : "图片"}+ meta={m.kind === "video" ? t("lib.video") : t("lib.image")}onClick={() => setPreview({ kind: m.kind, file: m.file, label: m.name })}payload={m.kind === "video"@@ -336,7 +337,7 @@ export const LibraryPanel: React.FC = () => {{tab === "cards" &&motionGroups.map((g) => (- <Group key={g.cat} id={`cat:${g.cat}`} label={g.cat} count={g.cards.length} defaultOpen={g.cat === "工作台"}>+ <Group key={g.cat} id={`cat:${g.cat}`} label={tx(g.cat)} count={g.cards.length} defaultOpen={g.cat === "工作台"}><div className="lib-grid">{g.cards.map((card) => (<CardCell key={card.id} card={card} />@@ -348,13 +349,13 @@ export const LibraryPanel: React.FC = () => {{tab === "sfx" && (<>{projectAudio.length > 0 && (- <Group id="sfx:proj" label="本片音频(工程 public/)" count={projectAudio.length} defaultOpen>+ <Group id="sfx:proj" label={t("lib.projectAudio")} count={projectAudio.length} defaultOpen>{projectAudio.map((m) => (<Rowkey={m.file}dot="#ff9f0a"name={m.name}- meta={usage.has(m.file) ? `片中×${usage.get(m.file)}` : "未用"}+ meta={usage.has(m.file) ? t("lib.usedIn", { n: usage.get(m.file) ?? 0 }) : t("lib.unused")}onClick={() => setPreview({ kind: "audio", file: m.file, label: m.name })}payload={audioPayload(m.file, m.name.replace(/\.[^.]+$/, ""), 0.4, 90)}/>@@ -362,7 +363,7 @@ export const LibraryPanel: React.FC = () => {</Group>)}{BGM_LIB.length > 0 && (- <Group id="sfx:bgm" label="BGM 备选(assets/audio/bgm)" count={BGM_LIB.length}>+ <Group id="sfx:bgm" label={t("lib.bgm")} count={BGM_LIB.length}>{BGM_LIB.map((b) => (<Rowkey={b.file}@@ -375,7 +376,7 @@ export const LibraryPanel: React.FC = () => {</Group>)}{groupBy(SFX_LIB, (s) => s.cat).map(([cat, items]) => (- <Group key={cat} id={`sfx:${cat}`} label={`音效库 · ${cat}`} count={items.length}>+ <Group key={cat} id={`sfx:${cat}`} label={t("lib.sfxLib", { cat: tx(cat) })} count={items.length}>{items.map((s) => (<Rowkey={s.file}@@ -392,12 +393,12 @@ export const LibraryPanel: React.FC = () => {</div><div className="lib-foot dim">- {tab === 'themes' ? '切换主题可撤销 · 随工程自动保存' : <>- 动效 {motionCards.length} 卡({motionCards.filter((c) => c.schema.length > 0).length} 张可调参)- · 音效库 {SFX_LIB.length}- {PROJ_LINKED && PROJ_HAS_MANIFEST ? ` · 成片单元 ${projectCards.length}` : ""}+ {tab === 'themes' ? t("lib.foot.themes") : <>+ {t("lib.foot.cards", { n: motionCards.length, m: motionCards.filter((c) => c.schema.length > 0).length })}+ {t("lib.foot.sfx", { n: SFX_LIB.length })}+ {PROJ_LINKED && PROJ_HAS_MANIFEST ? t("lib.foot.units", { n: projectCards.length }) : ""}<br />- 点击预览 · 拖拽到时间轨添加+ {t("lib.foot.hint")}</>}</div></div>diff --git a/workbench/src/panels/ThemePanel.tsx b/workbench/src/panels/ThemePanel.tsxindex 7970a2a..a85dc38 100644--- a/workbench/src/panels/ThemePanel.tsx+++ b/workbench/src/panels/ThemePanel.tsx@@ -3,6 +3,7 @@ import { MANIFEST } from '../cards/projectCards';import { useStore } from '../store';import { selectedTheme, switchTheme, validThemeColors } from '../theme';import { applyPalette, paletteFromProject, parsePalette, type PalettePreset } from '../palettePresets';+import { t, themeLabel, useT } from '../i18n';const savedKey = `shotcraft:palettes:${MANIFEST?.name ?? 'default'}`;type SavedPalette = {id:string;preset:PalettePreset};@@ -16,7 +17,7 @@ const readSaved = ():SavedPalette[] => {}catch{return []}};-const fields = [['page','背景'],['surface','卡片'],['text','文字'],['muted','次要文字'],['accent','强调色'],['field','浅色填充'],['border','边框']] as const;+const fields = [['page','theme.field.page'],['surface','theme.field.surface'],['text','theme.field.text'],['muted','theme.field.muted'],['accent','theme.field.accent'],['field','theme.field.field'],['border','theme.field.border']] as const;const ColorField = ({label,value,onChange}: {label:string;value:string;onChange:(value:string,begin?:boolean)=>void}) => {const [draft,setDraft] = useState(value);const picker = useRef<HTMLInputElement>(null);@@ -33,17 +34,18 @@ const ColorField = ({label,value,onChange}: {label:string;value:string;onChange:const valid = /^#[0-9a-f]{6}$/i.test(draft);const commit = () => { if(valid && draft !== value) onChange(draft); else setDraft(value); };return <label className="theme-color-row"><span>{label}</span>- <input ref={picker} type="color" aria-label={`${label}取色`} value={value}+ <input ref={picker} type="color" aria-label={t("theme.pick.aria", { label })} value={value}onClick={endEdit} onBlur={endEdit}onKeyDown={e=>{if(!e.repeat && (e.key==='Enter' || e.key===' '))endEdit();}}onChange={e=>{onChange(e.target.value,!editing.current);editing.current=true;}} />- <input type="text" aria-label={`${label}色值`} value={draft} maxLength={7} spellCheck={false}+ <input type="text" aria-label={t("theme.hex.aria", { label })} value={draft} maxLength={7} spellCheck={false}aria-invalid={!valid} onChange={e=>setDraft(e.target.value)} onBlur={commit}onKeyDown={e=>{if(e.key==='Enter')e.currentTarget.blur();if(e.key==='Escape')setDraft(value);}} /></label>;};export const ThemePanel = () => {+ const t = useT();const project = useStore(s=>s.project);const [saved,setSaved] = useState(readSaved);const [name,setName] = useState('');@@ -52,10 +54,10 @@ export const ThemePanel = () => {const colorHistory = useRef<ReturnType<typeof useStore.getState>["past"] | null>(null);const persist = (next:SavedPalette[]) => {try{localStorage.setItem(savedKey,JSON.stringify(next));setSaved(next);return true}- catch{setMessage('保存失败:浏览器存储不可用,请导出配色备份。');return false}+ catch{setMessage(t("theme.saveFailed"));return false}};const apply = (preset:PalettePreset) => {- const s=useStore.getState();s.setPreview(null);s.setProject(applyPalette(s.project,preset));setName(preset.name);setMessage(`已应用「${preset.name}」`);+ const s=useStore.getState();s.setPreview(null);s.setProject(applyPalette(s.project,preset));setName(preset.name);setMessage(t("theme.applied", { name: preset.name }));};const themes = MANIFEST?.themes ?? [];const current = selectedTheme(MANIFEST,project.themeId);@@ -74,50 +76,50 @@ export const ThemePanel = () => {store.setThemeColors(Object.keys(next).length ? next : undefined);colorHistory.current=useStore.getState().past;};- return <section className="theme-panel" aria-label="影片主题">- <div className="theme-panel-heading">预设主题</div>- <p className="theme-panel-hint">选择一套风格,再调整配色。</p>+ return <section className="theme-panel" aria-label={t("theme.aria")}>+ <div className="theme-panel-heading">{t("theme.presets")}</div>+ <p className="theme-panel-hint">{t("theme.hint")}</p>{themes.length ? <div className="theme-options">{themes.map(theme=>{const active=theme.id===current?.id;const colors=theme.palette ?? {page:theme.background ?? '#f2eee6',text:'#13110f',accent:'#955905'};- return <button key={theme.id} className={`theme-option${active?' active':''}`} aria-label={theme.label} aria-pressed={active}+ return <button key={theme.id} className={`theme-option${active?' active':''}`} aria-label={themeLabel(theme.label)} aria-pressed={active}onClick={()=>{const store=useStore.getState();store.setPreview(null);if(!active)store.setProject(switchTheme(store.project,MANIFEST,theme.id));}}><span className="theme-palette" aria-hidden="true">{[colors.page,colors.surface ?? colors.page,colors.accent].map((c,i)=><span key={i} style={{background:c}} />)}</span>- <span className="theme-option-label"><strong>{theme.label.split(' · ')[0]}</strong><span>{active?'✓':''}</span></span>+ <span className="theme-option-label"><strong>{themeLabel(theme.label)}</strong><span>{active?'✓':''}</span></span></button>;- })}</div> : <p className="theme-panel-empty">当前工程尚未提供主题。</p>}- {!!saved.length && <div className="saved-palettes"><div className="theme-panel-heading">我的主题</div>{saved.map(item=><div key={item.id} className="saved-palette">+ })}</div> : <p className="theme-panel-empty">{t("theme.none")}</p>}+ {!!saved.length && <div className="saved-palettes"><div className="theme-panel-heading">{t("theme.mine")}</div>{saved.map(item=><div key={item.id} className="saved-palette"><button onClick={()=>apply(item.preset)} title={item.preset.name}><span style={{background:item.preset.colors.accent}} />{item.preset.name}</button>- <button aria-label={`删除 ${item.preset.name}`} onClick={()=>{if(persist(saved.filter(p=>p.id!==item.id)))setMessage(`已删除「${item.preset.name}」`);}}>×</button>+ <button aria-label={t("theme.delete.aria", { name: item.preset.name })} onClick={()=>{if(persist(saved.filter(p=>p.id!==item.id)))setMessage(t("theme.deleted", { name: item.preset.name }));}}>×</button></div>)}</div>}- <div className="theme-editor" aria-label="替换配色">- <div className="theme-editor-heading"><span className="theme-panel-heading">替换配色</span><button className="theme-reset" disabled={!modified} onClick={()=>{const s=useStore.getState();s.setPreview(null);s.setProject({...s.project,themeColors:undefined});}}>恢复预设</button></div>- <input className="palette-name" aria-label="配色名称" placeholder="配色名称(可选)" value={name} maxLength={60} onChange={e=>setName(e.target.value)} />+ <div className="theme-editor" aria-label={t("theme.editor")}>+ <div className="theme-editor-heading"><span className="theme-panel-heading">{t("theme.editor")}</span><button className="theme-reset" disabled={!modified} onClick={()=>{const s=useStore.getState();s.setPreview(null);s.setProject({...s.project,themeColors:undefined});}}>{t("theme.reset")}</button></div>+ <input className="palette-name" aria-label={t("theme.name.aria")} placeholder={t("theme.name.placeholder")} value={name} maxLength={60} onChange={e=>setName(e.target.value)} /><div className="palette-actions"><button className="btn" disabled={!current?.palette} onClick={()=>{- if(saved.length>=50){setMessage('已保存 50 套配色,请先删除不再使用的主题。');return;}+ if(saved.length>=50){setMessage(t("theme.limit"));return;}const preset=paletteFromProject(MANIFEST,useStore.getState().project,name);- if(persist([...saved,{id:crypto.randomUUID(),preset}])){setName(preset.name);setMessage(`已保存「${preset.name}」,仅保存在此浏览器。`);}- }}>保存配色</button>- <button className="btn" onClick={()=>fileInput.current?.click()}>导入配色</button>+ if(persist([...saved,{id:crypto.randomUUID(),preset}])){setName(preset.name);setMessage(t("theme.saved", { name: preset.name }));}+ }}>{t("theme.save")}</button>+ <button className="btn" onClick={()=>fileInput.current?.click()}>{t("theme.import")}</button><button className="btn" disabled={!current?.palette} onClick={()=>{const preset=paletteFromProject(MANIFEST,useStore.getState().project,name);const url=URL.createObjectURL(new Blob([JSON.stringify(preset,null,2)],{type:'application/json'}));const a=document.createElement('a');a.href=url;a.download=`${preset.name.replace(/[\\/:*?"<>|]/g,'-')}.palette.json`;a.click();setTimeout(()=>URL.revokeObjectURL(url),1000);- setMessage('配色已导出为 JSON。');- }}>导出配色</button>+ setMessage(t("theme.exported"));+ }}>{t("theme.export")}</button></div>- <input ref={fileInput} type="file" hidden accept=".json,application/json" aria-label="导入配色文件" onChange={async e=>{+ <input ref={fileInput} type="file" hidden accept=".json,application/json" aria-label={t("theme.file.aria")} onChange={async e=>{const file=e.target.files?.[0];e.target.value='';if(!file)return;- try{if(file.size>65536)throw Error('配色文件不能超过 64 KB。');apply(parsePalette(await file.text(),MANIFEST));setMessage('已导入并应用,点击「保存配色」可加入我的主题。');}- catch(error){setMessage(error instanceof Error?error.message:'导入失败。');}+ try{if(file.size>65536)throw Error(t("theme.tooBig"));apply(parsePalette(await file.text(),MANIFEST));setMessage(t("theme.imported"));}+ catch(error){setMessage(error instanceof Error?error.message:t("theme.importFailed"));}}} />{!!message && <p className="theme-panel-hint" role="status">{message}</p>}{current?.palette ? <>- <p className="theme-panel-hint">{modified?'已自定义 · ':'点击色块或输入 HEX · '}切换预设会重置配色</p>- {fields.filter(([key])=>palette[key]).map(([key,label])=><ColorField key={`${current.id}:${key}`} label={label} value={palette[key]} onChange={(value,begin)=>updateColor(key,value,begin)} />)}- <p className="theme-panel-note">同步预览与导出,可撤销。单独调整过的镜头颜色优先保留。</p>- </> : <p className="theme-panel-note">{themes.length?'纸质主题保留原始截图质感。选择其他预设后,可调整整套配色。':'工程提供可编辑配色后,会在这里显示。'}</p>}+ <p className="theme-panel-hint">{modified?t("theme.customized"):t("theme.clickHint")}{t("theme.switchResets")}</p>+ {fields.filter(([key])=>palette[key]).map(([key,label])=><ColorField key={`${current.id}:${key}`} label={t(label)} value={palette[key]} onChange={(value,begin)=>updateColor(key,value,begin)} />)}+ <p className="theme-panel-note">{t("theme.note")}</p>+ </> : <p className="theme-panel-note">{themes.length?t("theme.paperNote"):t("theme.noPalette")}</p>}</div></section>;};diff --git a/workbench/src/preview/PreviewPanel.tsx b/workbench/src/preview/PreviewPanel.tsxindex 519be1e..f719055 100644--- a/workbench/src/preview/PreviewPanel.tsx+++ b/workbench/src/preview/PreviewPanel.tsx@@ -9,6 +9,7 @@ import { CARDS } from "../cards/registry";import { cardFps, cardSize } from "../cards/types";import { MANIFEST } from '../cards/projectCards';import { themedProps } from '../theme';+import { cardName, t, useLocale, useT } from "../i18n";/** 素材库点击预览:占据画面区,循环播放;主工程 Player 保持挂载(display:none) */const ItemPreview: React.FC<{ item: NonNullable<PreviewItem>; onClose: () => void }> = ({@@ -17,11 +18,12 @@ const ItemPreview: React.FC<{ item: NonNullable<PreviewItem>; onClose: () => voi}) => {const themeId = useStore(s => s.project.themeId);const themeColors = useStore(s => s.project.themeColors);+ const t = useT();let body: React.ReactNode = null;let title = "";if (item.kind === "card") {const card = CARDS[item.cardId];- title = card?.name ?? item.cardId;+ title = card ? cardName(card) : item.cardId;if (card && card.kind !== "audio") {const { width, height } = cardSize(card);body = (@@ -42,7 +44,7 @@ const ItemPreview: React.FC<{ item: NonNullable<PreviewItem>; onClose: () => voi/>);} else {- body = <div className="preview-audio">🔊 音频卡</div>;+ body = <div className="preview-audio">{t("prev.audioCard")}</div>;}} else {title = item.label;@@ -62,11 +64,11 @@ const ItemPreview: React.FC<{ item: NonNullable<PreviewItem>; onClose: () => voi<><div className="preview-stage">{body}</div><div className="transport">- <span className="preview-tag">素材预览</span>+ <span className="preview-tag">{t("prev.tag")}</span><b>{title}</b>- <span className="dim">拖拽素材到时间轨即可添加</span>+ <span className="dim">{t("prev.dragHint")}</span><button className="btn" style={{ marginLeft: "auto" }} onClick={onClose}>- ✕ 返回工程+ {t("prev.back")}</button></div></>@@ -105,10 +107,10 @@ const Transport: React.FC<{return (<div className="transport">- <button className="btn" title="回到开头" onClick={() => seekTo(0)}>+ <button className="btn" title={t("prev.toStart")} onClick={() => seekTo(0)}>⏮</button>- <button className="btn btn-play" title="播放/暂停(空格)" onClick={togglePlay}>+ <button className="btn btn-play" title={t("prev.playPause")} onClick={togglePlay}>{playing ? "⏸" : "▶"}</button><span className="timecode">@@ -116,7 +118,7 @@ const Transport: React.FC<{</span><label className="loop-toggle"><input type="checkbox" checked={loop} onChange={(e) => setLoop(e.target.checked)} />- 循环+ {t("prev.loop")}</label><span className="dim" style={{ marginLeft: "auto" }}>{sizeLabel}@@ -126,6 +128,7 @@ const Transport: React.FC<{};export const PreviewPanel: React.FC = () => {+ useLocale((s) => s.locale); // 语言切换时连带走带条一起重渲染const project = useStore((s) => s.project);const previewItem = useStore((s) => s.previewItem);const setPreview = useStore((s) => s.setPreview);diff --git a/workbench/src/projectImport.ts b/workbench/src/projectImport.tsindex f6db3df..330c7cd 100644--- a/workbench/src/projectImport.ts+++ b/workbench/src/projectImport.ts@@ -4,6 +4,7 @@ import type { ManifestAudio, WorkbenchManifest } from "./cards/manifest";import { manifestKey } from "./cards/manifest";import { MANIFEST, cardIdOfUnit, unitsOf } from "./cards/projectCards";import { inheritedProps } from './theme';+import { t } from "./i18n";const baseClip = (): Omit<ClipData, "id" | "cardId" | "start" | "duration"> => ({inOffset: 0, speed: 1, opacity: 1, scale: 1, x: 0, y: 0, props: {},@@ -71,7 +72,7 @@ export const buildProjectFromManifest = (m: WorkbenchManifest = MANIFEST!): Proj};const order = m.order ?? ["transitions", "captions", "overlays"];- const NAMES = { transitions: "转场", captions: "字幕", overlays: "叠加层" } as const;+ const NAMES = { transitions: t("track.transitions"), captions: t("track.captions"), overlays: t("track.overlays") } as const;const upper = order.map((k) => unitTrack(k.slice(0, -1) as "transition" | "caption" | "overlay", NAMES[k])).filter((t): t is TrackData => !!t);@@ -79,9 +80,9 @@ export const buildProjectFromManifest = (m: WorkbenchManifest = MANIFEST!): Projconst tracks: TrackData[] = [// tracks[0] 为最上层,对应原片 z 序:转场 > 字幕 > 叠加层 > 镜头(缺省序,清单 order 可改)...upper,- unitTrack("shot", "镜头")!,- ...(m.bgm?.length ? packAudio(m.bgm, "音乐", m.total, m.total) : []),- ...(m.sfx?.length ? packAudio(m.sfx, "音效", 90, m.total) : []),+ unitTrack("shot", t("track.shots"))!,+ ...(m.bgm?.length ? packAudio(m.bgm, t("track.music"), m.total, m.total) : []),+ ...(m.sfx?.length ? packAudio(m.sfx, t("track.sfx"), 90, m.total) : []),];return {diff --git a/workbench/src/store.ts b/workbench/src/store.tsindex 62be83c..8654fae 100644--- a/workbench/src/store.ts+++ b/workbench/src/store.ts@@ -8,6 +8,7 @@ import { MANIFEST } from "./cards/projectCards";import { manifestKey } from "./cards/manifest";import { buildProjectFromManifest } from "./projectImport";import { upgradeLegacyTheme } from './theme';+import { t } from "./i18n";export { projectDuration } from "./types";@@ -170,7 +171,7 @@ export const useStore = create<WorkbenchState>((set, get) => ({get().commit();set((s) => ({project: mutateProject(s.project, (d) => {- d.tracks.unshift({ id: uid("track"), name: `轨道 ${d.tracks.length + 1}`, clips: [] });+ d.tracks.unshift({ id: uid("track"), name: t("track.new", { n: d.tracks.length + 1 }), clips: [] });}),}));},diff --git a/workbench/src/timeline/ClipView.tsx b/workbench/src/timeline/ClipView.tsxindex 5948c67..9a46540 100644--- a/workbench/src/timeline/ClipView.tsx+++ b/workbench/src/timeline/ClipView.tsx@@ -3,6 +3,7 @@ import { inOffsetFps } from "../cards/types";import type { ClipData } from "../types";import { CARDS } from "../cards/registry";import { useStore } from "../store";+import { cardName, tx } from "../i18n";const SNAP_PX = 6;@@ -119,7 +120,7 @@ export const ClipView: React.FC<{onPointerDown={onBodyDown}><div className="clip-label">- <span className="clip-name">{clip.label ?? card?.name ?? clip.cardId}</span>+ <span className="clip-name">{clip.label ? tx(clip.label) : card ? cardName(card) : clip.cardId}</span><span className="clip-meta">{durSec}s{clip.speed !== 1 && <em className="badge">{clip.speed}×</em>}diff --git a/workbench/src/timeline/Timeline.tsx b/workbench/src/timeline/Timeline.tsxindex ac286ce..2cd284a 100644--- a/workbench/src/timeline/Timeline.tsx+++ b/workbench/src/timeline/Timeline.tsx@@ -3,6 +3,7 @@ import { projectDuration, useStore } from "../store";import { Ruler } from "./Ruler";import { ClipView } from "./ClipView";import { DRAG_MIME, readDragPayload } from "../dnd";+import { useT, useTx } from "../i18n";const HEADER_W = 140;@@ -18,6 +19,8 @@ const PlayheadLine: React.FC = () => {};export const Timeline: React.FC = () => {+ const t = useT();+ const tx = useTx();const project = useStore((s) => s.project);const ppf = useStore((s) => s.pxPerFrame);const selectedClipId = useStore((s) => s.selectedClipId);@@ -120,38 +123,38 @@ export const Timeline: React.FC = () => {<buttonclassName="btn"disabled={!selectedClipId}- title="在播放头处分割选中片段(S)"+ title={t("tl.split.title")}onClick={() =>selectedClipId && splitClip(selectedClipId, useStore.getState().playhead)}>- ✂ 分割+ {t("tl.split")}</button><buttonclassName="btn"disabled={!selectedClipId}- title="复制选中片段(⌘D)"+ title={t("tl.dup.title")}onClick={() => selectedClipId && duplicateClip(selectedClipId)}>- ⧉ 复制+ {t("tl.dup")}</button><buttonclassName="btn"disabled={!selectedClipId}- title="删除选中片段(Delete)"+ title={t("tl.del.title")}onClick={() => selectedClipId && removeClip(selectedClipId)}>- 🗑 删除+ {t("tl.del")}</button><span className="tl-sep" />- <button className="btn" onClick={addTrack} title="新增一条轨道(加在最上层)">- + 轨道+ <button className="btn" onClick={addTrack} title={t("tl.addTrack.title")}>+ {t("tl.addTrack")}</button><span style={{ marginLeft: "auto" }} />- <button className="btn" onClick={fit} title="缩放到适配全部内容">- ⤢ 适配+ <button className="btn" onClick={fit} title={t("tl.fit.title")}>+ {t("tl.fit")}</button>- <span className="dim">缩放</span>+ <span className="dim">{t("tl.zoom")}</span><inputtype="range"min={0.3}@@ -182,30 +185,30 @@ export const Timeline: React.FC = () => {<divclassName="tl-track-head"style={{ width: HEADER_W }}- title="按住上下拖动调整轨道层序(上层盖住下层)"+ title={t("tl.reorder.title")}onPointerDown={onTrackHeadDown(track.id)}><span className="track-grip" aria-hidden>⋮⋮</span>- <span className="track-name" title={track.name}>- {track.name}+ <span className="track-name" title={tx(track.name)}>+ {tx(track.name)}</span><span className="track-actions"><buttonclassName="mini"- title={track.hidden ? "显示轨道" : "隐藏轨道"}+ title={track.hidden ? t("tl.showTrack") : t("tl.hideTrack")}onClick={() => toggleTrackHidden(track.id)}>{track.hidden ? "🚫" : "👁"}</button><buttonclassName="mini"- title="删除轨道"+ title={t("tl.deleteTrack")}onClick={() => {if (track.clips.length === 0 ||- window.confirm(`删除轨道「${track.name}」及其 ${track.clips.length} 个片段?`)+ window.confirm(t("tl.deleteTrack.confirm", { name: tx(track.name), n: track.clips.length })))removeTrack(track.id);}}