-
Notifications
You must be signed in to change notification settings - Fork 2
feat(player): add subtitle search functionality #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,20 +85,6 @@ | |
| "tooltip": "透明背景" | ||
| } | ||
| }, | ||
| "mask-mode": { | ||
| "background-locked": { | ||
| "tooltip": "遮罩模式下背景样式固定为高斯模糊" | ||
| }, | ||
| "disable": { | ||
| "tooltip": "关闭遮罩模式" | ||
| }, | ||
| "enable": { | ||
| "tooltip": "开启遮罩模式,锁定内嵌字幕区域" | ||
| }, | ||
| "label": "遮罩模式", | ||
| "onboarding": "拖动或调整字幕框以匹配视频中的内嵌字幕区域", | ||
| "title": "遮罩模式" | ||
| }, | ||
| "display-mode": { | ||
| "bilingual": { | ||
| "label": "双语", | ||
|
|
@@ -117,9 +103,30 @@ | |
| "label": "译文", | ||
| "tooltip": "仅显示译文字幕 (Ctrl+3)" | ||
| } | ||
| }, | ||
| "mask-mode": { | ||
| "background-locked": { | ||
| "tooltip": "遮罩模式下背景样式固定为高斯模糊" | ||
| }, | ||
| "disable": { | ||
| "tooltip": "关闭遮罩模式" | ||
| }, | ||
| "enable": { | ||
| "tooltip": "开启遮罩模式,锁定内嵌字幕区域" | ||
| }, | ||
| "label": "遮罩模式", | ||
| "onboarding": "拖动或调整字幕框以匹配视频中的内嵌字幕区域", | ||
| "title": "遮罩模式" | ||
| } | ||
| } | ||
| }, | ||
| "dictionary": { | ||
| "error": "查询失败", | ||
| "loading": "查询中...", | ||
| "more_definitions": "... 还有 {{count}} 个释义", | ||
| "pronunciation": "点击发音", | ||
| "translations": "常用翻译" | ||
| }, | ||
|
Comment on lines
+123
to
+129
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain“dictionary” 放于 player 命名空间;核对各处引用是否一致 若组件期望根级 dictionary.* 将导致缺失;请统一为 player.dictionary.* 或调整代码。 可用脚本核对所有引用与各语言包是否存在相同路径: 🏁 Script executed: #!/bin/bash
echo "代码引用:"
rg -n -C2 "t\\(['\"]player\\.dictionary\\." src || true
echo "Locale 存在性:"
fd -a -g "src/renderer/src/i18n/locales/*.json" | xargs -I{} rg -n "player\"\\s*:\\s*\\{[^}]*\"dictionary\"" -n {}Length of output: 1654 本地化键与代码使用不一致: 代码中使用了 🤖 Prompt for AI Agents |
||
| "errorRecovery": { | ||
| "actions": { | ||
| "backToHome": "返回首页", | ||
|
|
@@ -179,39 +186,49 @@ | |
| "label": "文件路径" | ||
| } | ||
| }, | ||
| "subtitles": { | ||
| "hide": "隐藏字幕列表", | ||
| "show": "展开字幕列表" | ||
| }, | ||
| "mediaServerPrompt": { | ||
| "title": "视频格式不兼容", | ||
| "subtitle": "检测到当前视频格式不受支持", | ||
| "actions": { | ||
| "install": "立即安装", | ||
| "later": "稍后再说" | ||
| }, | ||
| "benefits": { | ||
| "title": "安装 Media Server 可以解决此问题", | ||
| "compatibility": { | ||
| "title": "完美兼容", | ||
| "description": "支持所有常见视频格式,包括高清和蓝光视频" | ||
| }, | ||
| "transcoding": { | ||
| "title": "实时转码", | ||
| "description": "后台自动转码,无需等待,即开即用" | ||
| "description": "支持所有常见视频格式,包括高清和蓝光视频", | ||
| "title": "完美兼容" | ||
| }, | ||
| "easySetup": { | ||
| "title": "一键安装", | ||
| "description": "自动化安装流程,无需手动配置" | ||
| "description": "自动化安装流程,无需手动配置", | ||
| "title": "一键安装" | ||
| }, | ||
| "title": "安装 Media Server 可以解决此问题", | ||
| "transcoding": { | ||
| "description": "后台自动转码,无需等待,即开即用", | ||
| "title": "实时转码" | ||
| } | ||
| }, | ||
| "actions": { | ||
| "install": "立即安装", | ||
| "later": "稍后再说" | ||
| } | ||
| "subtitle": "检测到当前视频格式不受支持", | ||
| "title": "视频格式不兼容" | ||
| }, | ||
| "dictionary": { | ||
| "loading": "查询中...", | ||
| "error": "查询失败", | ||
| "pronunciation": "点击发音", | ||
| "more_definitions": "... 还有 {{count}} 个释义", | ||
| "translations": "常用翻译" | ||
| "subtitles": { | ||
| "hide": "隐藏字幕列表", | ||
| "search": "搜索字幕", | ||
| "show": "展开字幕列表" | ||
| }, | ||
| "subtitleList": { | ||
| "empty": { | ||
| "title": "在视频文件同目录下未找到匹配的字幕文件", | ||
| "description": "您可以点击下方按钮选择字幕文件,或将字幕文件拖拽到此区域" | ||
| }, | ||
| "search": { | ||
| "placeholder": "搜索字幕...", | ||
| "pending": "搜索中...", | ||
| "count": "找到 {{count}} 条字幕", | ||
| "count_one": "找到 {{count}} 条字幕", | ||
| "count_other": "找到 {{count}} 条字幕", | ||
| "none": "未找到匹配的字幕", | ||
| "emptyTitle": "未找到匹配结果", | ||
| "emptySubtitle": "请尝试其他关键词" | ||
| } | ||
|
Comment on lines
+217
to
+231
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial subtitleList 搜索文案完备;可精简多余复数键(可选) 中文不需要复数变体,保留 count_other 足够;count 与 count_one 可视为冗余(不必改也无害)。 🤖 Prompt for AI Agents |
||
| } | ||
| }, | ||
| "search": { | ||
|
|
@@ -415,11 +432,11 @@ | |
| }, | ||
| "description": "FFprobe 用于读取音视频元数据和流信息,帮助 EchoPlayer 验证文件状态并完成兼容性检测。", | ||
| "download": { | ||
| "install": "安装", | ||
| "cancel": "取消下载", | ||
| "cancelled": "下载已取消", | ||
| "downloading": "下载中", | ||
| "failed": "下载失败,请重试", | ||
| "install": "安装", | ||
| "success": "下载完成" | ||
| }, | ||
| "path": { | ||
|
|
@@ -489,12 +506,12 @@ | |
| "show_settings": "打开设置", | ||
| "single_loop": "循环播放", | ||
| "title": "快捷键", | ||
| "toggle_auto_pause": "切换自动暂停", | ||
| "toggle_fullscreen": "切换全屏", | ||
| "toggle_new_context": "清除上下文", | ||
| "toggle_show_assistants": "切换助手显示", | ||
| "toggle_show_topics": "切换话题显示", | ||
| "toggle_subtitle_panel": "切换字幕面板", | ||
| "toggle_auto_pause": "切换自动暂停", | ||
| "volume_down": "减小音量", | ||
| "volume_up": "增大音量", | ||
| "zoom_in": "放大界面", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { PlayerSettingsService } from '@renderer/services/PlayerSettingsLoader' | |
| import { playerSettingsPersistenceService } from '@renderer/services/PlayerSettingsSaver' | ||
| import { usePlayerStore } from '@renderer/state' | ||
| import { usePlayerSessionStore } from '@renderer/state/stores/player-session.store' | ||
| import { usePlayerUIStore } from '@renderer/state/stores/player-ui.store' | ||
| import { IpcChannel } from '@shared/IpcChannel' | ||
| import { Layout, Tooltip } from 'antd' | ||
|
|
||
|
|
@@ -24,7 +25,7 @@ import { | |
| FONT_SIZES, | ||
| SPACING | ||
| } from '@renderer/infrastructure/styles/theme' | ||
| import { ArrowLeft, PanelRightClose, PanelRightOpen } from 'lucide-react' | ||
| import { ArrowLeft, PanelRightClose, PanelRightOpen, Search } from 'lucide-react' | ||
| import { useCallback, useEffect, useMemo, useRef, useState } from 'react' | ||
| import { useTranslation } from 'react-i18next' | ||
| import { useNavigate, useParams } from 'react-router-dom' | ||
|
|
@@ -93,6 +94,7 @@ function PlayerPage() { | |
|
|
||
| const { t } = useTranslation() | ||
| const { subtitlePanelVisible, toggleSubtitlePanel } = usePlayerStore() | ||
| const toggleSubtitleSearch = usePlayerUIStore((s) => s.toggleSubtitleSearch) | ||
|
|
||
| const [videoData, setVideoData] = useState<VideoData | null>(null) | ||
| const [loading, setLoading] = useState(true) | ||
|
|
@@ -600,8 +602,14 @@ function PlayerPage() { | |
| <NavTitle title={videoData.title}>{videoData.title}</NavTitle> | ||
| </NavbarCenter> | ||
| <NavbarRight> | ||
| <Tooltip title={t('player.subtitles.search')} mouseEnterDelay={0.8}> | ||
| <NavbarIcon onClick={toggleSubtitleSearch}> | ||
| <Search size={18} /> | ||
| </NavbarIcon> | ||
| </Tooltip> | ||
|
Comment on lines
+605
to
+609
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain驗證 i18n 鍵是否存在。 第 605 行引用了翻譯鍵 運行以下腳本驗證翻譯鍵的使用: 🏁 Script executed: #!/bin/bash
# 描述:在本地化文件中搜索 player.subtitles.search 鍵
# 預期:找到該鍵的定義或確認應使用其他鍵
# 搜索 player.subtitles.search
echo "=== 搜索 player.subtitles.search ==="
rg -n "subtitles.*search" src/renderer/src/i18n/locales/
# 搜索所有 player.subtitle 相關的鍵
echo "=== 搜索所有 player 下的 subtitle 相關鍵 ==="
rg -n '"subtitle' src/renderer/src/i18n/locales/ -A 2Length of output: 3807 确保 i18n 键 'player.subtitles.search' 在所有本地化文件中定义 🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @codex adress that feedback
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Summary
Testing
|
||
| <Tooltip | ||
| title={subtitlePanelVisible ? t('player.subtitles.hide') : t('player.subtitles.show')} | ||
| mouseEnterDelay={0.8} | ||
| > | ||
| <NavbarIcon onClick={toggleSubtitlePanel}> | ||
| {subtitlePanelVisible ? ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
复数形式基本正确;建议补齐字幕面板按钮文案(跨语言一致性)
建议在本文件补齐如下键值:
"player": { + "subtitles": { + "hide": "Скрыть список субтитров", + "search": "Поиск субтитров", + "show": "Показать список субтитров" + }, "subtitleList": {请确认代码调用路径为 t('player.subtitleList.search.count', { count }),以使用 i18next 复数推断。若需要,我可批量为所有语言包补齐缺失键并提交补丁。
正在验证 ru-ru.json 是否包含 player.subtitles 键,并检查代码中是否使用 t('player.subtitleList.search.count', { count }) 调用。
🏁 Script executed:
Length of output: 645
🏁 Script executed:
Length of output: 557
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 183
添加播放器字幕面板按钮翻译键
ru-ru.json 和 zh-cn.json 均缺少 player.subtitles.hide、search、show 三个键,需补充以保持跨语言一致性并避免回退默认语言。
建议在各自语言包的 player 节点下添加:
"player": { + "subtitles": { + "hide": "Скрыть список субтитров", // 隐藏字幕列表 + "search": "Поиск субтитров", // 搜索字幕 + "show": "Показать список субтитров" // 显示字幕列表 + }, "subtitleList": { …📝 Committable suggestion
🤖 Prompt for AI Agents