fix(i18n): 修复 {n} 占位符插值断裂

t() 按 {占位名} 逐名替换,但多数 count 语义键字典用 {n}、调用处传 count 或不传参,导致页面显示字面 "{n}"。t() 增加 count→{n} 约定,一次性修复 WorkflowsLibrary 统计、ProjectCard 相对时间、ActivityPanel、NavRail、MemoryPanel、ScriptStage、AssetsStage 等错配;queue.exportingSub/filmstrip.sceneClips/queue.scene/script.shotClipPlural 补 {n} 参数;queue.queueingProgress 与 queue.filmMeta 调用参数对齐字典;filmstrip.clipTitle 重写为 {scene}·镜头 {shot}·{time}。en/zh 983 keys 对齐,svelte-check 0 errors。
This commit is contained in:
happymy
2026-09-12 15:56:31 +08:00
parent 0caadd5a97
commit 44ab8389d6
6 changed files with 12 additions and 10 deletions
@@ -462,7 +462,7 @@ const generateOne = createMutation({
: [{ id: scene.id, key: String(scene.id) }];
for (const target of renderTargets) {
done++;
batchNote = t('queue.queueingProgress', { current: done, total: totalClips });
batchNote = t('queue.queueingProgress', { n: done, total: totalClips });
try {
// Resolve like the per-clip button does: session pick → scene's stored
// workflow → first enabled video workflow. A scene whose stored workflow
@@ -977,7 +977,7 @@ const generateOne = createMutation({
label={exportProg?.message}
/>
</div>
<p class="slate-sub">{t('queue.exportingSub')}</p>
<p class="slate-sub">{t('queue.exportingSub', { n: clipsReady })}</p>
<Button variant="ghost" size="sm" onclick={cancelExport}
>{t('common.cancel')}</Button
>
@@ -1038,7 +1038,7 @@ const generateOne = createMutation({
{@const exportUrl = assetUrl(exportPath)}
<div class="film-meta">
<span class="film-meta-text">
{t('queue.filmMeta', { clips: exportClipCount, time: formatClock(totalSec) })}
{t('queue.filmMeta', { scenes: scenes.length, clips: exportClipCount, duration: formatClock(totalSec) })}
{#if exportedAgo} · {t('queue.exportedAgo', { ago: exportedAgo })}{/if}
</span>
<div class="film-actions">
@@ -1069,7 +1069,7 @@ const generateOne = createMutation({
type="button"
class="filmstrip-item"
title={t('queue.editInTimeline', {
scene: entry.scene.heading || t('queue.scene'),
scene: entry.scene.heading || t('queue.scene', { n: entry.scene.order_index }),
label: entry.label,
})}
onclick={() => editScene(entry.scene.id)}
@@ -440,7 +440,7 @@
<span class="clip-title">
<Icon name="film" size={12} />
{(scene.clips ?? []).length}
{((scene.clips ?? []).length === 1 ? t('script.shotClipSingular') : t('script.shotClipPlural'))}
{((scene.clips ?? []).length === 1 ? t('script.shotClipSingular') : t('script.shotClipPlural', { n: (scene.clips ?? []).length }))}
{#if (scene.clips ?? []).some((c) => c.clip_path)}
· {t('script.renderedCount', { count: (scene.clips ?? []).filter((c) => c.clip_path).length })}
{/if}
@@ -73,7 +73,7 @@
<div
class="track"
role="listbox"
aria-label={t('filmstrip.sceneClips')}
aria-label={t('filmstrip.sceneClips', { n: clips.length })}
aria-activedescendant={selectedClipId != null ? `film-clip-${selectedClipId}` : undefined}
tabindex="0"
onkeydown={onKeydown}
+2
View File
@@ -34,6 +34,8 @@ export function t(key: string, vars?: Record<string, string | number>): string {
let s: string = dictionaries[language.current][key] ?? (en as Record<string, string>)[key] ?? key;
if (vars) {
for (const [k, v] of Object.entries(vars)) s = s.replaceAll(`{${k}}`, String(v));
// ponytail: count 语义占位统一为 {n};调用方传 count 即命中
if (vars.count !== undefined) s = s.replaceAll('{n}', String(vars.count));
}
return s;
}
+3 -3
View File
@@ -700,7 +700,7 @@ export const en = {
// --- Filmstrip ---
'filmstrip.title': 'Filmstrip',
'filmstrip.clipTitle': 'Clip {n}',
'filmstrip.clipTitle': '{scene} · shot {shot} · {time}',
'filmstrip.scene': 'Scene',
'filmstrip.sceneClips': '{n} clips',
'filmstrip.prev': 'Previous clip',
@@ -804,8 +804,8 @@ export const en = {
'wf.deleteTitle': 'Delete workflow',
'wf.deleteMessage': 'This workflow and its saved JSON will be deleted.',
'wf.analyzeRegister': 'Analyze & register',
'wf.countImage': '{n} image',
'wf.countVideo': '{n} video',
'wf.countImage': '{n} images',
'wf.countVideo': '{n} videos',
'wf.countSaved': '{n} saved',
'wf.profileH3': 'Use case',
'wf.profileProse': 'This workflow generates {kind} from a {target}.',
+1 -1
View File
@@ -700,7 +700,7 @@ export const zh: Dict = {
// --- Filmstrip ---
'filmstrip.title': '胶片条',
'filmstrip.clipTitle': '片段 {n}',
'filmstrip.clipTitle': '{scene} · 镜头 {shot} · {time}',
'filmstrip.scene': '场景',
'filmstrip.sceneClips': '{n} 个片段',
'filmstrip.prev': '上一个片段',