Skip to content

feat(eudict): add "Save to Vocabulary with Note" feature#570

Merged
ZGGSONG merged 2 commits intoSTranslate:mainfrom
chuichuihan:feat/vocabulary-save-with-note
Jan 13, 2026
Merged

feat(eudict): add "Save to Vocabulary with Note" feature#570
ZGGSONG merged 2 commits intoSTranslate:mainfrom
chuichuihan:feat/vocabulary-save-with-note

Conversation

@chuichuihan
Copy link
Contributor

结合欧陆官方提供的笔记api配合生词本api实现添加生词时,同步添加翻译内容作为笔记

  • Add new button in translation result area to save word with note
  • Translation result is automatically added as note to the vocabulary
  • Extend IVocabularyPlugin interface with SaveWithNoteAsync method
  • Support token validation and cancellation

- Add new button in translation result area to save word with note
- Translation result is automatically added as note to the vocabulary
- Extend IVocabularyPlugin interface with SaveWithNoteAsync method
- Support token validation and cancellation
Task<VocabularyResult> SaveWithNoteAsync(string word, string note, CancellationToken cancellationToken = default)
{
return SaveAsync(word, cancellationToken);
}
Copy link
Collaborator

@ZGGSONG ZGGSONG Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修改插件底层接口需要明确是否所有插件的实现都拥有该功能

比如另外一个生词本插件 Maimemo 以及其他可以接入的生词本服务都有嘛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢审阅!我看了一下 Maimemo 插件源码,确认兼容性没有问题。SaveWithNoteAsync 使用了 C# 接口默认实现,会自动回退到 SaveAsync。但是我个人不用墨墨,就没有进行实际测试了
结论:

  • Maimemo 等不支持笔记的插件无需任何修改,调用时会自动只保存单词,忽略笔记参数
  • 支持笔记的插件可以选择性覆盖实现

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我的意思是如果所有的插件都有 那就不要该底层的接口定义,实现时就直接按 SaveWithNoteAsync 这个来实现

并且不同用户需求不同,建议做成可选项,配制里开启 开启后再保存到笔记 而不是另起一个接口再写实现

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

并不是所有插件都有,这取决于插件调用的平台api是否开放"笔记"的修改接口

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

所以说嘛 src/STranslate.Plugin/IVocabularyPlugin.cs 轻易不动他

因为如果别人有插件实现,这个定义变了,人家的插件不更新实现这个接口,就打不开了
我还是推荐按如下提示方式修改后 我再合并吧😀

建议做成可选项,配制里开启 开启后再保存到笔记 而不是另起一个接口再写实现

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我们对齐一下方案,现在如果不动src/STranslate.Plugin/IVocabularyPlugin.cs我有以下两个方案:

  1. 新增一个可选接口:IVocabularyNoteSupport,来实现SaveWithNoteAsync功能,在插件中使用配置按钮控制是否开启笔记功能
    2.扩展IPluginContext,接口中添加 TranslationContext 属性用来获取翻译结果,插件按钮控制开关

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你认为那个方案比较好或者有什么更好的方案可以告诉我

@ZGGSONG
Copy link
Collaborator

ZGGSONG commented Dec 31, 2025

刚开始没太看明白这个功能的逻辑,debug了一下看出来区别了,如果要实现始终是需要对底层接口定义做修改的

不过我在考虑一件事,因为生词在web端是有释义,如果上传note里面加翻译结果不是重复了么,而且web端似乎看不到这个note里的信息

图片

刚好咨询一下用生词本保存单词和下一步的使用场景具体是什么样的,这个功能只是大家要我就做了 我从来没用过

@chuichuihan
Copy link
Contributor Author

1.我使用这个功能是配合了openai插件,因为有很多单词他在特殊场景有特殊含义,很可能此含义在各种词典中没有或者并非高频释义(此情况多出现在专业化的场景中,比如编程/金融/医科类场景),此时常用的词典翻译就显得很匮乏了,反而是ai翻译可以准确的翻译出他的含义,只需要你写好提示词即可。
举个例子:
override在词典中有以下含义:不顾,不理,优先于,压倒,但是在编码中最常用含义是:重写。此时如果你保存单独单词到单词本,看到含义很可能会很懵逼,但是如果你用openai插件进行翻译,在提示词中给出翻译背景是编码,那么肯定会给出此含义,这时可以将ai的翻译一同报错,后续在笔记本中一看便知
2.我不知道别人是怎么用的,我一般是拿来背诵,各个平台都有将生词本设置为背诵书源的功能,搭配ai来快速学习特定领域单词含义,作为普通词本的补充
3.不会重复,你现在这个界面他没有展示笔记内容,在app端可以直接看到,还可以设置显示优先级,让笔记显示在词典释义之前

@ZGGSONG
Copy link
Collaborator

ZGGSONG commented Dec 31, 2025

在app端可以直接看到,还可以设置显示优先级,让笔记显示在词典释义之前

好的

@ZGGSONG
Copy link
Collaborator

ZGGSONG commented Dec 31, 2025

那我可能要考虑一下生词本的设计问题了 入口不同了 交互逻辑不同了

你这个我先不合并 下个版本再带上 先看怎么设计交互会简单些

@chuichuihan
Copy link
Contributor Author

👌

@ZGGSONG ZGGSONG merged commit 48063e4 into STranslate:main Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants