词汇表管理
创建和管理自定义术语库,确保品牌名称、专业术语、产品名等在翻译中保持一致。翻译时可关联词汇表 ID。
快速概览
术语库 API 提供完整的 CRUD 操作,支持创建词汇表、批量导入术语条目、查询与删除。每条术语条目由源语言文本和目标语言文本组成,在翻译任务中通过 glossary_id 引用即可生效。每个账号最多创建 100 个词汇表,每个词汇表最多包含 10,000 条术语。
认证方式
Authentication
所有术语库管理接口均需要在 HTTP 请求头中携带有效的 API Token 进行身份认证。请在 控制台 获取您的 Access Token。
Authorization: Bearer <YOUR_ACCESS_TOKEN>
请求头
Request Headers
| Header | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | required | Bearer Token 认证信息 |
Content-Type | string | required | 请求体格式,固定为 application/json |
创建词汇表
Create Glossary
POST/v1/glossary
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| name | string | required | 词汇表名称 |
| source_lang | string | required | 源语言代码 |
| target_lang | string | required | 目标语言代码 |
| entries | array | required | 术语条目列表,最少 1 条,最多一次 500 条 |
| description | string | optional | 词汇表描述,便于管理和区分 |
| case_sensitive | boolean | optional | 是否大小写敏感匹配,默认 true |
Entry 条目对象字段
Entry Object Fields
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| source | string | required | 源语言术语文本,最长 200 字符 |
| target | string | required | 目标语言术语文本,最长 200 字符 |
| note | string | optional | 备注说明,如上下文或使用场景 |
| pos | string | optional | 词性标注,如 noun、verb、adj |
响应字段
Response Fields
| 字段 | 类型 | 说明 |
|---|---|---|
| code | integer | 状态码,0 表示成功 |
| message | string | 操作结果描述信息 |
| data.id | string | 词汇表唯一标识 ID |
| data.name | string | 词汇表名称 |
| data.source_lang | string | 源语言代码 |
| data.target_lang | string | 目标语言代码 |
| data.entry_count | integer | 当前术语条目数量 |
| data.created_at | string | 创建时间,ISO 8601 格式 |
请求示例
Request Examples
curl -X POST https://api.itranslator.cc/v1/glossary \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "我的产品术语库",
"source_lang": "zh",
"target_lang": "en",
"case_sensitive": true,
"entries": [
{"source": "人工智能", "target": "AI", "note": "通用"},
{"source": "机器学习", "target": "Machine Learning", "pos": "noun"}
]
}'
响应示例
{
"code": 0,
"message": "success",
"data": {
"id": "gls_8a7b3c2d1e",
"name": "我的产品术语库",
"source_lang": "zh",
"target_lang": "en",
"entry_count": 2,
"created_at": "2026-07-22T10:30:00Z"
}
}
查询词汇表列表
List Glossaries
GET/v1/glossary
获取当前账号下所有词汇表列表,支持分页和筛选。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| page | integer | optional | 页码,从 1 开始,默认 1 |
| page_size | integer | optional | 每页数量,默认 20,最大 100 |
| source_lang | string | optional | 按源语言筛选 |
| target_lang | string | optional | 按目标语言筛选 |
| keyword | string | optional | 按名称关键词搜索 |
curl -X GET "https://api.itranslator.cc/v1/glossary?page=1&page_size=20&source_lang=zh" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
响应示例
{
"code": 0,
"message": "success",
"data": {
"total": 5,
"page": 1,
"page_size": 20,
"items": [
{
"id": "gls_8a7b3c2d1e",
"name": "我的产品术语库",
"source_lang": "zh",
"target_lang": "en",
"entry_count": 250,
"description": "产品文档专用术语",
"case_sensitive": true,
"created_at": "2026-07-20T08:00:00Z",
"updated_at": "2026-07-22T10:30:00Z"
}
]
}
}
获取词汇表详情
Get Glossary Details
GET/v1/glossary/{id}
获取指定词汇表的详细信息,包括所有术语条目。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | required | 路径参数:词汇表 ID |
| page | integer | optional | 条目分页页码,默认 1 |
| page_size | integer | optional | 每页条目数,默认 100,最大 500 |
curl -X GET "https://api.itranslator.cc/v1/glossary/gls_8a7b3c2d1e?page=1&page_size=100" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
响应示例
{
"code": 0,
"message": "success",
"data": {
"id": "gls_8a7b3c2d1e",
"name": "我的产品术语库",
"source_lang": "zh",
"target_lang": "en",
"description": "产品文档专用术语",
"case_sensitive": true,
"entry_count": 250,
"entries": [
{
"id": "ent_001",
"source": "人工智能",
"target": "AI",
"note": "通用",
"pos": "noun",
"created_at": "2026-07-20T08:05:00Z"
},
{
"id": "ent_002",
"source": "机器学习",
"target": "Machine Learning",
"pos": "noun",
"created_at": "2026-07-20T08:05:00Z"
}
],
"created_at": "2026-07-20T08:00:00Z",
"updated_at": "2026-07-22T10:30:00Z"
}
}
添加术语条目
Add Entries
POST/v1/glossary/{id}/entries
向指定词汇表批量添加术语条目。如果 source 已存在,默认会覆盖 target 值。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | required | 路径参数:词汇表 ID |
| entries | array | required | 术语条目列表,一次最多 500 条 |
| overwrite | boolean | optional | 遇到重复 source 时是否覆盖,默认 true |
curl -X POST https://api.itranslator.cc/v1/glossary/gls_8a7b3c2d1e/entries \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entries": [
{"source": "深度学习", "target": "Deep Learning", "pos": "noun"},
{"source": "自然语言处理", "target": "NLP", "note": "缩写"}
],
"overwrite": true
}'
响应示例
{
"code": 0,
"message": "success",
"data": {
"added": 2,
"updated": 0,
"skipped": 0,
"entry_count": 252
}
}
删除术语条目
Delete Entry
DELETE/v1/glossary/{id}/entries/{entry_id}
删除词汇表中的单条术语条目。
curl -X DELETE https://api.itranslator.cc/v1/glossary/gls_8a7b3c2d1e/entries/ent_001 \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
响应示例
{
"code": 0,
"message": "success",
"data": {
"deleted_entry_id": "ent_001",
"entry_count": 251
}
}
删除词汇表
Delete Glossary
DELETE/v1/glossary/{id}
注意:此操作不可逆! Warning: This operation is irreversible! 删除整个词汇表及其所有术语条目。已关联该词汇表的翻译任务之后将不再应用这些术语。
curl -X DELETE https://api.itranslator.cc/v1/glossary/gls_8a7b3c2d1e \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
响应示例
{
"code": 0,
"message": "success",
"data": {
"deleted_glossary_id": "gls_8a7b3c2d1e",
"deleted_entry_count": 252
}
}
使用限制
Limits
| 项目 | 上限 | 说明 |
|---|---|---|
| 每账号词汇表数 | 100 | 超出后需删除旧词汇表 |
| 每词汇表条目数 | 10,000 | 建议针对不同领域拆分词汇表 |
| 源/目标文本长度 | 200 字符 | 适合单词、短语和短句 |
| 单次批量添加条目 | 500 | 超过需分多次请求 |
| 请求频率 | 60 次/分钟 | 按账号计算 |
错误码
Error Codes
| HTTP Code | 错误码 | 说明 |
|---|---|---|
| 200 | 0 | 成功 |
| 400 | 1001 | 参数错误,请检查必填参数和参数格式 |
| 400 | 1002 | 条目格式错误,source 或 target 为空 |
| 409 | 1003 | 数据冲突,同语言对下已存在同名词汇表 |
| 400 | 1004 | 词汇表条目数已达上限 |
| 400 | 1005 | 词汇表数量已达账号上限 |
| 400 | 1006 | 源/目标文本超出长度限制 |
| 401 | 2001 | 认证失败,Token 无效或已过期 |
| 403 | 2003 | 无权限访问该资源 |
| 404 | 2004 | 资源不存在(词汇表或条目不存在) |
| 429 | 4001 | 请求频率超限,请稍后重试 |
| 500 | 5001 | 服务器内部错误,请重试或联系技术支持 |
最佳实践
Best Practices
| 建议 | 说明 |
|---|---|
| 按领域拆分词汇表 | 为不同产品线、功能模块或内容类型创建独立词汇表,便于维护和复用 |
| 使用 note 字段记录上下文 | 为多义词或特定场景术语添加使用说明,方便团队成员协作 |
| 标记词性提升匹配精度 | 标注 pos 字段有助于避免同形异义词的误替换 |
| 批量导入时分批处理 | 大量条目建议每次 200-500 条分批调用,避免单次请求超时 |
| 翻译前验证词汇表关联 | 翻译前通过 Get Glossary 确认条目数量,确保术语库已正确配置 |
| 定期清理过期术语 | 定期审查并删除不再使用的术语条目,避免词汇表臃肿影响匹配性能 |
典型用例
Use Cases
| 场景 | 最佳方案 |
|---|---|
| 品牌名称统一翻译 | 创建品牌术语词汇表,将公司名、产品名、口号等条目统一管理,翻译时关联即可保证品牌一致性 |
| 行业专属术语翻译 | 按行业(医疗、法律、金融、IT)分别创建词汇表,为高频专业术语维护标准译法 |
| UI/UX 界面本地化 | 为界面字符串创建词汇表,固定按钮、菜单、提示中的常见 UI 元素的翻译 |
| 多语言文档同步 | 为文档中重复出现的技术缩写和概念创建词汇表,翻译时自动应用,减少人工校对工作 |
| 术语库与TM协同使用 | 将术语库与翻译记忆库配合使用:术语库保证关键术语准确,翻译记忆库保证句段整体一致性 |
| API 批量管理自动化 | 通过 API 将术语库管理集成到 CI/CD 流程中,代码仓库中维护术语文件,发版时自动同步到 TranslatePro |
iTranslator