mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-05 07:34:25 +00:00
feat(transcript): add Chinese script choices
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
|
||||
export function getChineseTranscriptLanguageName(code: string) {
|
||||
if (code === 'zh-Hans') return m.transcript_language_chinese_simplified()
|
||||
if (code === 'zh-Hant') return m.transcript_language_chinese_traditional()
|
||||
}
|
||||
|
||||
export function getTranscriptVideo(item: AssetInfo) {
|
||||
const isVideo = item.proxyType ? item.proxyType === 'video' : item.mediaType?.startsWith('video/')
|
||||
if (!isVideo) return undefined
|
||||
|
||||
@@ -1826,6 +1826,8 @@
|
||||
"failed_to_update_comment": "Failed to update comment",
|
||||
"generate_transcripts": "Generate Transcripts",
|
||||
"transcript_language_auto": "Auto",
|
||||
"transcript_language_chinese_simplified": "Chinese (Simplified)",
|
||||
"transcript_language_chinese_traditional": "Chinese (Traditional)",
|
||||
"transcript_generating": "Transcribing…",
|
||||
"transcript_no_speech": "No speech detected.",
|
||||
"transcript_submit_failed": "Could not start transcript generation.",
|
||||
|
||||
@@ -1756,6 +1756,8 @@
|
||||
"failed_to_update_comment": "댓글을 수정하지 못했습니다",
|
||||
"generate_transcripts": "전사 생성",
|
||||
"transcript_language_auto": "자동 감지",
|
||||
"transcript_language_chinese_simplified": "중국어(간체)",
|
||||
"transcript_language_chinese_traditional": "중국어(번체)",
|
||||
"transcript_generating": "전사 중…",
|
||||
"transcript_no_speech": "음성이 감지되지 않았습니다.",
|
||||
"transcript_submit_failed": "전사 생성을 시작할 수 없습니다.",
|
||||
|
||||
@@ -1826,6 +1826,8 @@
|
||||
"failed_to_update_comment": "更新评论失败",
|
||||
"generate_transcripts": "生成转录",
|
||||
"transcript_language_auto": "自动检测",
|
||||
"transcript_language_chinese_simplified": "中文(简体)",
|
||||
"transcript_language_chinese_traditional": "中文(繁体)",
|
||||
"transcript_generating": "正在转录…",
|
||||
"transcript_no_speech": "未检测到语音。",
|
||||
"transcript_submit_failed": "无法启动转录生成。",
|
||||
|
||||
Reference in New Issue
Block a user