zotero-pdf-translate README

The project's README from github.com/windingwind/zotero-pdf-translate. As one markdown file: README.md.

Translate for ZoteroTranslate for Zotero

zotero target version Using Zotero Plugin Template

Translate for Zotero, a.k.a. Zotero PDF Translate, is a Zotero plugin.
Translate PDF, EPub, webpage, metadata, annotations, notes to the target language. Support 20+ translate services.

中文文档

Quick Start Guide

Install

Usage

Open any PDF/EPub/webpage in the Zotero reader.

Q&A

Q I want to translate manually.
A Go to Edit->Settings->Translate->General, uncheck the Automatically Translate Selection. Click the Translate button on the pop-up or item pane to translate.

Q I want a translate shortcut.
A Press shortcut Ctrl+T after you selected some text. If you are in the collection view, the titles' translation will show/hide.

Q I want to concat different selections and translate them together.
A Press Ctrl/⌘ or select the Concat Mode check box on item pane when selecting text in PDF/EPub/webpage.

Q Not the language I want.
A The default target language is the same as your Zotero language. Go to Edit->Settings->Translate->Service and change the language settings.

Q Translation not correct or report an error.
A See Language Settings above and FAQ(#6). Make sure you use the right secret.

Q I want to change the font size.
A Go to Edit->Settings->Translate->User Interface and set the font size.

Q I want to resize the raw and result text area in the translate panel.
A Drag the separator up and down to adjust the size. Double-click the separator to reset the size.

Settings

General

Service

The default service is Google Translate. Currently, we support:

Translate Service Require Secret Supported Languages
Google Translate No [Free] 100+
Google Translate(API) No [Free] Use translate.googleapis.com
CNKI No [Free] https://dict.cnki.net
Haici Translate No [Free] https://fanyi.dict.cn
Youdao Translate No [Free] 100+?
iCIBA Translate No [Free] https://www.iciba.com/translate
MyMemory No [Free 5k/day per IP] https://mymemory.translated.net/
(Free upgrade: enter your email in Settings to get 50k/day per IP quota)
Bing No [Free] en-zh
DeepLX No [Free] Based on DeepLX
DeepLX(API) No [Require config] DeepLX related projects
LibreTranslate Optional [Require config] LibreTranslate
MTranServer Optional [Require config] MTranServer
NLLB No [Require config] nllb-api or NLLB Serve
Pot No [Require config] Pot Translate results show in Pot
Huoshan Yes 50+
Volcengine Web No [Free] en, zh, and more (auto-detect, web version)
Youdao Zhiyun Yes 100+
Youdao LLM Yes LLM-based(en-zh)
Niu Trans Yes 400+
Microsoft Translate Yes(free 2M) 200+
LingoCloud(Caiyun) Translate Yes 10+
DeepL Translate Yes(free 500k) 100+
Aliyun Translate Yes(free-1M) 200+
Baidu Translate Yes(free-QPS1/free-2M) 200+
Baidu Field Yes(free-QPS1/free-2M) en-zh
OpenL Yes 11
Tencent Translate Yes(QPS5, free-5M) 15
Tencent Transmart No [Free] en, zh, and more (auto-detect, web version)
Xftrans Yes(free 2M) Xftrans API(70+), NiuTrans API(100+)
GPT Yes(free-$18) OpenAI(ChatGPT), AzureGPT, compatible GPT-like LLM (Custom GPT)
Gemini Yes(free-) LLM-based
Qwen-MT Yes(free-) LLM-based
Claude Yes LLM-based

If the service you want is not yet supported, please post an issue.

Google
Google does not require a secret, but you can put your own API URL in the secret to replace the default URL (translate.google.com/translate.googleapi.com).

Huoshan
Apply here.
The secret format is accessKeyId#accessKeySecret

Youdao Zhiyun Translate 有道智云
Apply here.
The secret format is MY_APPID#MY_SECRET#MY_VOCABID(optional).

About VOCABID
登录控制台,选择文本翻译服务,点击右侧的术语表,选择新建,填写表名称和语言方向,添加需要的术语表,然后获取对应词表 id 即可。
About Config -> Domain
登录控制台,点击创建应用,输入应用名称,在选择服务一栏勾选文本翻译,然后勾选领域化翻译即可开通领域化翻译。领域化翻译仅支持中英互译。

Official Document

Youdao LLM Translate 有道智云子曰大模型
Apply here.
The secret format is MY_APPID#MY_SECRET.

登录控制台,点击创建应用,输入应用名称,在选择服务一栏勾选大模型翻译,大模型翻译仅支持中英互译。

Official Document

NiuTrans
Apply here.
The secret format is MY_APIKEY#dictNo(optional)#memoryNo(optional).

Chinese Document

Microsoft Translate
Apply here. Copy your secret and paste it into the settings.
The secret format is serviceKEY#region(required if the region is not global).

See this issue for detailed steps to set up the Microsoft Translate.

LingoCloud(Caiyun) Translate
Apply here.

DeepL Translate
Apply official API or third-party API.
The secret format is secretToken or secretToken#glossaryId (if you want to specify some translate glossary).

Aliyun Translate
Apply here.
The secret format is accessKeyId#accessKeySecret#endpoint(optional).

The endpoint is the region of the service, default https://mt.aliyuncs.com. For cn-hangzhou, the endpoint is mt.cn-hangzhou.aliyuncs.com. See also here.

Chinese Document

Baidu Translate
Apply here.
The secret format is MY_APPID#MY_KEY#ACTION(optional, see https://api.fanyi.baidu.com/doc/21, default 0)(split with '#').

Baidu Field Translate 百度垂直领域翻译
Apply here.
The secret format is MY_APPID#MY_KEY#DOMAIN_CODE(split with '#').

Domain Code 领域 支持语言方向
it 信息技术领域 中文(简)-> 英语、英语 -> 中文(简)
finance 金融财经领域 中文(简)-> 英语、英语 -> 中文(简)
machinery 机械制造领域 中文(简)-> 英语、英语 -> 中文(简)
senimed 生物医药领域 中文(简)-> 英语、英语 -> 中文(简)
novel 网络文学领域 中文(简)-> 英语
academic 学术论文领域 中文(简)-> 英语、英语 -> 中文(简)
aerospace 航空航天领域 中文(简)-> 英语、英语 -> 中文(简)
wiki 人文社科领域 中文(简)-> 英语
news 新闻资讯领域 中文(简)-> 英语、英语 -> 中文(简)
law 法律法规领域 中文(简)-> 英语、英语 -> 中文(简)
contract 合同领域 中文(简)-> 英语、英语 -> 中文(简)

Chinese Document

OpenL Translate
Apply here.
The secret format is service1,service2,...#apikey(split with '#'; split service codes with ',').

Supported service codes are: deepl,youdao,tencent,aliyun,baidu,caiyun,wechat,sogou,azure,ibm,aws,google, See Service Code

Chinese Document

Tencent Translate
Apply here.
The secret format is secretId#SecretKey#Region(optional, default ap-shanghai)#ProjectId(optional, default 0)(split with '#').

Chinese Document

Xftrans 讯飞翻译
Apply here.

GPT
Apply OpenAI ChatGPT API or Azure OpenAI REST API.
The secret format is sk-* for ChatGPT, and MY_APIKEY for AzureGPT and Custom GPT.

Support third-party or self-deployed compatible APIs.

Chinese Document

Gemini
Apply here.
The secret format is MY_APIKEY.

Qwen-MT
Apply here.
The secret format is MY_APIKEY.

Claude
Apply here.

LibreTranslate
See LibreTranslate. API Key is optional.

MTranServer
See MTranServer. Token is optional.

MTranServer only supports zh-en language pairs for v2.1.1 and previous versions. For MTranServer v3.0.0+, please check the checkbox in the Config panel to use zh-Hans or zh-Hant language. See explanation of the supported languages.

NLLB
See nllb-api or NLLB Serve.

Pot
See Pot. Translate results show in Pot.

User Interface

Advanced

Development & Contributing

This plugin is built based on the Zotero Plugin Template. See the setup and debug details there.

To startup, run

git clone https://github.com/windingwind/zotero-pdf-translate.git
cd zotero-pdf-translate
npm install
npm run build

The plugin is built to ./build/*.xpi.

Contributing

Add new translate service

  1. Copy src/modules/services/_template.ts > src/services/<your-service-id>.ts;
  2. Fill in the required fields (id, type, and translate) and optional fields (name, helpUrl, defaultSecret, secretValidator(secret), and config(settings)) following the introduction. The translation function sets the translation result to data.result if runs successfully and throws an error if fails;
  3. Import the new service object in src/modules/services/index.ts.
  4. Add locale string service.${serviceId} and service-<your-service-id>-dialog-xxx(if necessary) in addon/locale/${lang}/addon.ftl.
  5. Build and test.

Disclaimer

Use this code under AGPL. No warranties are provided. Keep the laws of your locality in mind!

My Zotero Plugins

Sponsors

Thanks peachgirl100, youngfish42, and other anonymous sponsors!

If you want to leave your name here, please email me or leave a message with the donation.

Contributors

zotero-pdf-translate (windingwind/zotero-pdf-translate)

Searching Database…

这是什么?Zotero PDF Translate 是一款 Zotero 插件,可以将 PDF、EPub、网页、元数据、批注和笔记翻译成你所需的目标语言。
这是独立应用还是 Zotero 的插件?它是一个扩展(.xpi 文件),需要安装到 Zotero 文献管理软件中,并不是独立应用。
使用任何翻译服务都需要 API 密钥吗?默认服务 Google 翻译无需密钥即可免费使用;其他服务如 DeepL、Microsoft、百度、阿里云、GPT 或 Gemini,则需要你自行申请并填入自己的 API 密钥。
每个翻译服务的使用方式都一样吗?每个第三方服务都有各自的密钥格式和语言限制。例如,旧版本的 MTranServer 只支持中英互译(zh-en),部分百度领域服务只支持特定的中英翻译方向。
支持 Windows、macOS 和 Linux 吗?支持。作为跨平台的 Zotero 插件,只要 Zotero 能运行的系统它都能使用,不过快捷键略有不同:Windows/Linux 使用 Ctrl,macOS 使用 Cmd。
支持多少种翻译服务?支持 20 多种,包括 Google 翻译、DeepL、Microsoft、百度、阿里云、腾讯、有道、GPT、Gemini、Claude,以及 LibreTranslate 和 MTranServer 等可自行部署的服务。
能否直接把选中的文字翻译到 PDF 批注中?可以。当你高亮或划线选中文字时,译文会添加到批注评论中,之后还可以通过“更新批注”进行修改或重新翻译。
能否同时对比多个翻译服务的结果?可以。独立的翻译窗口可以让你并排查看和比较多个翻译服务的结果。
我能自己添加自定义翻译服务吗?可以。开发者可以复制服务模板文件,填写 id 和 translate 函数等必填字段,在服务索引中注册,并在构建前添加语言文本。
Size
6.4 MB
Stars
12.1K
Age
4y
Commits · 90 Days