i18n: 补齐设置导航与画布/项目页缺失的中文文案

SettingsNav 7 个 tab 的 nav.* key(label/blurb)补齐中英文案;画布页 canvas/[id] 所有硬编码英文(toast、确认框、按钮 title、空态/错误提示)改为 t() 动态键;项目页 project/[id] 错误态、视频工作台按钮、队列状态接入 i18n;agents 页自动会话标题改用 t()(agent.task.*),移除静态 AGENT_TASK_TITLES;hooks.client.ts 全局兜底错误消息接入 i18n。en/zh 各 983 keys 键集完全对齐,svelte-check 0 errors。
This commit is contained in:
happymy
2026-09-12 13:21:59 +08:00
parent be0f5b6046
commit 0caadd5a97
7 changed files with 144 additions and 48 deletions
+2 -1
View File
@@ -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'),
};
};
+4 -4
View File
@@ -17,10 +17,10 @@ export const AGENT_TASK_PROMPTS: Record<AgentTaskKind, string> = {
'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<AgentTaskKind, string> = {
story: 'Draft Storyline',
script: 'Regenerate Script',
/** i18n key for the auto-created session's sidebar title. */
export const AGENT_TASK_TITLE_KEYS: Record<AgentTaskKind, string> = {
story: 'agent.task.story',
script: 'agent.task.script',
};
export function isAgentTaskKind(value: string | null | undefined): value is AgentTaskKind {
+49
View File
@@ -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',
+49
View File
@@ -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': '已达附件上限',
+2 -2
View File
@@ -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] : '';
@@ -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}
<div class="load-error" role="alert">
Could not load this canvas
{t('canvas.loadFailed')}
{#if $canvasQuery.error instanceof Error}
— {$canvasQuery.error.message}
{/if}
@@ -1012,7 +1012,7 @@
type="button"
class="title-btn"
onclick={() => (titleEditing = true)}
title="Rename canvas"
title={t('canvas.rename')}
>
{canvas.title}
</button>
@@ -1030,11 +1030,11 @@
class="unlink-btn"
onclick={unlinkActiveSession}
disabled={!activeSession || running}
title={running
? 'Wait for the run to finish'
: activeSession
? `Unlink this chat from ${canvas.project.title}`
: 'No chat on this canvas yet'}
title={running
? t('canvas.waitFinish')
: activeSession
? t('canvas.unlinkFrom', { title: canvas.project.title })
: t('canvas.noChatYet')}
aria-label={`Unlink this chat from ${canvas.project.title}`}
>
<Icon name="link-off" size={12} />
@@ -1075,20 +1075,17 @@
class="tidy-btn"
disabled={tidying || nodes.length === 0}
onclick={tidyCanvas}
title="Re-arrange all cards into clean columns and grids"
title={t('canvas.tidyTitle')}
>
<Icon name="drag" size={14} />
Tidy layout
{t('canvas.tidy')}
</button>
</Panel>
{#if nodes.length === 0 && !$canvasQuery.isLoading}
<Panel position="top-center">
<div class="canvas-empty-hint">
<strong>{t('canvas.emptyBoard')}</strong>
<span>
Ask the agent on the right to create characters, scenes, or to
generate an image or video — outputs land here as cards.
</span>
<span>{t('canvas.emptyHint')}</span>
</div>
</Panel>
{/if}
@@ -1127,8 +1124,8 @@
type="button"
class="chat-toggle"
onclick={toggleChat}
title="Collapse chat"
aria-label="Collapse chat"
title={t('canvas.collapseChat')}
aria-label={t('canvas.collapseChat')}
>
<Icon name="chevron-right" size={14} />
</button>
@@ -1165,8 +1162,8 @@
type="button"
class="chat-expand"
onclick={toggleChat}
title="Expand chat"
aria-label="Expand chat"
title={t('canvas.expandChat')}
aria-label={t('canvas.expandChat')}
>
<Icon name="chevron-left" size={14} />
</button>
@@ -152,8 +152,8 @@
{#if !enabled}
<div class="invalid-wrap">
<EmptyState
title="Project not found"
body={`“${data.id}” isn’t a valid project id — the link may be broken or the project was deleted.`}
title={t('project.notFound')}
body={t('project.invalidIdBody', { id: data.id })}
>
{#snippet icon()}
<Icon name="folder" size={28} />
@@ -169,13 +169,13 @@
<Button
variant="secondary"
size="sm"
title="Open the Video stage"
title={t('project.openVideoStage')}
onclick={() => selectStage('video')}
>
<Icon name="queue" size={13} />
{runningCount + queuedCount > 0
? `${runningCount} running · ${queuedCount} queued`
: 'Queue idle'}
? t('project.runningQueued', { running: runningCount, queued: queuedCount })
: t('project.queueIdle')}
{#if queuePaused}
<StatusChip status="paused" />
{/if}