huashu-motion 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.en.md CHANGED
@@ -282,7 +282,7 @@ After the export, `om share` makes a share kit: a GIF under 10 MB (the opening p
282
282
  |---|---|
283
283
  | `om grab` | The product's real material into the project: page screenshots, logo, images, its colours and type, or the screenshots, icons and recordings in its own project folder |
284
284
  | `om new` · `om templates` | Start a project, from one of 12 templates |
285
- | `om studio` | Live preview, scene strip, direct edits, frame comments |
285
+ | `om studio` | Live preview, scene strip, direct edits, frame comments. UI in 中文 / English / Español: follows the browser, or `--lang es` / `OM_LANG=es` |
286
286
  | `om inbox --wait` · `om look` · `om done` | Agent side: take the next comment, see the spot, report back |
287
287
  | `om sound` · `om voice` · `om samples` | Music and effects, narration, the instrument pack |
288
288
  | `om check` · `om qa` · `om still` | Before and after rendering |
package/README.md CHANGED
@@ -335,7 +335,7 @@ skill最大的一块是导演方法:先读产品、找出它的气质,再选
335
335
  |---|---|
336
336
  | `om grab` | 把产品的真实素材收进项目:网页截图、logo、配图、品牌色和字体,或本地工程里的截图、图标、录屏 |
337
337
  | `om new` · `om templates` | 新建项目,可以从12个模板起步 |
338
- | `om studio` | 编辑器:实时预览、场景条、直接改值、在画面上留评论 |
338
+ | `om studio` | 编辑器:实时预览、场景条、直接改值、在画面上留评论。界面支持中文 / English / Español:跟随浏览器语言,或 `--lang es` / `OM_LANG=es` |
339
339
  | `om inbox --wait` · `om look` · `om done` | agent那一侧:接下一条评论、看你点的位置、回报改了什么 |
340
340
  | `om sound` · `om voice` · `om samples` | 配乐和音效、口播、真乐器采样包 |
341
341
  | `om check` · `om qa` · `om still` | 渲染前检查、成片检查、任意时刻截一帧 |
package/cli/lib/server.js CHANGED
@@ -18,7 +18,7 @@ const STATIC = {
18
18
  '/_om/engine.js': join(PKG, 'runtime/om-engine.js'),
19
19
  };
20
20
 
21
- export function startStudio(project, { port = 4848, host = '127.0.0.1' } = {}) {
21
+ export function startStudio(project, { port = 4848, host = '127.0.0.1', lang = process.env.OM_LANG } = {}) {
22
22
  const csrf = randomBytes(16).toString('hex');
23
23
  const clients = new Set();
24
24
  let renderJob = null;
@@ -114,7 +114,7 @@ export function startStudio(project, { port = 4848, host = '127.0.0.1' } = {}) {
114
114
  }
115
115
 
116
116
  if (path === '/') {
117
- const html = readFileSync(join(PKG, 'studio/index.html'), 'utf8').replace('<!--OM_BOOT-->', `<script>window.OM_BOOT=${JSON.stringify({ csrf })}</script>`);
117
+ const html = readFileSync(join(PKG, 'studio/index.html'), 'utf8').replace('<!--OM_BOOT-->', `<script>window.OM_BOOT=${JSON.stringify({ csrf, lang: lang || undefined })}</script>`);
118
118
  return send(res, 200, html, TYPES['.html']);
119
119
  }
120
120
  if (path === '/api/state') return send(res, 200, state());
package/cli/om.js CHANGED
@@ -18,7 +18,7 @@ const HELP = `huashu-motion ${VERSION} — motion graphics made by your coding a
18
18
  om new <dir> [--template t] start a project (om templates lists them)
19
19
  om templates starter projects and what each is good for
20
20
  om demo [dir] copy the showcase film and open it in the studio
21
- om studio [dir] live preview, direct edits, comments for the agent
21
+ om studio [dir] [--lang zh|en|es] live preview, direct edits, comments for the agent (UI language; also OM_LANG)
22
22
  om inbox [dir] [--wait] list comments; --wait blocks, claims the next one and prints it
23
23
  om look <id|--at sec> [dir] save the frame (and a close-up of the clicked spot) as PNGs to look at
24
24
  om done <id> [dir] --note … mark a comment handled (the studio shows the note)
@@ -369,7 +369,7 @@ async function studio(dir, flags) {
369
369
  const port = Number(flags.port || 4848);
370
370
  let started;
371
371
  for (let p = port; p < port + 20 && !started; p++) {
372
- try { started = await startStudio(project, { port: p }); }
372
+ try { started = await startStudio(project, { port: p, lang: flags.lang }); }
373
373
  catch (e) { if (e.code !== 'EADDRINUSE') throw e; }
374
374
  }
375
375
  if (!started) throw new OmError(`no free port from ${port}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huashu-motion",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Make motion graphics with your own coding agent — point at the frame to change it. Open, local, with sound.",
5
5
  "type": "module",
6
6
  "bin": { "om": "cli/om.js", "huashu-motion": "cli/om.js" },
@@ -5,7 +5,7 @@ metadata:
5
5
  author: "花叔"
6
6
  homepage: "https://github.com/alchaincyf"
7
7
  repository: "https://github.com/alchaincyf/huashu-motion"
8
- version: "0.4.1"
8
+ version: "0.5.0"
9
9
  ---
10
10
 
11
11
  # huashu-motion
package/studio/i18n.js ADDED
@@ -0,0 +1,231 @@
1
+ // Studio UI strings. One flat dictionary per language; `zh` is the reference set, the others must
2
+ // cover every key (test/i18n.test.js checks). Placeholders are {name}; {kbd} becomes a <kbd> element.
3
+ export const LANGS = {
4
+ zh: {
5
+ name: '中文',
6
+ 'status.connecting': '连接中',
7
+ 'status.disconnected': '与 studio 断开,重新运行 om studio',
8
+ 'status.exporting': '正在导出视频…',
9
+ 'status.agentWorking': 'Agent 正在改:{text}',
10
+ 'status.waiting': '{n} 条评论等 Agent 接单',
11
+ 'status.saved': '已保存 · 第 {n} 版',
12
+ 'undo': '撤回',
13
+ 'undo.title': '撤回到上一版 (⌘Z)',
14
+ 'undo.done': '已撤回到上一版',
15
+ 'undo.nothing': '没有可以撤回的版本',
16
+ 'export': '导出视频',
17
+ 'export.mp4': 'MP4 视频',
18
+ 'export.mov': 'MOV(透明底)',
19
+ 'export.gif': 'GIF 动图',
20
+ 'export.running': '正在导出 {format}…',
21
+ 'export.firstTime': '首次导出会下载渲染器,需要几分钟',
22
+ 'export.done': '导出完成:',
23
+ 'export.failed': '导出失败:',
24
+ 'tools': '工具',
25
+ 'tool.select': '选择 (V)',
26
+ 'tool.comment': '在画面上留言给 Agent (C)',
27
+ 'composer.placeholder': '告诉 Agent 这里要怎么改,比如:这里多停一拍',
28
+ 'composer.hint': '⌘↩ 发送 · Esc 取消',
29
+ 'composer.send': '发给 Agent',
30
+ 'composer.sent': '已发给 Agent。它接单后,这里会显示进度。',
31
+ 'composer.scene': '场景',
32
+ 'agent.none': '还没有 Agent 在接单。',
33
+ 'agent.none.body': '在你的 Agent 里说「处理 huashu-motion 的评论」,或在终端运行:',
34
+ 'copy': '复制',
35
+ 'copied': '已复制',
36
+ 'tab.props': '参数',
37
+ 'tab.comments': '评论',
38
+ 'selection.empty': '点画面里的元素查看它,双击文字直接改;按 {kbd} 在画面上给 Agent 留言。',
39
+ 'selection.canvas': '画布',
40
+ 'selection.comment': '留言给 Agent',
41
+ 'selection.editable': '可直接改:{list}',
42
+ 'selection.unbound': '这个元素没有绑定参数,留言让 Agent 改。',
43
+ 'edit.unbound': '这段文字没有绑定参数,按 C 留言让 Agent 改',
44
+ 'edit.conflict': '文件刚被 Agent 改过,已载入最新版本,请再改一次。',
45
+ 'list.sep': '、',
46
+ 'comment.pending': '待处理',
47
+ 'comment.working': 'Agent 正在改',
48
+ 'comment.done': '已完成',
49
+ 'comment.cancelled': '已取消',
50
+ 'comment.handled': '已处理',
51
+ 'comment.cancel': '取消',
52
+ 'comment.notRight': '没改对',
53
+ 'comments.empty': '还没有评论。按 C,再点画面上想改的地方。',
54
+ 'reply.placeholder': '哪里还不对?比如:再慢一点,或者换成蓝色',
55
+ 'reply.hint': '⌘↩ 发送',
56
+ 'reply.send': '发回给 Agent',
57
+ 'reply.sent': '已发回给 Agent',
58
+ 'vars.none': '这个工程还没有可直接改的参数。让 Agent 把标题、数字、颜色声明成变量(data-composition-variables),这里就会出现输入框。',
59
+ 'vars.group': '画面参数',
60
+ 'scenes.none': '没有分镜标签。时间轴上加 tl.addLabel("scene:名字", 秒),这里就会分段。',
61
+ 'play.title': '播放 / 暂停 (空格)',
62
+ 'shortcuts': '空格 播放 · ←→ 逐帧 · C 留言 · ⌘Z 撤回',
63
+ 'boot.failed': 'studio 启动失败:',
64
+ 'lang.title': '界面语言',
65
+ },
66
+ en: {
67
+ name: 'English',
68
+ 'status.connecting': 'Connecting',
69
+ 'status.disconnected': 'Disconnected from the studio — run om studio again',
70
+ 'status.exporting': 'Exporting video…',
71
+ 'status.agentWorking': 'Agent is working: {text}',
72
+ 'status.waiting': '{n} comment(s) waiting for an agent',
73
+ 'status.saved': 'Saved · version {n}',
74
+ 'undo': 'Undo',
75
+ 'undo.title': 'Back to the previous version (⌘Z)',
76
+ 'undo.done': 'Back to the previous version',
77
+ 'undo.nothing': 'Nothing to undo',
78
+ 'export': 'Export video',
79
+ 'export.mp4': 'MP4 video',
80
+ 'export.mov': 'MOV (transparent)',
81
+ 'export.gif': 'Animated GIF',
82
+ 'export.running': 'Exporting {format}…',
83
+ 'export.firstTime': 'The first export downloads the renderer and takes a few minutes',
84
+ 'export.done': 'Export finished: ',
85
+ 'export.failed': 'Export failed: ',
86
+ 'tools': 'Tools',
87
+ 'tool.select': 'Select (V)',
88
+ 'tool.comment': 'Leave the agent a note on the frame (C)',
89
+ 'composer.placeholder': 'Tell the agent what to change here, e.g. hold a beat longer',
90
+ 'composer.hint': '⌘↩ send · Esc cancel',
91
+ 'composer.send': 'Send to agent',
92
+ 'composer.sent': 'Sent to the agent. Progress shows here once it picks it up.',
93
+ 'composer.scene': 'scene',
94
+ 'agent.none': 'No agent is listening yet.',
95
+ 'agent.none.body': 'Tell your agent "handle the huashu-motion comments", or run in a terminal:',
96
+ 'copy': 'Copy',
97
+ 'copied': 'Copied',
98
+ 'tab.props': 'Parameters',
99
+ 'tab.comments': 'Comments',
100
+ 'selection.empty': 'Click an element in the frame to inspect it, double-click text to edit it; press {kbd} to leave the agent a note on the frame.',
101
+ 'selection.canvas': 'canvas',
102
+ 'selection.comment': 'Note to agent',
103
+ 'selection.editable': 'Editable here: {list}',
104
+ 'selection.unbound': 'This element is not bound to a parameter — leave the agent a note.',
105
+ 'edit.unbound': 'This text is not bound to a parameter — press C and ask the agent',
106
+ 'edit.conflict': 'The agent just changed the file; the latest version was loaded, please make the change again.',
107
+ 'list.sep': ', ',
108
+ 'comment.pending': 'Pending',
109
+ 'comment.working': 'Agent working',
110
+ 'comment.done': 'Done',
111
+ 'comment.cancelled': 'Cancelled',
112
+ 'comment.handled': 'Handled',
113
+ 'comment.cancel': 'Cancel',
114
+ 'comment.notRight': 'Not right yet',
115
+ 'comments.empty': 'No comments yet. Press C, then click the spot in the frame you want changed.',
116
+ 'reply.placeholder': 'What is still off? e.g. slower, or make it blue',
117
+ 'reply.hint': '⌘↩ send',
118
+ 'reply.send': 'Send back to agent',
119
+ 'reply.sent': 'Sent back to the agent',
120
+ 'vars.none': 'This project has no directly editable parameters yet. Ask the agent to declare titles, numbers and colours as variables (data-composition-variables) and fields will appear here.',
121
+ 'vars.group': 'Frame parameters',
122
+ 'scenes.none': 'No scene labels. Add tl.addLabel("scene:name", seconds) on the timeline and sections will show here.',
123
+ 'play.title': 'Play / pause (space)',
124
+ 'shortcuts': 'Space play · ←→ frame step · C note · ⌘Z undo',
125
+ 'boot.failed': 'The studio failed to start: ',
126
+ 'lang.title': 'Interface language',
127
+ },
128
+ es: {
129
+ name: 'Español',
130
+ 'status.connecting': 'Conectando',
131
+ 'status.disconnected': 'Desconectado del studio, vuelve a correr om studio',
132
+ 'status.exporting': 'Exportando video…',
133
+ 'status.agentWorking': 'El agente está trabajando: {text}',
134
+ 'status.waiting': '{n} comentario(s) esperando al agente',
135
+ 'status.saved': 'Guardado · versión {n}',
136
+ 'undo': 'Deshacer',
137
+ 'undo.title': 'Volver a la versión anterior (⌘Z)',
138
+ 'undo.done': 'Se volvió a la versión anterior',
139
+ 'undo.nothing': 'No hay una versión anterior',
140
+ 'export': 'Exportar video',
141
+ 'export.mp4': 'Video MP4',
142
+ 'export.mov': 'MOV (fondo transparente)',
143
+ 'export.gif': 'GIF animado',
144
+ 'export.running': 'Exportando {format}…',
145
+ 'export.firstTime': 'La primera exportación descarga el renderizador y tarda unos minutos',
146
+ 'export.done': 'Exportación lista: ',
147
+ 'export.failed': 'Falló la exportación: ',
148
+ 'tools': 'Herramientas',
149
+ 'tool.select': 'Seleccionar (V)',
150
+ 'tool.comment': 'Dejar una nota al agente sobre el cuadro (C)',
151
+ 'composer.placeholder': 'Dile al agente qué cambiar aquí, por ejemplo: que se detenga un poco más',
152
+ 'composer.hint': '⌘↩ enviar · Esc cancelar',
153
+ 'composer.send': 'Enviar al agente',
154
+ 'composer.sent': 'Enviado al agente. Cuando lo tome, aquí verás el avance.',
155
+ 'composer.scene': 'escena',
156
+ 'agent.none': 'Ningún agente está escuchando todavía.',
157
+ 'agent.none.body': 'Dile a tu agente "atiende los comentarios de huashu-motion" o corre en la terminal:',
158
+ 'copy': 'Copiar',
159
+ 'copied': 'Copiado',
160
+ 'tab.props': 'Parámetros',
161
+ 'tab.comments': 'Comentarios',
162
+ 'selection.empty': 'Haz clic en un elemento del cuadro para verlo, doble clic en un texto para editarlo; pulsa {kbd} para dejarle una nota al agente sobre el cuadro.',
163
+ 'selection.canvas': 'lienzo',
164
+ 'selection.comment': 'Nota al agente',
165
+ 'selection.editable': 'Editable aquí: {list}',
166
+ 'selection.unbound': 'Este elemento no está ligado a un parámetro; déjale una nota al agente.',
167
+ 'edit.unbound': 'Este texto no está ligado a un parámetro; pulsa C y pídele el cambio al agente',
168
+ 'edit.conflict': 'El agente acaba de modificar el archivo; se cargó la versión más reciente, vuelve a hacer el cambio.',
169
+ 'list.sep': ', ',
170
+ 'comment.pending': 'Pendiente',
171
+ 'comment.working': 'El agente está trabajando',
172
+ 'comment.done': 'Hecho',
173
+ 'comment.cancelled': 'Cancelado',
174
+ 'comment.handled': 'Atendido',
175
+ 'comment.cancel': 'Cancelar',
176
+ 'comment.notRight': 'No quedó bien',
177
+ 'comments.empty': 'Aún no hay comentarios. Pulsa C y haz clic en la parte del cuadro que quieras cambiar.',
178
+ 'reply.placeholder': '¿Qué sigue mal? Por ejemplo: más lento, o cámbialo a azul',
179
+ 'reply.hint': '⌘↩ enviar',
180
+ 'reply.send': 'Devolver al agente',
181
+ 'reply.sent': 'Devuelto al agente',
182
+ 'vars.none': 'Este proyecto aún no tiene parámetros editables. Pídele al agente que declare títulos, números y colores como variables (data-composition-variables) y aquí aparecerán los campos.',
183
+ 'vars.group': 'Parámetros del cuadro',
184
+ 'scenes.none': 'Sin etiquetas de escena. Agrega tl.addLabel("scene:nombre", segundos) en la línea de tiempo y aquí se verán las secciones.',
185
+ 'play.title': 'Reproducir / pausar (espacio)',
186
+ 'shortcuts': 'Espacio reproducir · ←→ cuadro a cuadro · C nota · ⌘Z deshacer',
187
+ 'boot.failed': 'El studio no pudo iniciar: ',
188
+ 'lang.title': 'Idioma de la interfaz',
189
+ },
190
+ };
191
+
192
+ const STORE = 'om-lang';
193
+
194
+ // Order: ?lang= in the URL, the choice saved in this browser, --lang / OM_LANG from the server, then the browser's languages.
195
+ export function pickLang(boot = {}, nav = globalThis.navigator) {
196
+ const url = typeof location !== 'undefined' ? new URLSearchParams(location.search).get('lang') : null;
197
+ let saved = null;
198
+ try { saved = localStorage.getItem(STORE); } catch {}
199
+ const wanted = [url, saved, boot.lang, ...(nav?.languages || [nav?.language])].filter(Boolean);
200
+ for (const w of wanted) {
201
+ const code = String(w).toLowerCase();
202
+ if (LANGS[code]) return code;
203
+ const base = code.split(/[-_]/)[0];
204
+ if (LANGS[base]) return base;
205
+ }
206
+ return 'en';
207
+ }
208
+
209
+ export function saveLang(code) {
210
+ try { localStorage.setItem(STORE, code); } catch {}
211
+ }
212
+
213
+ let current = 'zh';
214
+ export function setLang(code) { current = LANGS[code] ? code : 'en'; return current; }
215
+ export function lang() { return current; }
216
+
217
+ export function t(key, vars = {}) {
218
+ const s = LANGS[current]?.[key] ?? LANGS.zh[key] ?? key;
219
+ return s.replace(/\{(\w+)\}/g, (_, k) => (vars[k] !== undefined ? String(vars[k]) : `{${k}}`));
220
+ }
221
+
222
+ // Fills the static page: data-i18n (text), data-i18n-title, data-i18n-placeholder, data-i18n-aria,
223
+ // and data-i18n-html, whose {kbd} placeholder becomes <kbd>C</kbd>.
224
+ export function applyI18n(root = document) {
225
+ root.documentElement && (root.documentElement.lang = current);
226
+ for (const n of root.querySelectorAll('[data-i18n]')) n.textContent = t(n.dataset.i18n);
227
+ for (const n of root.querySelectorAll('[data-i18n-title]')) n.title = t(n.dataset.i18nTitle);
228
+ for (const n of root.querySelectorAll('[data-i18n-placeholder]')) n.placeholder = t(n.dataset.i18nPlaceholder);
229
+ for (const n of root.querySelectorAll('[data-i18n-aria]')) n.setAttribute('aria-label', t(n.dataset.i18nAria));
230
+ for (const n of root.querySelectorAll('[data-i18n-html]')) n.innerHTML = t(n.dataset.i18nHtml).replace('{kbd}', '<kbd>C</kbd>');
231
+ }
package/studio/index.html CHANGED
@@ -1,5 +1,5 @@
1
1
  <!doctype html>
2
- <html lang="zh-CN">
2
+ <html lang="zh">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
@@ -12,24 +12,25 @@
12
12
  <header class="bar">
13
13
  <div class="brand"><span class="logo" aria-hidden="true"></span>huashu-motion</div>
14
14
  <div class="crumb"><span id="project-name">…</span><span class="dim" id="project-meta"></span></div>
15
- <div class="status" id="status"><span class="dot"></span><span id="status-text">连接中</span></div>
15
+ <div class="status" id="status"><span class="dot"></span><span id="status-text" data-i18n="status.connecting">连接中</span></div>
16
16
  <div class="spacer"></div>
17
- <button class="ghost" id="undo" title="撤回到上一版 (⌘Z)">撤回</button>
17
+ <select class="ghost lang" id="lang" title="界面语言" data-i18n-title="lang.title"></select>
18
+ <button class="ghost" id="undo" title="撤回到上一版 (⌘Z)" data-i18n-title="undo.title" data-i18n="undo">撤回</button>
18
19
  <div class="export">
19
- <button class="primary" id="export">导出视频</button>
20
+ <button class="primary" id="export" data-i18n="export">导出视频</button>
20
21
  <div class="menu" id="export-menu" hidden>
21
- <button data-format="mp4">MP4 视频</button>
22
- <button data-format="mov">MOV(透明底)</button>
23
- <button data-format="gif">GIF 动图</button>
22
+ <button data-format="mp4" data-i18n="export.mp4">MP4 视频</button>
23
+ <button data-format="mov" data-i18n="export.mov">MOV(透明底)</button>
24
+ <button data-format="gif" data-i18n="export.gif">GIF 动图</button>
24
25
  <button data-format="webm">WebM</button>
25
26
  </div>
26
27
  </div>
27
28
  </header>
28
29
 
29
30
  <main class="work">
30
- <nav class="tools" aria-label="工具">
31
- <button class="tool active" data-tool="select" title="选择 (V)"><svg viewBox="0 0 24 24"><path d="M5 3l14 8-6 1.5L10 19z"/></svg></button>
32
- <button class="tool" data-tool="comment" title="在画面上留言给 Agent (C)"><svg viewBox="0 0 24 24"><path d="M4 5h16v11H9l-5 4z"/></svg></button>
31
+ <nav class="tools" aria-label="工具" data-i18n-aria="tools">
32
+ <button class="tool active" data-tool="select" title="选择 (V)" data-i18n-title="tool.select"><svg viewBox="0 0 24 24"><path d="M5 3l14 8-6 1.5L10 19z"/></svg></button>
33
+ <button class="tool" data-tool="comment" title="在画面上留言给 Agent (C)" data-i18n-title="tool.comment"><svg viewBox="0 0 24 24"><path d="M4 5h16v11H9l-5 4z"/></svg></button>
33
34
  </nav>
34
35
 
35
36
  <section class="stage" id="stage">
@@ -43,23 +44,23 @@
43
44
  </div>
44
45
  <div class="composer" id="composer" hidden>
45
46
  <div class="composer-ctx" id="composer-ctx"></div>
46
- <textarea id="composer-text" rows="3" placeholder="告诉 Agent 这里要怎么改,比如:这里多停一拍"></textarea>
47
- <div class="composer-actions"><span class="hint">⌘↩ 发送 · Esc 取消</span><button class="primary small" id="composer-send">发给 Agent</button></div>
47
+ <textarea id="composer-text" rows="3" placeholder="告诉 Agent 这里要怎么改,比如:这里多停一拍" data-i18n-placeholder="composer.placeholder"></textarea>
48
+ <div class="composer-actions"><span class="hint" data-i18n="composer.hint">⌘↩ 发送 · Esc 取消</span><button class="primary small" id="composer-send" data-i18n="composer.send">发给 Agent</button></div>
48
49
  </div>
49
50
  <div class="agent-hint" id="agent-hint" hidden>
50
- <div><b>还没有 Agent 在接单。</b>在你的 Agent 里说「处理 huashu-motion 的评论」,或在终端运行:</div>
51
- <code id="agent-cmd">om inbox --wait</code><button class="ghost small" id="copy-cmd">复制</button>
51
+ <div><b data-i18n="agent.none">还没有 Agent 在接单。</b><span data-i18n="agent.none.body">在你的 Agent 里说「处理 huashu-motion 的评论」,或在终端运行:</span></div>
52
+ <code id="agent-cmd">om inbox --wait</code><button class="ghost small" id="copy-cmd" data-i18n="copy">复制</button>
52
53
  </div>
53
54
  </section>
54
55
 
55
56
  <aside class="side">
56
57
  <div class="tabs" role="tablist">
57
- <button class="tab active" data-tab="props">参数</button>
58
- <button class="tab" data-tab="comments">评论 <span class="count" id="comment-count"></span></button>
58
+ <button class="tab active" data-tab="props" data-i18n="tab.props">参数</button>
59
+ <button class="tab" data-tab="comments"><span data-i18n="tab.comments">评论</span> <span class="count" id="comment-count"></span></button>
59
60
  </div>
60
61
  <div class="panel" id="panel-props">
61
62
  <div class="selection" id="selection">
62
- <div class="empty">点画面里的元素查看它,双击文字直接改;按 <kbd>C</kbd> 在画面上给 Agent 留言。</div>
63
+ <div class="empty" data-i18n-html="selection.empty">点画面里的元素查看它,双击文字直接改;按 <kbd>C</kbd> 在画面上给 Agent 留言。</div>
63
64
  </div>
64
65
  <div id="vars"></div>
65
66
  </div>
@@ -71,10 +72,10 @@
71
72
 
72
73
  <footer class="timeline">
73
74
  <div class="transport">
74
- <button class="icon" id="play" title="播放 / 暂停 (空格)"><svg viewBox="0 0 24 24" id="play-icon"><path d="M7 4l13 8-13 8z"/></svg></button>
75
+ <button class="icon" id="play" title="播放 / 暂停 (空格)" data-i18n-title="play.title"><svg viewBox="0 0 24 24" id="play-icon"><path d="M7 4l13 8-13 8z"/></svg></button>
75
76
  <span class="clock"><span id="time">00:00.00</span><span class="dim"> / <span id="duration">00:00.00</span></span></span>
76
77
  <div class="spacer"></div>
77
- <span class="dim small">空格 播放 · ←→ 逐帧 · C 留言 · ⌘Z 撤回</span>
78
+ <span class="dim small" data-i18n="shortcuts">空格 播放 · ←→ 逐帧 · C 留言 · ⌘Z 撤回</span>
78
79
  </div>
79
80
  <div class="track" id="track">
80
81
  <div class="ruler" id="ruler"></div>
package/studio/studio.css CHANGED
@@ -30,6 +30,7 @@ kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5p
30
30
  @keyframes pulse { 50% { opacity: .3; } }
31
31
  .ghost { padding: 6px 12px; border-radius: 6px; color: var(--ink-2); }
32
32
  .ghost:hover { background: var(--bg); color: var(--ink); }
33
+ select.lang { appearance: none; -webkit-appearance: none; background: transparent; border: 0; font: inherit; cursor: pointer; }
33
34
  .primary { padding: 7px 14px; border-radius: 6px; background: var(--ink); color: #fff; font-weight: 500; }
34
35
  .primary:hover { background: #000; } .primary:disabled { opacity: .5; cursor: default; }
35
36
  .small { padding: 4px 10px; font-size: 12px; }
package/studio/studio.js CHANGED
@@ -1,6 +1,9 @@
1
1
  // huashu-motion studio. One page, no build step: the om player shows the real composition,
2
2
  // this file adds pointing, direct edits and the comment loop around it.
3
+ import { LANGS, pickLang, saveLang, setLang, lang, t, applyI18n } from './i18n.js';
4
+
3
5
  const BOOT = window.OM_BOOT || {};
6
+ setLang(pickLang(BOOT));
4
7
  const $ = (s) => document.querySelector(s);
5
8
  const el = (tag, attrs = {}, ...kids) => {
6
9
  const n = document.createElement(tag);
@@ -37,7 +40,14 @@ function toast(html, { bad = false, ms = 3600 } = {}) {
37
40
  const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' })[c]);
38
41
  const fmt = (t) => { t = Math.max(0, t || 0); const m = Math.floor(t / 60), s = t - m * 60; return `${String(m).padStart(2, '0')}:${s.toFixed(2).padStart(5, '0')}`; };
39
42
 
43
+ function renderLang() {
44
+ const sel = $('#lang');
45
+ sel.replaceChildren(...Object.entries(LANGS).map(([code, d]) => el('option', { value: code, selected: code === lang() }, d.name)));
46
+ sel.addEventListener('change', () => { saveLang(sel.value); location.reload(); });
47
+ }
48
+
40
49
  async function boot() {
50
+ applyI18n(); renderLang();
41
51
  const st = await (await fetch('/api/state')).json();
42
52
  Object.assign(S, { token: st.token, variables: st.variables, comments: st.comments, history: st.history, name: st.name, renderJob: st.render });
43
53
  if (st.scan.width) { S.w = st.scan.width; S.h = st.scan.height; }
@@ -52,7 +62,7 @@ async function boot() {
52
62
  es.addEventListener('inbox', (e) => { S.comments = JSON.parse(e.data).comments; renderComments(); renderStatus(); renderPins(); renderMarks(); });
53
63
  es.addEventListener('render', (e) => onRender(JSON.parse(e.data)));
54
64
  es.addEventListener('problem', (e) => toast(esc(JSON.parse(e.data).message), { bad: true }));
55
- es.onerror = () => { $('#status').className = 'status bad'; $('#status-text').textContent = '与 studio 断开,重新运行 om studio'; };
65
+ es.onerror = () => { $('#status').className = 'status bad'; $('#status-text').textContent = t('status.disconnected'); };
56
66
  es.onopen = () => renderStatus();
57
67
  }
58
68
 
@@ -245,7 +255,7 @@ overlay.addEventListener('dblclick', (e) => {
245
255
  const hit = objectAt(x, y); if (!hit?.node) return;
246
256
  const bound = hit.node.closest('[data-var-text],[data-om-var]') || hit.node.querySelector('[data-var-text],[data-om-var]');
247
257
  const v = bound && S.variables.find((d) => d.id === (bound.getAttribute('data-om-var') || bound.getAttribute('data-var-text')));
248
- if (!v || (v.type && v.type !== 'string')) { toast('这段文字没有绑定参数,按 C 留言让 Agent 改'); return; }
258
+ if (!v || (v.type && v.type !== 'string')) { toast(t('edit.unbound')); return; }
249
259
  if (S.playing) pause();
250
260
  const r = bound.getBoundingClientRect(), p = toFrame(r.left, r.top), { k } = view();
251
261
  const cs = win().getComputedStyle(bound);
@@ -256,7 +266,7 @@ overlay.addEventListener('dblclick', (e) => {
256
266
  if (done) return; done = true; input.remove();
257
267
  if (!save || input.value === v.default) return;
258
268
  try { const res = await api('/api/vars', { token: S.token, values: { [v.id]: input.value } }); S.token = res.token; v.default = input.value; }
259
- catch (err) { toast(err.status === 409 ? '文件刚被 Agent 改过,已载入最新版本,请再改一次。' : esc(err.message), { bad: true }); refreshState(); }
269
+ catch (err) { toast(err.status === 409 ? t('edit.conflict') : esc(err.message), { bad: true }); refreshState(); }
260
270
  };
261
271
  input.addEventListener('keydown', (ev) => { if (ev.key === 'Enter') finish(true); if (ev.key === 'Escape') finish(false); ev.stopPropagation(); });
262
272
  input.addEventListener('blur', () => finish(true));
@@ -285,17 +295,17 @@ function linkedVars(id) {
285
295
  function renderSelection() {
286
296
  const box = $('#selection');
287
297
  box.innerHTML = '';
288
- if (!S.selected) { box.append(el('div', { class: 'empty' }, '点画面里的元素查看它,双击文字直接改;按 ', el('kbd', {}, 'C'), ' 在画面上给 Agent 留言。')); return; }
298
+ if (!S.selected) { box.append(el('div', { class: 'empty' }, ...t('selection.empty').split('{kbd}').flatMap((s, i) => (i ? [el('kbd', {}, 'C'), s] : [s])))); return; }
289
299
  const n = doc()?.querySelector(`[data-om-id="${CSS.escape(S.selected)}"]`);
290
300
  const linked = linkedVars(S.selected);
291
301
  let label = null;
292
302
  try { label = win()?.__om?.hitTest && !n ? (win().__om.regionLabel?.(S.selected) ?? null) : null; } catch {}
293
303
  box.append(
294
304
  el('div', { class: 'sel-head' },
295
- el('div', { class: 'sel-id' }, '#' + S.selected, el('small', {}, n ? n.tagName.toLowerCase() : (label ? `${label} · 画布` : '画布'))),
296
- el('button', { class: 'ghost small', onclick: () => setTool('comment') }, '留言给 Agent')),
305
+ el('div', { class: 'sel-id' }, '#' + S.selected, el('small', {}, n ? n.tagName.toLowerCase() : (label ? `${label} · ${t('selection.canvas')}` : t('selection.canvas')))),
306
+ el('button', { class: 'ghost small', onclick: () => setTool('comment') }, t('selection.comment'))),
297
307
  n && n.textContent.trim() ? el('div', { class: 'sel-text' }, n.textContent.trim().slice(0, 120)) : null,
298
- el('div', { class: 'sel-text dim small' }, linked.length ? `可直接改:${linked.map((id) => S.variables.find((v) => v.id === id)?.label || id).join('、')}` : '这个元素没有绑定参数,留言让 Agent 改。'));
308
+ el('div', { class: 'sel-text dim small' }, linked.length ? t('selection.editable', { list: linked.map((id) => S.variables.find((v) => v.id === id)?.label || id).join(t('list.sep')) }) : t('selection.unbound')));
299
309
  }
300
310
 
301
311
  // ---------- composer ----------
@@ -310,11 +320,11 @@ function cleanHtml(node) {
310
320
  }
311
321
  let draft = null;
312
322
  function openComposer(e, x, y, hit) {
313
- const t = player.currentTime || 0;
314
- const scene = sceneAt(t)?.id || null;
315
- draft = { x, y, t, target: hit?.id || null, scene, element: hit?.node ? cleanHtml(hit.node) : null };
323
+ const at = player.currentTime || 0;
324
+ const scene = sceneAt(at)?.id || null;
325
+ draft = { x, y, t: at, target: hit?.id || null, scene, element: hit?.node ? cleanHtml(hit.node) : null };
316
326
  const ctx = $('#composer-ctx');
317
- ctx.innerHTML = `${hit ? `<b>#${esc(hit.id)}</b> · ` : ''}${fmt(t)}${scene ? ` · 场景 ${esc(scene)}` : ''}`;
327
+ ctx.innerHTML = `${hit ? `<b>#${esc(hit.id)}</b> · ` : ''}${fmt(at)}${scene ? ` · ${t('composer.scene')} ${esc(scene)}` : ''}`;
318
328
  const c = $('#composer'), stage = $('#stage').getBoundingClientRect();
319
329
  c.hidden = false;
320
330
  const left = Math.min(Math.max(12, e.clientX - stage.left + 12), stage.width - 332);
@@ -333,7 +343,7 @@ async function sendComment() {
333
343
  if (!S.comments.some((x) => x.id === c.id)) S.comments.push(c);
334
344
  closeComposer();
335
345
  renderComments(); renderPins(); renderMarks(); renderStatus();
336
- toast('已发给 Agent。它接单后,这里会显示进度。');
346
+ toast(t('composer.sent'));
337
347
  } catch (err) { toast(esc(err.message), { bad: true }); }
338
348
  finally { $('#composer-send').disabled = false; }
339
349
  }
@@ -344,35 +354,35 @@ $('#composer-text').addEventListener('keydown', (e) => {
344
354
  });
345
355
 
346
356
  // ---------- comments ----------
347
- const STATUS = { pending: '待处理', working: 'Agent 正在改', done: '已完成', cancelled: '已取消' };
357
+ const STATUS = { pending: 'comment.pending', working: 'comment.working', done: 'comment.done', cancelled: 'comment.cancelled' };
348
358
  function renderComments() {
349
359
  const list = $('#comments'); list.innerHTML = '';
350
360
  const open = S.comments.filter((c) => c.status === 'pending' || c.status === 'working').length;
351
361
  $('#comment-count').textContent = open || '';
352
- if (!S.comments.length) { list.append(el('div', { class: 'no-vars' }, '还没有评论。按 C,再点画面上想改的地方。')); return; }
362
+ if (!S.comments.length) { list.append(el('div', { class: 'no-vars' }, t('comments.empty'))); return; }
353
363
  for (const c of [...S.comments].reverse()) {
354
364
  list.append(el('div', { class: 'comment', onclick: () => { if (c.t != null) seek(c.t); if (c.target) select(c.target); } },
355
365
  el('div', { class: 'c-head' },
356
- el('span', { class: 'chip ' + c.status }, STATUS[c.status] || c.status),
366
+ el('span', { class: 'chip ' + c.status }, STATUS[c.status] ? t(STATUS[c.status]) : c.status),
357
367
  el('span', {}, c.t != null ? fmt(c.t) : ''), c.target ? el('span', {}, '#' + c.target) : null,
358
368
  el('span', { class: 'c-actions' },
359
- c.status === 'pending' ? el('button', { onclick: (e) => { e.stopPropagation(); api(`/api/comments/${c.id}/cancel`).catch((x) => toast(esc(x.message), { bad: true })); } }, '取消') : null,
360
- c.status === 'done' ? el('button', { onclick: (e) => { e.stopPropagation(); openReply(e.currentTarget.closest('.comment'), c); } }, '没改对') : null)),
369
+ c.status === 'pending' ? el('button', { onclick: (e) => { e.stopPropagation(); api(`/api/comments/${c.id}/cancel`).catch((x) => toast(esc(x.message), { bad: true })); } }, t('comment.cancel')) : null,
370
+ c.status === 'done' ? el('button', { onclick: (e) => { e.stopPropagation(); openReply(e.currentTarget.closest('.comment'), c); } }, t('comment.notRight')) : null)),
361
371
  el('div', { class: 'c-text' }, c.text),
362
- (c.thread || []).map((m) => el('div', { class: m.who === 'agent' ? 'c-note' : 'c-reply' }, m.who === 'agent' ? m.text || '已处理' : '↩ ' + m.text))));
372
+ (c.thread || []).map((m) => el('div', { class: m.who === 'agent' ? 'c-note' : 'c-reply' }, m.who === 'agent' ? m.text || t('comment.handled') : '↩ ' + m.text))));
363
373
  }
364
374
  }
365
375
  // Tell the agent what is still wrong; the comment goes back into its inbox with the whole thread.
366
376
  function openReply(card, c) {
367
377
  if (card.querySelector('.reply')) return;
368
- const ta = el('textarea', { rows: 2, placeholder: '哪里还不对?比如:再慢一点,或者换成蓝色' });
378
+ const ta = el('textarea', { rows: 2, placeholder: t('reply.placeholder') });
369
379
  const send = async () => {
370
380
  const text = ta.value.trim(); if (!text) return;
371
- try { await api(`/api/comments/${c.id}/reopen`, { note: text }); toast('已发回给 Agent'); }
381
+ try { await api(`/api/comments/${c.id}/reopen`, { note: text }); toast(t('reply.sent')); }
372
382
  catch (x) { toast(esc(x.message), { bad: true }); }
373
383
  };
374
384
  ta.addEventListener('keydown', (e) => { e.stopPropagation(); if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) send(); if (e.key === 'Escape') box.remove(); });
375
- const box = el('div', { class: 'reply', onclick: (e) => e.stopPropagation() }, ta, el('div', { class: 'composer-actions' }, el('span', { class: 'hint' }, '⌘↩ 发送'), el('button', { class: 'primary small', onclick: send }, '发回给 Agent')));
385
+ const box = el('div', { class: 'reply', onclick: (e) => e.stopPropagation() }, ta, el('div', { class: 'composer-actions' }, el('span', { class: 'hint' }, t('reply.hint')), el('button', { class: 'primary small', onclick: send }, t('reply.send'))));
376
386
  card.append(box); ta.focus();
377
387
  }
378
388
 
@@ -396,10 +406,10 @@ function renderStatus() {
396
406
  const s = $('#status'), txt = $('#status-text');
397
407
  const working = S.comments.find((c) => c.status === 'working');
398
408
  const waiting = S.comments.filter((c) => c.status === 'pending');
399
- if (S.renderJob?.status === 'running') { s.className = 'status working'; txt.textContent = '正在导出视频…'; }
400
- else if (working) { s.className = 'status working'; txt.textContent = `Agent 正在改:${working.text.slice(0, 18)}${working.text.length > 18 ? '…' : ''}`; }
401
- else if (waiting.length) { s.className = 'status'; txt.textContent = `${waiting.length} 条评论等 Agent 接单`; }
402
- else { s.className = 'status ok'; txt.textContent = `已保存 · 第 ${S.history} 版`; }
409
+ if (S.renderJob?.status === 'running') { s.className = 'status working'; txt.textContent = t('status.exporting'); }
410
+ else if (working) { s.className = 'status working'; txt.textContent = t('status.agentWorking', { text: working.text.slice(0, 18) + (working.text.length > 18 ? '…' : '') }); }
411
+ else if (waiting.length) { s.className = 'status'; txt.textContent = t('status.waiting', { n: waiting.length }); }
412
+ else { s.className = 'status ok'; txt.textContent = t('status.saved', { n: S.history }); }
403
413
  clearTimeout(hintTimer);
404
414
  $('#agent-hint').hidden = true;
405
415
  if (waiting.length && !working) {
@@ -407,17 +417,17 @@ function renderStatus() {
407
417
  hintTimer = setTimeout(() => { if (S.comments.some((c) => c.status === 'pending') && !S.comments.some((c) => c.status === 'working')) $('#agent-hint').hidden = false; }, Math.max(0, 6000 - (Date.now() - oldest)));
408
418
  }
409
419
  }
410
- $('#copy-cmd').addEventListener('click', () => { navigator.clipboard?.writeText($('#agent-cmd').textContent); toast('已复制'); });
420
+ $('#copy-cmd').addEventListener('click', () => { navigator.clipboard?.writeText($('#agent-cmd').textContent); toast(t('copied')); });
411
421
 
412
422
  // ---------- variables ----------
413
423
  function renderVars() {
414
424
  const box = $('#vars');
415
425
  if (box.contains(document.activeElement) && document.activeElement.matches('input,textarea,select')) { S.varsDirty = true; return; }
416
426
  box.innerHTML = '';
417
- if (!S.variables.length) { box.append(el('div', { class: 'no-vars' }, '这个工程还没有可直接改的参数。让 Agent 把标题、数字、颜色声明成变量(data-composition-variables),这里就会出现输入框。')); return; }
427
+ if (!S.variables.length) { box.append(el('div', { class: 'no-vars' }, t('vars.none'))); return; }
418
428
  const linked = new Set(S.selected ? linkedVars(S.selected) : []);
419
429
  const groups = new Map();
420
- for (const v of S.variables) { const g = v.group || '画面参数'; if (!groups.has(g)) groups.set(g, []); groups.get(g).push(v); }
430
+ for (const v of S.variables) { const g = v.group || t('vars.group'); if (!groups.has(g)) groups.set(g, []); groups.get(g).push(v); }
421
431
  for (const [name, vars] of groups) {
422
432
  const g = el('div', { class: 'group' }, el('h4', {}, name));
423
433
  for (const v of vars) g.append(field(v, linked.has(v.id)));
@@ -433,7 +443,7 @@ function field(v, linked) {
433
443
  row.classList.add('saving');
434
444
  try { const r = await api('/api/vars', { token: S.token, values: { [v.id]: value } }); S.token = r.token; v.default = value; }
435
445
  catch (e) {
436
- toast(e.status === 409 ? '文件刚被 Agent 改过,已载入最新版本,请再改一次。' : esc(e.message), { bad: true });
446
+ toast(e.status === 409 ? t('edit.conflict') : esc(e.message), { bad: true });
437
447
  refreshState();
438
448
  } finally { row.classList.remove('saving'); }
439
449
  };
@@ -480,7 +490,7 @@ async function refreshState() {
480
490
  function renderScenes() {
481
491
  const box = $('#scenes'); box.innerHTML = '';
482
492
  box.style.display = 'block';
483
- if (!S.scenes.length) { box.append(el('div', { class: 'none' }, '没有分镜标签。时间轴上加 tl.addLabel("scene:名字", 秒),这里就会分段。')); }
493
+ if (!S.scenes.length) { box.append(el('div', { class: 'none' }, t('scenes.none'))); }
484
494
  for (const s of S.scenes) {
485
495
  const left = (s.start / S.duration) * 100, width = ((s.end - s.start) / S.duration) * 100;
486
496
  box.append(el('div', { class: 'scene', 'data-id': s.id, style: `position:absolute;left:${left}%;width:calc(${width}% - 2px);top:0`, title: s.id },
@@ -520,8 +530,8 @@ document.querySelectorAll('.tab').forEach((b) => b.addEventListener('click', ()
520
530
  $('#play').addEventListener('click', () => (S.playing ? pause() : play()));
521
531
  $('#undo').addEventListener('click', doUndo);
522
532
  async function doUndo() {
523
- try { await api('/api/undo'); toast('已撤回到上一版'); }
524
- catch (e) { toast(esc(e.message === 'nothing to undo' ? '没有可以撤回的版本' : e.message), { bad: true }); }
533
+ try { await api('/api/undo'); toast(t('undo.done')); }
534
+ catch (e) { toast(esc(e.message === 'nothing to undo' ? t('undo.nothing') : e.message), { bad: true }); }
525
535
  }
526
536
 
527
537
  window.addEventListener('keydown', (e) => {
@@ -547,9 +557,9 @@ function onRender(job) {
547
557
  S.renderJob = job; renderStatus();
548
558
  $('#export').disabled = job?.status === 'running';
549
559
  if (!job) return;
550
- if (job.status === 'running') toast(`正在导出 ${job.format.toUpperCase()}…<br><span class="dim small">${esc(job.log?.at(-1) || '首次导出会下载渲染器,需要几分钟')}</span>`, { ms: 0 });
551
- if (job.status === 'done') { const name = job.out.split('/').pop(); toast(`导出完成:<a href="/out/${encodeURIComponent(name)}" target="_blank">${esc(name)}</a><br><span class="small">${esc(job.out)}</span>`, { ms: 12000 }); }
552
- if (job.status === 'failed') toast(`导出失败:${esc(job.error)}`, { bad: true, ms: 12000 });
560
+ if (job.status === 'running') toast(`${t('export.running', { format: job.format.toUpperCase() })}<br><span class="dim small">${esc(job.log?.at(-1) || t('export.firstTime'))}</span>`, { ms: 0 });
561
+ if (job.status === 'done') { const name = job.out.split('/').pop(); toast(`${t('export.done')}<a href="/out/${encodeURIComponent(name)}" target="_blank">${esc(name)}</a><br><span class="small">${esc(job.out)}</span>`, { ms: 12000 }); }
562
+ if (job.status === 'failed') toast(`${t('export.failed')}${esc(job.error)}`, { bad: true, ms: 12000 });
553
563
  }
554
564
 
555
- boot().catch((e) => toast('studio 启动失败:' + esc(e.message), { bad: true, ms: 0 }));
565
+ boot().catch((e) => toast(t('boot.failed') + esc(e.message), { bad: true, ms: 0 }));