feat(transcript): add Chinese script choices

This commit is contained in:
yiling
2026-12-05 11:43:32 +08:00
parent 6c74413375
commit 70e4c63323
19 changed files with 242 additions and 29 deletions
@@ -2,6 +2,7 @@ import { useRef, useState } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { toast } from 'sonner'
import { client } from '@/ui/api/client'
import { getChineseTranscriptLanguageName } from '@/ui/lib/transcript'
import { m } from '@/ui/paraglide/messages.js'
import { savedTranscriptLanguagesKey } from '@/ui/hooks/use-video-transcript'
import { Button } from '@/ui/components/ui/button'
@@ -77,7 +78,10 @@ export function GenerateTranscriptsDialog({
const choices = [
{ code: '', name: m.transcript_language_auto() },
...(languages.data?.languages ?? []),
...(languages.data?.languages ?? []).map(({ code, name }) => ({
code,
name: getChineseTranscriptLanguageName(code) ?? name,
})),
]
const busy = generate.isPending || isTranscribing
@@ -5,6 +5,7 @@ import { NativeSelect, NativeSelectOption } from '@/ui/components/ui/native-sele
import { ScrollArea } from '@/ui/components/ui/scroll-area'
import type { MediaController } from '@/ui/components/viewers/types'
import { savedTranscriptKey } from '@/ui/hooks/use-video-transcript'
import { getChineseTranscriptLanguageName } from '@/ui/lib/transcript'
import { cn } from '@/ui/lib/utils'
import { m } from '@/ui/paraglide/messages.js'
import { getLocale } from '@/ui/paraglide/runtime.js'
@@ -69,7 +70,10 @@ export const TranscriptPanel = memo(function TranscriptPanel({
const options = useMemo(() => {
const names = new Intl.DisplayNames(locale, { type: 'language' })
return languages
.map((code) => ({ code, name: names.of(code) ?? code }))
.map((code) => ({
code,
name: getChineseTranscriptLanguageName(code) ?? names.of(code) ?? code,
}))
.sort((a, b) => a.name.localeCompare(b.name, locale))
}, [languages, locale])
const [preferredLanguage, setPreferredLanguage] = useState<string>(locale)