feat: 翻译功能重构与沉浸式翻译初步实现#7
Merged
Merged
Conversation
added 21 commits
February 4, 2026 21:36
- Add showTranslationResult() to display translation based on translationMode setting - Inline mode: use TranslationOverlayController at OCR text positions - Below mode: use TranslationPopoverController as popover - Setting changes take effect immediately on next translation
- 在填充后的区域绘制译文 - 译文字体大小根据区域高度自动调整(10-32px) - 若译文较长,允许向右/下延伸超出原区域 - 实现内容感知填充:采样原文区域边缘像素作为填充色 - 根据背景亮度自动计算对比色(黑/白)确保可读性
主要变更: - 修复目标语言设置:从用户配置读取翻译目标语言,不再硬编码 - 修复 Apple Translation API 参数:正确设置 installedSource 和 target - 修复 PaddleOCR JSON 解析:正确处理 numpy array() 格式 - 新增 ImmersiveTranslationView:沉浸式翻译渲染组件 - 移除重复的翻译弹窗 - 重构预览窗口组件结构 技术细节: - TranslationEngine: 修正 TranslationSession 初始化参数 - PaddleOCREngine: 使用括号匹配算法解析 array() 内容 - ImmersiveTranslationView: 在原文下方显示译文,支持虚线装饰
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
技术细节
翻译引擎修复
TranslationEngine.swift: 修正TranslationSession初始化参数,installedSource设为源语言,target设为目标语言PreviewViewModel+OCR.swift: 从settings.translationTargetLanguage读取用户配置的目标语言PaddleOCR 解析修复
array([...], shape=..., dtype=...)格式沉浸式翻译组件
ImmersiveTranslationView.swift: 在原文下方显示译文后续计划
完整的沉浸式翻译效果需要进一步实现:
测试