feat(i18n): 全量中英双语字典与组件接入

- en.ts 934 键无重复,zh.ts 全量镜像
- 补齐 assets/buildScene/queue 缺失键,修正 promptPreview.sceneMeta/shotMeta 占位符
- i18n.svelte.ts 修复 \ 响应式语言状态
- 修复 QueueStage/ToastHost 局部变量遮蔽 t()
This commit is contained in:
happymy
2026-09-12 13:00:19 +08:00
parent 929df8c9b6
commit be0f5b6046
64 changed files with 3540 additions and 1341 deletions
@@ -3,6 +3,7 @@
import SafeMedia from '$lib/components/SafeMedia.svelte';
import ImageLightbox from '$lib/components/ImageLightbox.svelte';
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
export interface ArtifactJob {
id: number;
@@ -31,10 +32,10 @@
const isVideo = $derived(primaryPath ? isVideoPath(primaryPath, job.kind) : job.kind === 'video');
function statusWord(status: string): string {
if (status === 'done') return 'Ready';
if (status === 'running') return 'Generating';
if (status === 'pending') return 'Queued';
if (status === 'failed') return 'Failed';
if (status === 'done') return t('job.status.done');
if (status === 'running') return t('job.status.generating');
if (status === 'pending') return t('job.status.queued');
if (status === 'failed') return t('job.status.failed');
return status;
}
@@ -55,7 +56,7 @@
{#if busy}
<div class="waiting" aria-busy="true">
<span class="pulse"></span>
<span class="waiting-text">{job.status === 'running' ? 'Generating…' : 'Queued'}</span>
<span class="waiting-text">{job.status === 'running' ? t('job.status.generatingPulse') : t('job.status.queued')}</span>
</div>
{/if}
@@ -68,8 +69,8 @@
<button
type="button"
class="media-hit"
aria-label="Play video, artifact {job.id}"
title="Play in viewer"
aria-label={t('artifact.playVideo', { id: job.id })}
title={t('artifact.playInViewer')}
onclick={() => (preview = { src: primaryMedia, kind: 'video' })}
>
<div class="media-frame">
@@ -77,7 +78,7 @@
class="artifact-media"
src={primaryMedia}
kind="video"
label="Video unavailable"
label={t('artifact.videoUnavailable')}
controls={false}
/>
<span class="play-badge" aria-hidden="true"><Icon name="play" size={20} /></span>
@@ -87,29 +88,29 @@
<button
type="button"
class="media-hit"
aria-label="View image, artifact {job.id}"
aria-label={t('artifact.viewImage', { id: job.id })}
onclick={() => (preview = { src: primaryMedia, kind: 'image' })}
>
<div class="media-frame">
<SafeMedia
class="artifact-media"
src={primaryMedia}
alt="Artifact {job.id}"
label="Image unavailable"
alt={t('artifact.artifactLabel', { id: job.id })}
label={t('artifact.imageUnavailable')}
/>
</div>
</button>
{/if}
{:else if job.status === 'done'}
<div class="missing">
<p>File missing on disk</p>
<p>{t('artifact.fileMissing')}</p>
</div>
{/if}
</div>
<ImageLightbox
src={preview?.src ?? null}
alt={`Artifact #${job.id}`}
alt={t('artifact.artifactLabel', { id: job.id })}
kind={preview?.kind ?? 'image'}
onClose={() => (preview = null)}
/>
@@ -7,6 +7,7 @@
import ReasoningPanel from './ReasoningPanel.svelte';
import { agentColor, agentDisplayName } from './agentPalette';
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
interface Props {
messages: AgentMessage[];
@@ -158,8 +159,8 @@
});
function answerLabel(scope: string): string {
if (scope === 'render') return 'Your click records approval to generate.';
if (scope === 'destructive_replace') return 'Your click records approval to replace content.';
if (scope === 'render') return t('agentChat.approveRender');
if (scope === 'destructive_replace') return t('agentChat.approveReplace');
return '';
}
@@ -189,17 +190,14 @@
<div class="chat" bind:this={listEl} onscroll={onScroll}>
{#if loading}
<div class="empty">
<p class="empty-hint">Loading chat…</p>
<p class="empty-hint">{t('agentChat.loading')}</p>
</div>
{:else if messages.length === 0 && !running}
<div class="empty">
<div class="empty-mark"><Icon name="sparkle" size={22} /></div>
<p class="empty-eyebrow">Calliope</p>
<p class="empty-title">What are we making?</p>
<p class="empty-hint">
Tell your production agent the idea and it takes the story to script to video — or ask it to
work on one of your projects.
</p>
<p class="empty-title">{t('agentChat.emptyTitle')}</p>
<p class="empty-hint">{t('agentChat.emptyHint')}</p>
{#if suggestions.length > 0}
<div class="suggestions">
{#each suggestions as s (s.label)}
@@ -266,7 +264,7 @@
{/each}
</div>
<p class="question-hint">
{answerLabel(lastQuestion.scope) || 'Pick an option or just type your answer.'}
{answerLabel(lastQuestion.scope) || t('agentChat.pickOption')}
</p>
</div>
{/if}
@@ -320,7 +318,7 @@
{#if streaming}
<div class="stream-text">{streaming}<span class="caret"></span></div>
{:else}
<div class="thinking"><span class="pulse"></span> working…</div>
<div class="thinking"><span class="pulse"></span> {t('agentChat.working')}</div>
{/if}
{#if streamingReasoning}
<ReasoningPanel streaming={streamingReasoning} />
@@ -17,6 +17,7 @@
import { createUploadManager, truncateMiddle } from '$lib/comfy/useUpload.svelte';
import { toast } from '$lib/toast';
import WorkflowMentionMenu from './WorkflowMentionMenu.svelte';
import { t } from '$lib/i18n.svelte';
interface Props {
running: boolean;
@@ -350,7 +351,7 @@ let {
const list = Array.from(files);
for (const file of list) {
if (attachments.length >= ATTACH_LIMIT) {
toast.error(`At most ${ATTACH_LIMIT} attachments`);
toast.error(t('agentComposer.attachLimit', { count: ATTACH_LIMIT }));
break;
}
const slot = `attach-${Date.now()}-${Math.random().toString(16).slice(2)}`;
@@ -481,7 +482,7 @@ let {
class="composer"
class:drag-over={dragOver}
role="region"
aria-label="Message composer"
aria-label={t('agentComposer.aria')}
ondragover={(e) => {
e.preventDefault();
dragOver = true;
@@ -490,7 +491,7 @@ let {
ondrop={onDrop}
>
{#if attachments.length > 0 || uploadingNames.length > 0}
<div class="tray" aria-label="Attachments">
<div class="tray" aria-label={t('agentComposer.attachments')}>
{#each attachments as a, i (a.path)}
<div class="tile">
{#if a.kind === 'image'}
@@ -511,7 +512,7 @@ let {
<button
type="button"
class="tile-x"
title="Remove"
title={t('agentComposer.remove')}
onclick={() => removeAttachment(i)}
disabled={running}
>
@@ -536,8 +537,8 @@ let {
role="textbox"
tabindex="0"
aria-multiline="true"
aria-label="Message"
data-placeholder={running ? 'Agent is working…' : 'Describe what you want to build or change…'}
aria-label={t('agentComposer.message')}
data-placeholder={running ? t('agentComposer.working') : t('agentComposer.placeholder')}
onkeydown={onKeydown}
oninput={onEditorInput}
onpaste={onPaste}
@@ -554,16 +555,16 @@ let {
<button
type="button"
class="attach"
title="Attach image, video, or audio"
title={t('agentComposer.attach')}
disabled={busy}
onclick={() => fileInput?.click()}
>
<Icon name="paperclip" size={16} />
</button>
{#if running}
<button type="button" class="send stop" onclick={onCancel} title="Stop the agent">
<button type="button" class="send stop" onclick={onCancel} title={t('agentComposer.stopTitle')}>
<Icon name="stop" size={14} />
Stop
{t('common.stop')}
</button>
{:else}
<button
@@ -571,9 +572,9 @@ let {
class="send"
onclick={submit}
disabled={!sendable}
title="Send (Enter)"
title={t('agentComposer.sendTitle')}
>
Send
{t('common.send')}
<Icon name="chevron-right" size={14} />
</button>
{/if}
@@ -585,7 +586,7 @@ let {
open={mentionOpen}
items={mentionLocked ? [] : mentionItems}
lockReason={mentionLocked
? 'One workflow per message — remove the existing @ tag to pick another.'
? t('agentComposer.mentionLock')
: null}
activeIndex={mentionIndex}
anchor={mentionAnchor}
@@ -2,6 +2,7 @@
import type { AgentPlan } from '$lib/api';
import { agentColor, agentDisplayName } from './agentPalette';
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
interface Props {
plan: AgentPlan;
@@ -21,10 +22,10 @@
}
function statusLabel(status: string): string {
if (status === 'running') return 'Running';
if (status === 'done') return 'Done';
if (status === 'failed') return 'Failed';
return 'Queued';
if (status === 'running') return t('job.status.running');
if (status === 'done') return t('job.status.done');
if (status === 'failed') return t('job.status.failed');
return t('queue.queued');
}
</script>
@@ -33,7 +34,7 @@
<span class="icon-wrap" class:spinning={running}>
<Icon name="sparkle" size={13} />
</span>
<span class="title">Planner</span>
<span class="title">{t('agentPlan.planner')}</span>
{#if plan.note}
<span class="note">{plan.note}</span>
{/if}
@@ -1,6 +1,7 @@
<script lang="ts">
import type { AgentSession } from '$lib/api';
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
interface Props {
sessions: AgentSession[];
@@ -46,8 +47,8 @@
type="button"
class="rail-btn"
onclick={() => onToggleCollapse?.()}
title="Expand sessions"
aria-label="Expand sessions"
title={t('sessionSidebar.expand')}
aria-label={t('sessionSidebar.expand')}
>
<Icon name="drag" size={14} />
</button>
@@ -55,8 +56,8 @@
type="button"
class="rail-btn"
onclick={onNewSandbox}
title="New sandbox chat"
aria-label="New sandbox chat"
title={t('sessionSidebar.newSandbox')}
aria-label={t('sessionSidebar.newSandbox')}
>
<Icon name="plus" size={14} />
</button>
@@ -69,7 +70,7 @@
class:run={s.running || s.status === 'running'}
onclick={() => onSelect(s.id)}
title={s.title}
aria-label={`Open ${s.title}`}
aria-label={t('sessionSidebar.open', { title: s.title })}
></button>
{/each}
</div>
@@ -81,25 +82,25 @@
type="button"
class="collapse-toggle"
onclick={() => onToggleCollapse?.()}
title="Collapse sessions"
aria-label="Collapse sessions"
title={t('sessionSidebar.collapse')}
aria-label={t('sessionSidebar.collapse')}
>
<Icon name="drag" size={14} />
</button>
{/if}
<button type="button" class="new-chat" onclick={onNewSandbox}>
<Icon name="plus" size={14} />
New sandbox chat
{t('sessionSidebar.newSandboxButton')}
</button>
{#if sessions.length === 0}
<p class="muted">No sessions yet.</p>
<p class="muted">{t('sessionSidebar.noSessions')}</p>
{/if}
{#if sandbox.length > 0}
<div class="group">
<div class="group-head">
<span class="group-title">Sandbox</span>
<span class="group-title">{t('sessionSidebar.sandbox')}</span>
<span class="count">{sandbox.length}</span>
</div>
{#each sandbox as s (s.id)}
@@ -111,56 +112,56 @@
>
<span class="dot" class:run={s.running || s.status === 'running'}></span>
<span class="title">{s.title}</span>
<span
class="del"
role="button"
tabindex="-1"
aria-label="Delete session"
onclick={(e) => {
e.stopPropagation();
onDelete(s.id);
}}
onkeydown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
onDelete(s.id);
}
}}
>
<Icon name="trash" size={12} />
</span>
</button>
{/each}
</div>
{/if}
{#each grouped as g (g.project?.id ?? 0)}
<div class="group">
<div class="group-head">
<span class="group-title" title={g.project?.title}>
{g.project?.title ?? `Project #${g.project?.id ?? '?'}`}
</span>
<span class="count">{g.items.length}</span>
<span
class="add-chat"
<span
class="del"
role="button"
tabindex="0"
aria-label="New chat for this project"
title="New chat for this project"
tabindex="-1"
aria-label={t('sessionSidebar.deleteSession')}
onclick={(e) => {
e.stopPropagation();
if (g.project) onNewProjectChat(g.project.id);
onDelete(s.id);
}}
onkeydown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
if (g.project) onNewProjectChat(g.project.id);
onDelete(s.id);
}
}}
>
<Icon name="plus" size={12} />
<Icon name="trash" size={12} />
</span>
</div>
</button>
{/each}
</div>
{/if}
{#each grouped as g (g.project?.id ?? 0)}
<div class="group">
<div class="group-head">
<span class="group-title" title={g.project?.title}>
{g.project?.title ?? t('sessionSidebar.projectFallback', { id: g.project?.id ?? '?' })}
</span>
<span class="count">{g.items.length}</span>
<span
class="add-chat"
role="button"
tabindex="0"
aria-label={t('sessionSidebar.newProjectChat')}
title={t('sessionSidebar.newProjectChat')}
onclick={(e) => {
e.stopPropagation();
if (g.project) onNewProjectChat(g.project.id);
}}
onkeydown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
if (g.project) onNewProjectChat(g.project.id);
}
}}
>
<Icon name="plus" size={12} />
</span>
</div>
{#each g.items as s (s.id)}
<button
type="button"
@@ -170,24 +171,24 @@
>
<span class="dot" class:run={s.running || s.status === 'running'}></span>
<span class="title">{s.title}</span>
<span
class="del"
role="button"
tabindex="-1"
aria-label="Delete session"
onclick={(e) => {
<span
class="del"
role="button"
tabindex="-1"
aria-label={t('sessionSidebar.deleteSession')}
onclick={(e) => {
e.stopPropagation();
onDelete(s.id);
}}
onkeydown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
onDelete(s.id);
}}
onkeydown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
onDelete(s.id);
}
}}
>
<Icon name="trash" size={12} />
</span>
}
}}
>
<Icon name="trash" size={12} />
</span>
</button>
{/each}
</div>
@@ -1,5 +1,6 @@
<script lang="ts">
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
interface Props {
name: string;
@@ -25,11 +26,11 @@
<span class="dot" class:running={phase === 'running'}></span>
<span class="name mono">{name}</span>
{#if phase === 'running'}
<span class="state">running…</span>
<span class="state">{t('agentTool.running')}</span>
{:else if phase === 'error'}
<span class="state err-text">failed</span>
<span class="state err-text">{t('agentTool.failed')}</span>
{:else}
<span class="state ok-text">done</span>
<span class="state ok-text">{t('agentTool.done')}</span>
{/if}
<span class="chev"><Icon name="chevron-down" size={13} /></span>
</button>
@@ -37,13 +38,13 @@
<div class="body">
{#if args && Object.keys(args).length > 0}
<div class="section">
<span class="label">args</span>
<span class="label">{t('agentTool.args')}</span>
<pre>{fmt(args)}</pre>
</div>
{/if}
{#if result != null}
<div class="section">
<span class="label">result</span>
<span class="label">{t('agentTool.result')}</span>
<pre>{fmt(result)}</pre>
</div>
{/if}
@@ -1,5 +1,6 @@
<script lang="ts">
import Icon from '$lib/components/ui/Icon.svelte';
import { t } from '$lib/i18n.svelte';
interface Props {
/** Persisted reasoning text (from stored message). */
@@ -25,11 +26,11 @@
</span>
<span class="label">
{#if isLive && !open}
Thinking…
{t('reasoning.thinking')}
{:else if open}
Reasoning
{t('reasoning.title')}
{:else}
Show reasoning
{t('reasoning.show')}
{/if}
</span>
<span class="chev"><Icon name="chevron-down" size={12} /></span>
@@ -1,4 +1,6 @@
<script lang="ts">
import { t } from '$lib/i18n.svelte';
interface MenuItem {
id?: number;
name: string;
@@ -87,12 +89,12 @@
? 'visible'
: 'hidden'}"
role="listbox"
aria-label={skillMode ? 'Skills' : 'Workflows'}
aria-label={skillMode ? t('mentionMenu.skills') : t('mentionMenu.workflows')}
>
{#if lockReason}
<div class="empty">{lockReason}</div>
{:else if items.length === 0}
<div class="empty">{skillMode ? 'No matching skill' : 'No matching workflow'}</div>
<div class="empty">{skillMode ? t('mentionMenu.noSkill') : t('mentionMenu.noWorkflow')}</div>
{:else}
{#each items as item, i (item.id ?? item.name)}
<button