词汇表管理Glossary Management

创建和管理自定义术语库,确保品牌名称、专业术语、产品名等在翻译中保持一致。翻译时可关联词汇表 ID。Create and manage custom glossaries to ensure brand names, technical terms, and product names are translated consistently. Associate with translations via glossary_id.

快速概览

术语库 API 提供完整的 CRUD 操作,支持创建词汇表、批量导入术语条目、查询与删除。每条术语条目由源语言文本和目标语言文本组成,在翻译任务中通过 glossary_id 引用即可生效。每个账号最多创建 100 个词汇表,每个词汇表最多包含 10,000 条术语。 The Glossary API provides complete CRUD operations to create glossaries, bulk import entries, query, and delete. Each entry consists of a source text and a target text. Once a glossary is referenced via glossary_id in a translation request, terms are applied automatically. Each account can create up to 100 glossaries with up to 10,000 entries each.

认证方式

Authentication

所有术语库管理接口均需要在 HTTP 请求头中携带有效的 API Token 进行身份认证。请在 控制台 获取您的 Access Token。

All glossary management endpoints require a valid API Token in the HTTP request header for authentication. Obtain your Access Token from the Console.

Authorization: Bearer <YOUR_ACCESS_TOKEN>

请求头

Request Headers

HeaderHeader类型Type必填Required说明Description
AuthorizationstringrequiredBearer Token 认证信息Bearer token authentication
Content-Typestringrequired请求体格式,固定为 application/jsonRequest body format; fixed to application/json

创建词汇表

Create Glossary

POST/v1/glossary
参数Parameter类型Type必填Required说明Description
namestringrequired词汇表名称Glossary name
source_langstringrequired源语言代码Source language code
target_langstringrequired目标语言代码Target language code
entriesarrayrequired术语条目列表,最少 1 条,最多一次 500 条Array of entry objects; min 1, max 500 per request
descriptionstringoptional词汇表描述,便于管理和区分Description for management and identification
case_sensitivebooleanoptional是否大小写敏感匹配,默认 trueCase-sensitive matching; default true

Entry 条目对象字段

Entry Object Fields

字段Field类型Type必填Required说明Description
sourcestringrequired源语言术语文本,最长 200 字符Source term text; max 200 characters
targetstringrequired目标语言术语文本,最长 200 字符Target term text; max 200 characters
notestringoptional备注说明,如上下文或使用场景Note or context for this entry
posstringoptional词性标注,如 nounverbadjPart of speech tag, e.g. noun, verb, adj

响应字段

Response Fields

字段Field类型Type说明Description
codeinteger状态码,0 表示成功Status code; 0 = success
messagestring操作结果描述信息Result description message
data.idstring词汇表唯一标识 IDUnique glossary identifier
data.namestring词汇表名称Glossary name
data.source_langstring源语言代码Source language code
data.target_langstring目标语言代码Target language code
data.entry_countinteger当前术语条目数量Current entry count
data.created_atstring创建时间,ISO 8601 格式Creation time in ISO 8601 format

请求示例

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

获取当前账号下所有词汇表列表,支持分页和筛选。

Retrieve all glossaries under the current account, with pagination and filtering support.

参数Parameter类型Type必填Required说明Description
pageintegeroptional页码,从 1 开始,默认 1Page number starting from 1; default 1
page_sizeintegeroptional每页数量,默认 20,最大 100Items per page; default 20, max 100
source_langstringoptional按源语言筛选Filter by source language
target_langstringoptional按目标语言筛选Filter by target language
keywordstringoptional按名称关键词搜索Search by glossary name keyword
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}

获取指定词汇表的详细信息,包括所有术语条目。

Retrieve detailed information for a specific glossary, including all entries.

参数Parameter类型Type必填Required说明Description
idstringrequired路径参数:词汇表 IDPath parameter: glossary ID
pageintegeroptional条目分页页码,默认 1Entry pagination page; default 1
page_sizeintegeroptional每页条目数,默认 100,最大 500Entries per page; default 100, max 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 值。

Batch add entries to a specified glossary. If a source term already exists, the target value will be overwritten by default.

参数Parameter类型Type必填Required说明Description
idstringrequired路径参数:词汇表 IDPath parameter: glossary ID
entriesarrayrequired术语条目列表,一次最多 500 条Entry array; max 500 per request
overwritebooleanoptional遇到重复 source 时是否覆盖,默认 trueWhether to overwrite duplicate sources; default 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}

删除词汇表中的单条术语条目。

