Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
fix(web): localize video translation file and format controls
Joshua Yin Junxi85c2b1ef2207
diff --git a/apps/web/src/features/dashboard/VideoTranslationSubtitleImport.tsx b/apps/web/src/features/dashboard/VideoTranslationSubtitleImport.tsxindex 5fd8ddae..c915dc7f 100644--- a/apps/web/src/features/dashboard/VideoTranslationSubtitleImport.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationSubtitleImport.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { useId, useRef, useState } from 'react';import { useLocalizedCopy } from '../../i18n/useLocalizedCopy.js';import {captureCreatorClientFailure,@@ -12,6 +12,9 @@ export function VideoTranslationSubtitleImport(props: { sourceLanguage: string;const [kind, setKind] = useState('source_subtitle');const [busy, setBusy] = useState(false);const [error, setError] = useState('');+ const [selectedFileName, setSelectedFileName] = useState('');+ const fileInputId = useId();+ const fileInputRef = useRef<HTMLInputElement>(null);if (session === null) return null;const imports = session.job.artifacts.filter(artifact => artifact.metadata.source === 'local-upload' && artifact.kind.endsWith('_subtitle'));@@ -71,13 +74,21 @@ export function VideoTranslationSubtitleImport(props: { sourceLanguage: string;<option value="target_subtitle">{l('已翻译字幕(跳过识别和翻译)', 'Translated subtitles (skip transcription and translation)')}</option></select></label>- <label><span>{l('UTF-8 SRT 文件', 'UTF-8 SRT file')}</span>- <input type="file" accept=".srt" onChange={event => {- const file = event.target.files?.[0];- event.target.value = '';- if (file) void importFile(file);- }} />- </label>+ <div className="video-translation-subtitle-file-field">+ <label htmlFor={fileInputId}>{l('UTF-8 SRT 文件', 'UTF-8 SRT file')}</label>+ <div className="video-translation-subtitle-file-picker">+ <input ref={fileInputRef} id={fileInputId} className="app-visually-hidden" tabIndex={-1} type="file" accept=".srt" onChange={event => {+ const file = event.target.files?.[0];+ event.target.value = '';+ if (file) {+ setSelectedFileName(file.name);+ void importFile(file);+ }+ }} />+ <button type="button" onClick={() => fileInputRef.current?.click()}>{l('选择文件', 'Choose file')}</button>+ <span aria-live="polite">{selectedFileName || l('未选择文件', 'No file selected')}</span>+ </div>+ </div><p>{l('语言沿用上方选择。仅有译文时不会生成双语字幕。', 'Uses the language selected above. A translated-only import does not generate bilingual subtitles.')}</p>{busy ? <p role="status">{l('正在导入字幕…', 'Importing subtitles…')}</p> : null}{error ? <p role="alert">{error}</p> : null}diff --git a/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx b/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsxindex e51a30b1..68d89425 100644--- a/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationWorkspace.control.test.tsx@@ -12,6 +12,23 @@ import { CreatorSessionProvider, useCreatorSession } from './creator-session-stoimport VideoTranslationWorkspace from './VideoTranslationWorkspace.js';describe('VideoTranslationWorkspace task controls', () => {+ it('shows English file picker and output format labels', () => {+ render(<LanguageProvider initialPreference="en-US"><CreatorSessionProvider+ initialJob={job({ status: 'draft', revision: 0, stages: [], state: { currentStep: 1, composeVideo: true } })}+ service={{ applyAction: vi.fn(), runAgentTurn: vi.fn() } as never}+ ><VideoTranslationWorkspace onBack={vi.fn()} /></CreatorSessionProvider></LanguageProvider>);++ fireEvent.click(screen.getByRole('switch', { name: 'Import existing subtitles' }));+ expect(screen.getByRole('button', { name: 'Choose file' })).toBeInTheDocument();+ expect(screen.getByText('No file selected')).toBeInTheDocument();+ expect(screen.getByLabelText('UTF-8 SRT file')).toHaveAttribute('type', 'file');++ fireEvent.click(screen.getByRole('button', { name: 'Continue' }));+ fireEvent.click(screen.getByRole('button', { name: 'Continue' }));+ expect(screen.getByRole('radio', { name: '16:9 + 9:16 Both' })).toBeInTheDocument();+ expect(screen.queryByText('双画幅')).not.toBeInTheDocument();+ });+it('keeps an imported translation in configuration and shows its persisted metadata', async () => {let current = job({ status: 'draft', revision: 0, stages: [], state: { currentStep: 1, furthestStep: 1 } });const applyAction = vi.fn(async (_id: string, request: { action: string; input: Record<string, CreatorJson> }) => {diff --git a/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsx b/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsxindex becc102e..b6bb3086 100644--- a/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsx+++ b/apps/web/src/features/dashboard/VideoTranslationWorkspace.tsx@@ -3371,7 +3371,7 @@ export default function VideoTranslationWorkspace(props: {setVideoFormat(value);}}>- <span>{ratio}</span>+ <span>{value === 'all' ? l('双画幅', '16:9 + 9:16') : ratio}</span><small>{localizeFormatLabel(label, l)}</small>{videoFormat === value ? <Check size={14} strokeWidth={2} aria-hidden="true" /> : null}</button>diff --git a/apps/web/src/features/dashboard/dashboard.css b/apps/web/src/features/dashboard/dashboard.cssindex 9af77c00..662fff3d 100644--- a/apps/web/src/features/dashboard/dashboard.css+++ b/apps/web/src/features/dashboard/dashboard.css@@ -849,6 +849,7 @@}.video-translation-subtitle-import-fields label > span,+.video-translation-subtitle-file-field > label,.video-translation-subtitle-import-fields p {margin: 0;color: var(--muted);@@ -860,6 +861,53 @@padding: 0 10px;}+.video-translation-subtitle-file-field {+ display: grid;+ gap: 6px;+}++.video-translation-subtitle-file-picker {+ min-height: 42px;+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 4px 12px;+ border: 1px solid var(--border);+ border-radius: 7px;+ background: var(--surface);+}++.video-translation-subtitle-file-picker input.app-visually-hidden {+ width: 1px;+ height: 1px;+ padding: 0;+ border: 0;+}++.video-translation-subtitle-file-picker button {+ flex: 0 0 auto;+ padding: 4px 8px;+ border: 1px solid var(--border);+ border-radius: 4px;+ background: var(--surface-2);+ color: var(--text);+ font-size: 12px;+}++.video-translation-subtitle-file-picker button:focus-visible {+ outline: 2px solid var(--accent);+ outline-offset: 2px;+}++.video-translation-subtitle-file-picker > span {+ min-width: 0;+ overflow: hidden;+ color: var(--muted);+ font-size: 12px;+ text-overflow: ellipsis;+ white-space: nowrap;+}+.video-translation-subtitle-import-fields details {color: var(--muted);font-size: 11px;