Files
kiss-translator/README.md

198 lines
6.9 KiB
Markdown
Raw Normal View History

2023-09-02 17:22:35 +08:00
# 简约翻译
2023-07-18 15:23:16 +08:00
2024-04-21 22:21:29 +08:00
[English](README.en.md) | 简体中文
2023-11-17 11:38:42 +08:00
一个简约、开源的 [双语对照翻译扩展 & 油猴脚本](https://github.com/fishjar/kiss-translator)。
2023-07-18 15:23:16 +08:00
2023-07-18 15:26:46 +08:00
[kiss-translator.webm](https://github.com/fishjar/kiss-translator/assets/1157624/f7ba8a5c-e4a8-4d5a-823a-5c5c67a0a47f)
2023-09-16 20:11:10 +08:00
## 特性
2023-07-18 15:23:16 +08:00
2023-09-21 16:41:49 +08:00
- [x] 保持简约
2023-09-11 13:37:19 +08:00
- [x] 开放源代码
- [x] 适配常见浏览器
2025-08-10 20:12:12 +08:00
- [x] Chrome/Edge
- [x] Firefox
- [x] Kiwi (Android)
- [x] Orion (iOS)
2023-09-11 13:37:19 +08:00
- [ ] Safari
2025-08-10 22:01:50 +08:00
- [x] Safari (Mac)
2025-08-09 11:41:24 +08:00
- [x] Thunderbird
2023-09-11 13:37:19 +08:00
- [x] 支持多种翻译服务
2025-08-10 20:12:12 +08:00
- [x] Google/Microsoft
- [x] Baidu/Tencent/Volcengine
- [x] OpenAI/Gemini/Claude/Ollama/DeepSeek/CloudflareAI
- [x] DeepL/DeepLX/NiuTrans
2023-09-11 13:37:19 +08:00
- [x] 自定义翻译接口
2023-09-16 21:16:04 +08:00
- [x] 覆盖常见翻译场景
2023-10-13 10:20:14 +08:00
- [x] 网页双语对照翻译
2023-09-16 20:11:10 +08:00
- [x] 输入框翻译
2023-10-25 13:36:46 +08:00
- [x] 划词翻译
2023-10-27 00:11:44 +08:00
- [x] 收藏词汇
2023-09-16 20:11:10 +08:00
- [x] 鼠标悬停翻译
- [x] YouTube 字幕翻译
- [x] 跨客户端数据同步
2023-09-21 16:41:49 +08:00
- [x] KISS-Workercloudflare/docker
- [x] WebDAV
2023-09-16 20:11:10 +08:00
- [x] 自定义翻译规则
- [x] 规则订阅/规则分享
2024-01-19 16:02:53 +08:00
- [x] 自定义专业术语
2023-09-16 20:11:10 +08:00
- [x] 自定义译文样式
2023-09-11 13:42:44 +08:00
- [x] 自定义快捷键
2024-02-22 22:57:34 +08:00
- `Alt+Q` 开启翻译
2023-09-11 13:37:19 +08:00
- `Alt+C` 切换样式
2023-10-25 13:36:46 +08:00
- `Alt+K` 打开设置弹窗
2023-11-28 15:15:02 +08:00
- `Alt+S` 打开翻译弹窗/翻译选中文字
2023-10-25 13:36:46 +08:00
- `Alt+O` 打开设置页面
2023-09-15 22:03:50 +08:00
- `Alt+I` 输入框翻译
2023-09-11 13:37:19 +08:00
2023-09-16 21:16:04 +08:00
## 安装
2023-09-11 13:37:19 +08:00
2023-09-21 16:41:49 +08:00
> 注:基于以下原因,建议优先使用浏览器扩展
>
2023-11-22 15:04:52 +08:00
> - 浏览器扩展的功能更完整(本地语言识别、右键菜单等)
2023-11-22 12:27:38 +08:00
> - 油猴脚本会遇到更多使用上的问题(跨域问题、脚本冲突等)
2023-09-21 16:41:49 +08:00
2023-09-11 13:37:19 +08:00
- [x] 浏览器扩展
2024-03-26 17:50:56 +08:00
- [x] Chrome [安装地址](https://chrome.google.com/webstore/detail/kiss-translator/bdiifdefkgmcblbcghdlonllpjhhjgof?hl=zh-CN)
- [x] Kiwi (Android)
- [x] Orion (iOS)
2023-09-11 13:37:19 +08:00
- [x] Edge [安装地址](https://microsoftedge.microsoft.com/addons/detail/%E7%AE%80%E7%BA%A6%E7%BF%BB%E8%AF%91/jemckldkclkinpjighnoilpbldbdmmlh?hl=zh-CN)
- [x] Firefox [安装地址](https://addons.mozilla.org/zh-CN/firefox/addon/kiss-translator/)
- [ ] Safari
2025-08-10 22:01:50 +08:00
- [x] Safari (Mac) 第三方编译,未作验证,自行获取: https://www.nodeloc.com/t/topic/54245
2025-08-09 11:41:24 +08:00
- [x] Thunderbird [下载地址](https://github.com/fishjar/kiss-translator/releases)
2023-09-11 13:37:19 +08:00
- [x] 油猴脚本
2023-11-14 10:50:48 +08:00
- [x] Chrome/Edge/Firefox ([Tampermonkey](https://www.tampermonkey.net/)/[Violentmonkey](https://violentmonkey.github.io/)) [安装链接](https://fishjar.github.io/kiss-translator/kiss-translator.user.js)
2024-03-26 17:50:56 +08:00
- [Greasy Fork](https://greasyfork.org/zh-CN/scripts/472840-kiss-translator)
2023-11-14 10:50:48 +08:00
- [x] iOS Safari ([Userscripts Safari](https://github.com/quoid/userscripts)) [安装链接](https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js)
2023-07-18 15:23:16 +08:00
2023-09-04 23:08:00 +08:00
## 关联项目
- 数据同步服务: [https://github.com/fishjar/kiss-worker](https://github.com/fishjar/kiss-worker)
- 可用于本项目的数据同步服务。
2023-09-05 13:35:12 +08:00
- 亦可用于分享个人的私有规则列表。
2023-09-04 23:08:00 +08:00
- 自己部署,自己管理,数据私有。
- 社区订阅规则: [https://github.com/fishjar/kiss-rules](https://github.com/fishjar/kiss-rules)
- 提供社区维护的,最新最全的订阅规则列表。
- 求助规则相关的问题。
- 翻译接口代理: [https://github.com/fishjar/kiss-proxy](https://github.com/fishjar/kiss-proxy)
2023-11-22 15:08:26 +08:00
- 如果访问某个翻译接口遇到网络问题,这个代理服务也许可以帮到你。
2023-09-04 23:08:00 +08:00
- 自己部署,自己管理。
2025-08-09 11:41:24 +08:00
## 常见问题
2025-08-10 12:48:40 +08:00
### 如何关闭自动翻译
通过规则设置,以下方法均可实现:
- 个人规则:全局规则 -> 开启翻译 -> 默认关闭
- 订阅规则:选择第三个 `kiss-rules-off.json`
- 覆写订阅规则:开启翻译 -> 默认关闭
- 添加一条针对某个网站的个人规则:开启翻译 -> 默认关闭
### 如何设置快捷键
在插件管理那里设置,例如:
- chrome [chrome://extensions/shortcuts](chrome://extensions/shortcuts)
2025-08-10 17:37:15 +08:00
- firefox [about:addons](about:addons)
2025-08-10 12:48:40 +08:00
### 如何关闭划词翻译
通过规则设置:个人规则 -> 全局规则 -> 是否启用划词翻译 -> 禁用
### 如何设置仅显示译文
通过规则设置:个人规则 -> 全局规则 -> 仅显示译文 -> 启用
### 如何设置鼠标悬停翻译
通过规则设置:个人规则 -> 全局规则 -> 触发方式
2025-08-09 11:41:24 +08:00
### 为什么有些网页翻译不全
2025-08-10 12:48:40 +08:00
本插件的网页翻译是基于CSS选择器的通用规则不能适配所有网页有时需要自行添加相应网站的单独规则。如果不会写规则可以到这里求助 https://github.com/fishjar/kiss-rules/issues
2025-08-09 11:41:24 +08:00
### 规则设置的优先级是如何的
个人规则 > 覆写订阅规则 > 订阅规则 > 全局规则
2025-08-10 12:48:40 +08:00
其中全局规则优先级最低,但非常重要,相当于默认规则。
2025-08-09 11:41:24 +08:00
### 为什么油管字幕一句话会断开翻译
2025-08-10 12:48:40 +08:00
本插件目前没有针对视频做特殊开发,对油管的支持也是当做网页翻译看待,自动生成字幕是流式生成并输出的,所以支持较差。
如果需要关闭本插件的字幕翻译增加一条规则即可参考https://github.com/fishjar/kiss-translator/issues/62
2025-08-09 11:41:24 +08:00
### 本地的Ollama接口不能使用
2025-08-10 12:48:40 +08:00
如果出现403的情况参考https://github.com/fishjar/kiss-translator/issues/174
2025-08-09 11:41:24 +08:00
### 填写的接口在油猴脚本不能使用
2025-08-10 12:48:40 +08:00
油猴脚本需要增加域名白名单,否则不能发出请求。
2023-09-04 23:08:00 +08:00
2025-08-10 21:40:58 +08:00
### 如何设置自定义接口的hook函数
自定义接口功能非常灵活,理论可以接入任何翻译接口。
Request Hook 函数示例如下:
```js
/**
* Request Hook
* @param {string} text 需要翻译的原文
* @param {string} from 原文语言
* @param {string} to 译文语言
* @param {string} url 翻译接口地址
* @param {string} key 翻译接口密钥
* @returns {Array[string, object]} [接口地址, 请求参数对象]
*/
(text, from, to, url, key) => [url, {
headers: {
"Content-type": "application/json",
"Authorization": `Bearer ${key}`
},
method: "POST",
body: { text, to },
}]
```
Response Hook 函数示例如下:
```js
/**
* Request Hook
* @param {string} res 接口返回的json数据
* @param {string} text 需要翻译的原文
* @param {string} from 原文语言
* @param {string} to 译文语言
* @returns {Array[string, boolean]} [译文, 译文语言与原文语言是否相同]
2025-08-10 21:50:33 +08:00
*如果返回值第二个值为true译文语言与原文语言相同则译文不会在页面显示
* 参数不全的情况建议直接返回false
2025-08-10 21:40:58 +08:00
*/
(res, text, from, to) => [res.text, to === res.src]
```
2025-08-10 21:54:24 +08:00
更多的自定义接口示例,请参考: [custom-api.md](https://github.com/fishjar/kiss-translator/blob/master/custom-api.md)
2025-08-10 21:40:58 +08:00
2023-09-11 13:37:19 +08:00
## 开发指引
2023-07-20 13:51:53 +08:00
```sh
git clone https://github.com/fishjar/kiss-translator.git
cd kiss-translator
2025-08-09 21:06:18 +08:00
git checkout dev # 提交PR建议推送到dev分支
2023-09-21 10:15:03 +08:00
pnpm install
pnpm build
2023-07-20 13:51:53 +08:00
```
2023-07-31 15:08:51 +08:00
2023-09-02 17:22:35 +08:00
## 交流
2023-08-03 10:43:41 +08:00
- 加入 [Telegram 群](https://t.me/+RRCu_4oNwrM2NmFl)
2024-01-03 15:25:40 +08:00
## 赞赏
2024-01-03 15:47:24 +08:00
![appreciate](https://github.com/fishjar/kiss-translator/assets/1157624/ebaecabe-2934-4172-8085-af236f5ee399)