diff --git a/calliope-web/src/hooks.client.ts b/calliope-web/src/hooks.client.ts index 6fa26381..496b069b 100644 --- a/calliope-web/src/hooks.client.ts +++ b/calliope-web/src/hooks.client.ts @@ -1,8 +1,9 @@ import type { HandleClientError } from '@sveltejs/kit'; +import { t } from '$lib/i18n.svelte'; export const handleError: HandleClientError = ({ error }) => { console.error(error); return { - message: 'Something went wrong.', + message: t('global.somethingWentWrong'), }; }; diff --git a/calliope-web/src/lib/agentTasks.ts b/calliope-web/src/lib/agentTasks.ts index 6b4b20f2..2ab0e53f 100644 --- a/calliope-web/src/lib/agentTasks.ts +++ b/calliope-web/src/lib/agentTasks.ts @@ -17,10 +17,10 @@ export const AGENT_TASK_PROMPTS: Record = { 'Regenerate the full script for this project — turn the storyline into ordered scenes with action and dialogue.', }; -/** A sidebar-friendly title for the auto-created session. */ -export const AGENT_TASK_TITLES: Record = { - story: 'Draft Storyline', - script: 'Regenerate Script', +/** i18n key for the auto-created session's sidebar title. */ +export const AGENT_TASK_TITLE_KEYS: Record = { + story: 'agent.task.story', + script: 'agent.task.script', }; export function isAgentTaskKind(value: string | null | undefined): value is AgentTaskKind { diff --git a/calliope-web/src/lib/i18n/en.ts b/calliope-web/src/lib/i18n/en.ts index 4b51dfaa..a571db46 100644 --- a/calliope-web/src/lib/i18n/en.ts +++ b/calliope-web/src/lib/i18n/en.ts @@ -41,6 +41,20 @@ export const en = { 'nav.countActive': '{count} active', 'nav.eyebrow': 'Calliope', 'nav.unsaved': 'Unsaved changes', + 'nav.llm': 'LLMs', + 'nav.llmBlurb': 'Configure the language models used by the agent.', + 'nav.comfy': 'ComfyUI', + 'nav.comfyBlurb': 'Where ComfyUI runs.', + 'nav.workflows': 'Workflows', + 'nav.workflowsBlurb': 'Upload and register ComfyUI workflows for generation.', + 'nav.agent': 'Agent model', + 'nav.agentBlurb': 'Model used for story drafting and agent tasks.', + 'nav.skills': 'Skills', + 'nav.skillsBlurb': 'Agent skills available in this project.', + 'nav.queue': 'Job queue', + 'nav.queueBlurb': 'Concurrency and timeouts for generation jobs.', + 'nav.storage': 'Storage', + 'nav.storageBlurb': 'Where files live on disk.', // --- Toast --- 'toast.dismiss': 'Dismiss', @@ -138,6 +152,11 @@ export const en = { // --- Project detail page --- 'project.backToProjects': 'Back to projects', + 'project.notFound': 'Project not found', + 'project.invalidIdBody': '“{id}” isn’t a valid project id — the link may be broken or the project was deleted.', + 'project.openVideoStage': 'Open the Video stage', + 'project.runningQueued': '{running} running · {queued} queued', + 'project.queueIdle': 'Queue idle', // --- API errors --- 'api.unknownError': 'Something went wrong', @@ -204,6 +223,17 @@ export const en = { 'artifact.playVideo': 'Play video', 'artifact.videoUnavailable': 'Video unavailable', 'artifact.viewImage': 'View image', + 'canvas.emptyHint': 'Ask the agent on the right to create characters, scenes, or to generate an image or video — outputs land here as cards.', + 'canvas.loadFailed': 'Could not load this canvas', + 'canvas.tidy': 'Tidy layout', + 'canvas.tidyTitle': 'Re-arrange all cards into clean columns and grids', + 'canvas.savePosFailed': 'Could not save position', + 'canvas.openThatFailed': 'Could not open that canvas', + 'canvas.sessionCreateFailed': 'Could not create session', + 'canvas.sessionDeleteFailed': 'Could not delete session', + 'canvas.renameFailed': 'Rename failed', + 'canvas.suggestFilm': 'Create a new film', + 'canvas.suggestStory': 'Draft a storyline', 'canvas.emptyBoard': 'Empty board', 'canvas.noChatSelected': 'No chat selected', 'canvas.failed': 'failed', @@ -213,6 +243,23 @@ export const en = { 'canvas.running': 'running', 'canvas.openFailed': 'Failed to open board', 'canvas.opening': 'Opening board…', + 'canvas.invalidId': 'Invalid canvas id', + 'canvas.confirmDeleteChat': 'Delete this chat and its message history?', + 'canvas.sessionDeleted': 'Session deleted', + 'canvas.chatUnlinked': 'Chat unlinked — moved to Sandbox', + 'canvas.unlinkFailed': 'Unlink failed', + 'canvas.sendFailed': 'Failed to send', + 'canvas.runCancelled': 'Run cancelled', + 'canvas.cancelFailed': 'Cancel failed', + 'canvas.tidied': 'Tidied {count} cards into columns', + 'canvas.tidyFailed': 'Tidy failed', + 'canvas.rename': 'Rename canvas', + 'canvas.waitFinish': 'Wait for the run to finish', + 'canvas.unlinkFrom': 'Unlink this chat from {title}', + 'canvas.noChatYet': 'No chat on this canvas yet', + 'canvas.collapseChat': 'Collapse chat', + 'canvas.expandChat': 'Expand chat', + 'global.somethingWentWrong': 'Something went wrong.', // --- Memory --- 'memory.title': 'Memory', @@ -274,6 +321,8 @@ export const en = { 'agentChat.loading': 'Loading conversation', 'agentChat.pickOption': 'Pick an option', 'agentChat.working': 'Agent is working…', + 'agent.task.story': 'Draft Storyline', + 'agent.task.script': 'Regenerate Script', 'agentComposer.aria': 'Message composer', 'agentComposer.attach': 'Attach file', 'agentComposer.attachLimit': 'Attachment limit reached', diff --git a/calliope-web/src/lib/i18n/zh.ts b/calliope-web/src/lib/i18n/zh.ts index 53ca2e67..f2fea475 100644 --- a/calliope-web/src/lib/i18n/zh.ts +++ b/calliope-web/src/lib/i18n/zh.ts @@ -43,6 +43,20 @@ export const zh: Dict = { 'nav.countActive': '{count} 个进行中', 'nav.eyebrow': 'Calliope', 'nav.unsaved': '未保存的更改', + 'nav.llm': '大语言模型', + 'nav.llmBlurb': '配置智能体使用的大语言模型。', + 'nav.comfy': 'ComfyUI', + 'nav.comfyBlurb': 'ComfyUI 的运行位置。', + 'nav.workflows': '工作流', + 'nav.workflowsBlurb': '上传并注册用于生成的 ComfyUI 工作流。', + 'nav.agent': '智能体模型', + 'nav.agentBlurb': '用于故事起草和智能体任务的模型。', + 'nav.skills': '技能', + 'nav.skillsBlurb': '本项目可用的智能体技能。', + 'nav.queue': '任务队列', + 'nav.queueBlurb': '生成任务的并发数与超时设置。', + 'nav.storage': '存储', + 'nav.storageBlurb': '文件在磁盘上的位置。', // --- Toast --- 'toast.dismiss': '关闭', @@ -138,6 +152,11 @@ export const zh: Dict = { // --- Project detail page --- 'project.backToProjects': '返回项目', + 'project.notFound': '未找到项目', + 'project.invalidIdBody': '“{id}”不是有效的项目 ID——链接可能已失效,或项目已被删除。', + 'project.openVideoStage': '打开视频工作台', + 'project.runningQueued': '{running} 运行中 · {queued} 排队中', + 'project.queueIdle': '队列空闲', // --- API errors --- 'api.unknownError': '出错了', @@ -204,6 +223,17 @@ export const zh: Dict = { 'artifact.playVideo': '播放视频', 'artifact.videoUnavailable': '视频不可用', 'artifact.viewImage': '查看图片', + 'canvas.emptyHint': '让右侧的智能体创建角色、场景,或生成图片或视频——输出会以卡片形式显示在这里。', + 'canvas.loadFailed': '无法加载此画布', + 'canvas.tidy': '整理布局', + 'canvas.tidyTitle': '将所有卡片重新排列为整洁的列与网格', + 'canvas.savePosFailed': '无法保存位置', + 'canvas.openThatFailed': '无法打开该画布', + 'canvas.sessionCreateFailed': '无法创建会话', + 'canvas.sessionDeleteFailed': '无法删除会话', + 'canvas.renameFailed': '重命名失败', + 'canvas.suggestFilm': '创建新影片', + 'canvas.suggestStory': '起草故事线', 'canvas.emptyBoard': '空白画布', 'canvas.noChatSelected': '未选择对话', 'canvas.failed': '失败', @@ -213,6 +243,23 @@ export const zh: Dict = { 'canvas.running': '运行中', 'canvas.openFailed': '无法打开画布', 'canvas.opening': '正在打开画布……', + 'canvas.invalidId': '无效的画布 ID', + 'canvas.confirmDeleteChat': '删除此对话及其消息历史?', + 'canvas.sessionDeleted': '对话已删除', + 'canvas.chatUnlinked': '对话已取消关联——已移至沙盒', + 'canvas.unlinkFailed': '取消关联失败', + 'canvas.sendFailed': '发送失败', + 'canvas.runCancelled': '运行已取消', + 'canvas.cancelFailed': '取消失败', + 'canvas.tidied': '已将 {count} 张卡片整理为多列', + 'canvas.tidyFailed': '整理失败', + 'canvas.rename': '重命名画布', + 'canvas.waitFinish': '等待运行完成', + 'canvas.unlinkFrom': '从 {title} 取消关联此对话', + 'canvas.noChatYet': '此画布尚无对话', + 'canvas.collapseChat': '收起对话', + 'canvas.expandChat': '展开对话', + 'global.somethingWentWrong': '出了点问题。', // --- Memory --- 'memory.title': '记忆', @@ -274,6 +321,8 @@ export const zh: Dict = { 'agentChat.loading': '正在加载对话', 'agentChat.pickOption': '选择一个选项', 'agentChat.working': '智能体正在工作……', + 'agent.task.story': '起草故事线', + 'agent.task.script': '重新生成剧本', 'agentComposer.aria': '消息输入框', 'agentComposer.attach': '添加附件', 'agentComposer.attachLimit': '已达附件上限', diff --git a/calliope-web/src/routes/agents/+page.svelte b/calliope-web/src/routes/agents/+page.svelte index e1127776..71723e02 100644 --- a/calliope-web/src/routes/agents/+page.svelte +++ b/calliope-web/src/routes/agents/+page.svelte @@ -3,7 +3,7 @@ import { goto } from '$app/navigation'; import { page } from '$app/state'; import { agentApi, canvasApi } from '$lib/api'; - import { AGENT_TASK_PROMPTS, AGENT_TASK_TITLES, isAgentTaskKind } from '$lib/agentTasks'; + import { AGENT_TASK_PROMPTS, AGENT_TASK_TITLE_KEYS, isAgentTaskKind } from '$lib/agentTasks'; import { t } from '$lib/i18n.svelte'; let failed = $state(''); @@ -21,7 +21,7 @@ const task = isAgentTaskKind(taskParam) ? taskParam : null; const s = await agentApi.createSession({ ...(pid != null && Number.isFinite(pid) ? { project_id: pid } : {}), - ...(task ? { title: AGENT_TASK_TITLES[task] } : {}), + ...(task ? { title: t(AGENT_TASK_TITLE_KEYS[task]) } : {}), }); sessionId = s.id; prefill = task ? AGENT_TASK_PROMPTS[task] : ''; diff --git a/calliope-web/src/routes/canvas/[id]/+page.svelte b/calliope-web/src/routes/canvas/[id]/+page.svelte index db3798b8..64fca027 100644 --- a/calliope-web/src/routes/canvas/[id]/+page.svelte +++ b/calliope-web/src/routes/canvas/[id]/+page.svelte @@ -52,7 +52,7 @@ const canvasId = Number(page.params.id); if (!Number.isFinite(canvasId)) { - throw new Error('Invalid canvas id'); + throw new Error(t('canvas.invalidId')); } const RAIL_KEY = 'calliope.canvas.railCollapsed'; @@ -234,7 +234,7 @@ y: node.position.y, }); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Could not save position'); + toast.error(err instanceof Error ? err.message : t('canvas.savePosFailed')); } } @@ -491,7 +491,7 @@ : await canvasApi.ensureForSession(s.id); goto(`/canvas/${graph.canvas.id}?session=${s.id}`); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Could not open that canvas'); + toast.error(err instanceof Error ? err.message : t('canvas.openThatFailed')); } } @@ -523,7 +523,7 @@ const graph = await canvasApi.ensureForSession(s.id); goto(`/canvas/${graph.canvas.id}?session=${s.id}`); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Could not create session'); + toast.error(err instanceof Error ? err.message : t('canvas.sessionCreateFailed')); } } @@ -540,19 +540,19 @@ goto(`/canvas/${graph.canvas.id}?session=${s.id}`); } } catch (err) { - toast.error(err instanceof Error ? err.message : 'Could not create session'); + toast.error(err instanceof Error ? err.message : t('canvas.sessionCreateFailed')); } } async function removeSession(id: number) { - if (!confirm('Delete this chat and its message history?')) return; + if (!confirm(t('canvas.confirmDeleteChat'))) return; try { await agentApi.deleteSession(id); if (activeId === id) activeId = null; await client.invalidateQueries({ queryKey: ['agent-sessions'] }); - toast.success('Session deleted'); + toast.success(t('canvas.sessionDeleted')); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Could not delete session'); + toast.error(err instanceof Error ? err.message : t('canvas.sessionDeleteFailed')); } } @@ -572,9 +572,9 @@ // Follow the chat to its sandbox canvas (created on demand). const graph = await canvasApi.ensureForSession(sid); goto(`/canvas/${graph.canvas.id}?session=${sid}`); - toast.success('Chat unlinked — moved to Sandbox'); + toast.success(t('canvas.chatUnlinked')); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Unlink failed'); + toast.error(err instanceof Error ? err.message : t('canvas.unlinkFailed')); } } @@ -598,7 +598,7 @@ await client.invalidateQueries({ queryKey: ['agent-sessions'] }); }, onError: (err) => { - toast.error(err instanceof Error ? err.message : 'Failed to send'); + toast.error(err instanceof Error ? err.message : t('canvas.sendFailed')); }, }); @@ -611,9 +611,9 @@ // so the composer leaves its running state immediately. await client.invalidateQueries({ queryKey: ['agent-sessions'] }); await client.invalidateQueries({ queryKey: ['agent-session', activeId] }); - toast.info('Run cancelled'); + toast.info(t('canvas.runCancelled')); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Cancel failed'); + toast.error(err instanceof Error ? err.message : t('canvas.cancelFailed')); } } @@ -628,7 +628,7 @@ activeId = s.id; $sendMutation.mutate(payload); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Could not create session'); + toast.error(err instanceof Error ? err.message : t('canvas.sessionCreateFailed')); } } @@ -865,9 +865,9 @@ try { const res = await canvasApi.tidy(canvasId); await client.invalidateQueries({ queryKey: ['canvas', canvasId] }); - toast.success(`Tidied ${res.moved} cards into columns`); + toast.success(t('canvas.tidied', { count: res.moved })); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Tidy failed'); + toast.error(err instanceof Error ? err.message : t('canvas.tidyFailed')); } finally { tidying = false; } @@ -956,17 +956,17 @@ savedFlash = true; setTimeout(() => (savedFlash = false), 1400); } catch (err) { - toast.error(err instanceof Error ? err.message : 'Rename failed'); + toast.error(err instanceof Error ? err.message : t('canvas.renameFailed')); } } const SUGGESTIONS: { label: string; prompt: string }[] = [ { - label: 'Create a new film', + label: t('canvas.suggestFilm'), prompt: 'Create a new film project and guide me through drafting the story.', }, { - label: 'Draft a storyline', + label: t('canvas.suggestStory'), prompt: 'Draft a storyline — beats, characters, environments, and misc. items.', }, ]; @@ -977,7 +977,7 @@ {#if $canvasQuery.isError}