-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(translate): brand new translate feature #8513
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
Open
EurFelux
wants to merge
106
commits into
CherryHQ:main
Choose a base branch
from
EurFelux:refactor/translate-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+2,514
−863
Conversation
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
4 tasks
添加防抖函数来优化文本输入和键盘事件的处理,减少不必要的状态更新和翻译请求
重构翻译页面,将输入区域相关逻辑和UI抽离到单独的InputArea组件中 优化代码结构,提高可维护性 buggy: waiting for merge
将翻译设置功能提取为独立组件,减少主页面代码复杂度
This was
linked to
issues
Jul 30, 2025
统一操作栏的padding样式,将输入和输出区域的容器样式分离以提高可维护性
添加源语言与目标语言交换功能按钮 为AWS Bedrock添加i18n
在翻译提示中添加说明,要求翻译时去除文本中的"[to be translated]"前缀
添加虚拟列表组件并应用于翻译历史页面,优化长列表渲染性能
将模型选择器从翻译设置移动到翻译页面主界面,优化模型选择流程
- 新增 CustomTranslateLanguage 类型定义 - 在数据库中增加 translate_languages 表和相关 CRUD 操作 - 实现自定义语言的添加、删除、更新和查询功能
添加翻译设置页面,包含自定义语言表格、添加/编辑模态框、翻译模型选择和提示词配置
添加自定义语言表格组件及模态框,支持增删改查操作 修复数据库字段命名不一致问题,将langcode改为langCode 新增内置语言代码列表用于校验 添加多语言支持及错误提示
新增getTranslateOptions函数,用于合并内置翻译语言和自定义语言选项。当获取自定义语言失败时,自动回退到只返回内置语言选项。
- 将翻译语言选项管理集中到useTranslate钩子中 - 修改LanguageCode类型为string以支持自定义语言 - 废弃旧的getLanguageByLangcode方法,提供新的实现 - 统一各组件对翻译语言选项的获取方式 - 优化类型定义,移除冗余类型TranslateLanguageVarious
build check 没过 |
alephpiece
reviewed
Aug 3, 2025
Comment on lines
24
to
29
<Space.Compact direction="horizontal" block> | ||
<span role="img" aria-label={lang.emoji} style={{ marginRight: 8 }}> | ||
{lang.emoji} | ||
</span> | ||
<Space.Compact block>{lang.label()}</Space.Compact> | ||
</Space.Compact> |
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.
这里是不是只要最外面的 Space.Compact 就行了?
自定义语言对不齐可能是在我这 emoji 宽度和 flag 不一样
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.
检查一下,看有没有必要给emoji容器锁定一个长宽?
将输入输出区域整合为统一容器,调整操作栏宽度和间距 移动设置和历史按钮到输出操作栏,简化布局结构
将硬编码的窗口最小宽度和高度值替换为从共享配置导入的常量,提高代码可维护性
将操作栏从三个独立部分改为网格布局,使用InnerOperationBar组件统一样式 移除冗余的operationBarWidth变量,简化样式代码
移除自定义的CopyButton组件,直接使用Ant Design的原生Button组件来实现复制功能,保持UI一致性并减少冗余代码
将操作按钮从左侧移动到右侧,并移除不必要的HStack组件 调整翻译按钮位置并保留其工具提示功能
为源语言和目标语言选择器添加统一的宽度样式,保持UI一致性
添加 Windows_GetSize IPC 通道用于获取窗口当前尺寸 添加 Windows_Resize IPC 通道用于监听窗口大小变化 新增 useWindowSize hook 方便在渲染进程中使用窗口尺寸
使用debounce优化窗口大小变化的处理,避免频繁触发更新 为翻译页面添加响应式布局,根据窗口宽度和导航栏位置动态调整模型选择器宽度
在窗口最大化或还原时发送尺寸变化事件,以便界面可以响应这些状态变化
为翻译配置添加对'zh-yue'语言代码的处理,返回对应的'Cantonese'值
当编辑已存在的自定义语言时,如果输入的语言代码已存在且与原代码不同,则抛出错误提示
all done |
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.
What this PR does
Before
目前整个翻译页面的内容全部塞在一个tsx里面,任何状态改变都会导致整个页面重渲染,非常非常重,计划重构一下。
另外发现翻译历史列表没有使用虚拟化技术,同时因为输入文本会频繁触发重渲染,导致翻译历史多起来时非常卡顿,这部分也计划优化一下。
After
LanguageSelect
通用的翻译语言语言选择组件useWindowSize
可获取实时主窗口尺寸用于复杂的样式控制fetchTranslate
无法捕获流式Error导致静默错误2025-08-04.00-10-25.mov
Fixes #
Why we need it and why it was done in this way
The following tradeoffs were made:
The following alternatives were considered:
Links to places where the discussion took place:
Breaking changes
If this PR introduces breaking changes, please describe the changes and the impact on users.
Special notes for your reviewer
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.
Release note