Delete a single entry from a glossary.

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! 删除整个词汇表及其所有术语条目。已关联该词汇表的翻译任务之后将不再应用这些术语。 Deletes the entire glossary and all its entries. Translation tasks that reference this glossary will no longer apply these terms.

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

项目Item上限Limit说明Notes
每账号词汇表数Glossaries per account100超出后需删除旧词汇表Delete old glossaries if exceeded
每词汇表条目数Entries per glossary10,000建议针对不同领域拆分词汇表Consider splitting by domain
源/目标文本长度Source/target text length200 字符chars适合单词、短语和短句Suitable for words, phrases, and short sentences
单次批量添加条目Entries per batch add500超过需分多次请求Split into multiple requests if exceeded
请求频率Rate limit60 次/分钟req/min按账号计算Per account

错误码

Error Codes

HTTP Code错误码Error Code说明Description
2000成功Success
4001001参数错误,请检查必填参数和参数格式Invalid parameter; check required fields and format
4001002条目格式错误,source 或 target 为空Entry format error; empty source or target
4091003数据冲突,同语言对下已存在同名词汇表Data conflict; glossary with same name exists for this language pair
4001004词汇表条目数已达上限Glossary entry limit reached
4001005词汇表数量已达账号上限Account glossary count limit reached
4001006源/目标文本超出长度限制Source or target text exceeds length limit
4012001认证失败,Token 无效或已过期Authentication failed; invalid or expired token
4032003无权限访问该资源Access denied; insufficient permissions
4042004资源不存在(词汇表或条目不存在)Resource not found (glossary or entry)
4294001请求频率超限,请稍后重试Rate limit exceeded; please retry later
5005001服务器内部错误,请重试或联系技术支持Internal server error; retry or contact support

最佳实践

Best Practices

建议Suggestion说明Description
按领域拆分词汇表Split glossaries by domain为不同产品线、功能模块或内容类型创建独立词汇表,便于维护和复用Create separate glossaries for different products, modules, or content types for easier maintenance and reuse
使用 note 字段记录上下文Use note field for context为多义词或特定场景术语添加使用说明,方便团队成员协作Add usage notes for polysemous or context-specific terms to facilitate team collaboration
标记词性提升匹配精度Tag POS for better matching标注 pos 字段有助于避免同形异义词的误替换Using the pos field helps avoid incorrect substitution of homographs
批量导入时分批处理Batch import in chunks大量条目建议每次 200-500 条分批调用,避免单次请求超时For large imports, send 200-500 entries per batch to avoid request timeouts
翻译前验证词汇表关联Verify glossary before translation翻译前通过 Get Glossary 确认条目数量,确保术语库已正确配置Confirm entry count via Get Glossary before translation to ensure correct configuration
定期清理过期术语Clean up obsolete terms定期审查并删除不再使用的术语条目,避免词汇表臃肿影响匹配性能Regularly review and delete unused entries to prevent glossary bloat and maintain matching performance

典型用例

Use Cases

场景Scenario最佳方案Approach
品牌名称统一翻译Brand name consistency创建品牌术语词汇表,将公司名、产品名、口号等条目统一管理,翻译时关联即可保证品牌一致性Create a brand glossary with company names, product names, and slogans; link it in translation to ensure brand consistency
行业专属术语翻译Industry-specific terms按行业(医疗、法律、金融、IT)分别创建词汇表,为高频专业术语维护标准译法Create domain-specific glossaries (medical, legal, finance, IT) with standardized translations for high-frequency terminology
UI/UX 界面本地化UI/UX localization为界面字符串创建词汇表,固定按钮、菜单、提示中的常见 UI 元素的翻译Create a UI glossary to fix translations for common interface elements like buttons, menus, and tooltips
多语言文档同步Multi-language documentation为文档中重复出现的技术缩写和概念创建词汇表,翻译时自动应用,减少人工校对工作Create a glossary for recurring technical abbreviations and concepts in documentation; apply automatically during translation to reduce manual review
术语库与TM协同使用Glossary + TM synergy将术语库与翻译记忆库配合使用:术语库保证关键术语准确,翻译记忆库保证句段整体一致性Use glossary alongside Translation Memory: the glossary ensures key term accuracy, while TM ensures overall segment consistency
API 批量管理自动化Automated batch management通过 API 将术语库管理集成到 CI/CD 流程中,代码仓库中维护术语文件,发版时自动同步到 TranslateProIntegrate glossary management into CI/CD pipelines via API; maintain term files in code repositories and auto-sync to TranslatePro on release