Weblate 的 REST API¶
API 可以在 /api/ URL上访问,并且它基于 Django REST 框架。你可以直接使用或参考 Weblate 客户端。
还用 /api/schema/ URL 上的 OpenAPI 3.1 记录了该 API,您可以访问 /api/docs/ 进行浏览。
备注
OpenAPI 作为功能预览提供。相关文档此刻很可能不完整有待更改。关于此 API 更详细信息请查看下方文档。
身份认证和通用参数¶
公共项目的 API 无需身份认证即可使用,但未经身份认证的请求会受到严格的限制(默认为每天 100 个请求),所以建议使用身份认证。身份认证使用令牌,你可以在你的个人资料中获取该令牌。在 Authorization 标头中使用它:
- ANY /¶
API 的通用请求行为、标头、状态码和此处的参数也适用于所有端点。
- 查询参数:
format -- 响应格式(覆盖了 Accept)。可能的值取决于 REST 框架设置,默认支持
json、csv和api。后者为 API 提供了 web 浏览器接口。page -- 返回给定页面的分页结果(使用 next 和 previous 字段来响应自动导航)。
page_size -- 返回每次请求指定的项数。默认值为 50,最大值为 1000。对于 units 端点,默认值为 100,最大值为 10000。也可以通过 PAGE_SIZE 设置项来配置默认值。
- 请求标头:
Authorization -- 验证为
Authorization: Token YOUR-TOKEN的可选令牌
- 响应标头:
Content-Type -- 这取决于请求的标头 Accept
Allow -- 对象允许的 HTTP 方法的列表
- 响应 JSON 对象:
detail (string) -- 结果的详细说明(对于 200 OK 以外的 HTTP 状态码)
count (int) -- 对象列表的总项目计数
next (string) -- 对象列表的下一页 URL
previous (string) -- 对象列表的上一页 URL
results (array) -- 对象列表的结果
url (string) -- 使用 API 访问这个资源的 URL
web_url (string) -- 使用浏览器访问这个资源的 URL
- 状态码:
200 OK -- 当请求被正确地处理时
201 Created -- 当成功创建新对象时
204 No Content -- 当成功删除对象时
400 Bad Request -- 当表单参数丢失时
403 Forbidden -- 当访问被拒绝时
429 Too Many Requests -- 当出现瓶颈时
身份认证令牌¶
在 4.10 版本发生变更: 在 4.10 版本中引入了项目范围的令牌。
每个用户都有自己的个人访问令牌,可以在用户档案中获得。新生成的用户访问令牌带有 wlu_ 前缀。
可以创建项目范围的访问令牌,只用于访问指定项目的 API。这些访问令牌带有 wlp_ 前缀。
身份认证的示例¶
示例请求:
GET /api/ HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
Authorization: Token YOUR-TOKEN
示例响应:
HTTP/1.0 200 OK
Date: Fri, 25 Mar 2016 09:46:12 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, HEAD, OPTIONS
{
"projects":"http://example.com/api/projects/",
"components":"http://example.com/api/components/",
"translations":"http://example.com/api/translations/",
"languages":"http://example.com/api/languages/"
}
CURL 示例:
curl \
-H "Authorization: Token TOKEN" \
https://example.com/api/
传递参数的示例¶
对于 POST 方法,参数可以指定为表单提交(application/x-www-form-urlencoded)或 JSON(application/json)。
表单请求示例:
POST /api/projects/hello/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Token TOKEN
operation=pull
JSON 请求的示例:
POST /api/projects/hello/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20
{"operation":"pull"}
CURL 示例:
curl \
-d operation=pull \
-H "Authorization: Token TOKEN" \
http://example.com/api/components/hello/weblate/repository/
CURL JSON 示例:
curl \
--data-binary '{"operation":"pull"}' \
-H "Content-Type: application/json" \
-H "Authorization: Token TOKEN" \
http://example.com/api/components/hello/weblate/repository/
部件和类别¶
要访问嵌套在 分类 内的部件,你需要将分类名通过 URL 编码成用斜杠分隔的部件名。比如,置于 docs 分类中的 usage 需要转换成 docs%252Fusage,此示例的完整 URL 应形如 https://example.com/api/components/hello/docs%252Fusage/repository/.
API 频次限制¶
这个 API 请求限制了速率;对于匿名用户默认配置限制为每天 100 个请求,对于身份认证的用户限制为每小时 5000 个请求。
速率限制可以在 settings.py 中调整;如何配置它的更多细节请参见 Throttling in Django REST framework documentation。
在 Docker 容器中可使用 WEBLATE_API_RATELIMIT_ANON 和 WEBLATE_API_RATELIMIT_USER 对此进行配置。
速率限制在后面的标头中报告:
|
允许执行请求的数量 |
|
剩余的执行请求数 |
|
速率限制窗口重置前的秒数 |
在 4.1 版本发生变更: 添加速率限制状态的标头。
错误响应¶
在 5.10 版本发生变更: 此版本前不同端点的错误响应不一样。
Weblate 错误响应格式依据 Error Response Format。
API 入口点¶
- GET /api/¶
API 根入口点。
示例请求:
GET /api/ HTTP/1.1 Host: example.com Accept: application/json, text/javascript Authorization: Token YOUR-TOKEN
示例响应:
HTTP/1.0 200 OK Date: Fri, 25 Mar 2016 09:46:12 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, HEAD, OPTIONS { "projects":"http://example.com/api/projects/", "components":"http://example.com/api/components/", "translations":"http://example.com/api/translations/", "languages":"http://example.com/api/languages/" }
用户¶
Added in version 4.0.
- GET /api/users/¶
返回用户列表,如果有权限查看管理用户的话。如果没有,那么会只看到自己的具体信息。
- 查询参数:
username (string) -- 要搜索的用户名
id (int) -- 要搜索的用户 ID
参见
用户对象属性记录在
GET /api/users/(str:username)/。
- POST /api/users/¶
创建新用户。
- 参数:
username (string) -- 用户名
full_name (string) -- 用户全名
email (string) -- 用户电子邮箱
is_superuser (boolean) -- 用户是超级用户吗?(可选的)
is_active (boolean) -- 用户是活动用户吗?(可选的)
is_bot (boolean) -- 用户是机器人吗?(可选)(用于项目范围内的访问令牌)
- GET /api/users/(str: username)/¶
返回用户的信息。
- 参数:
username (string) -- 用户的用户名
- 响应 JSON 对象:
username (string) -- 用户的用户名
full_name (string) -- 用户的全名
email (string) -- 用户的电子邮箱
is_superuser (boolean) -- 用户是否是超级用户
is_active (boolean) -- 用户是否是活动用户
is_bot (boolean) -- 用户是否是机器人(用于项目范围的令牌)
date_joined (string) -- 创建用户的日期
last_login (string) -- 用户最后登录日期
groups (array) -- 连接到关联的组;请参见
GET /api/groups/(int:id)/languages (array) -- 链接到翻译语言;请参见
GET /api/languages/(string:language)/
示例 JSON 数据:
{ "email": "user@example.com", "full_name": "Example User", "username": "exampleusername", "groups": [ "http://example.com/api/groups/2/", "http://example.com/api/groups/3/" ], "languages": [ "http://example.com/api/languages/cs/", ], "is_superuser": true, "is_active": true, "is_bot": false, "date_joined": "2020-03-29T18:42:42.617681Z", "url": "http://example.com/api/users/exampleusername/", "contributions_url": "http://example.com/api/users/exampleusername/contributions/" "statistics_url": "http://example.com/api/users/exampleusername/statistics/" }
- PUT /api/users/(str: username)/¶
更改用户参数。
- 参数:
username (string) -- 用户的用户名
- 响应 JSON 对象:
username (string) -- 用户的用户名
full_name (string) -- 用户的全名
email (string) -- 用户的电子邮箱
is_superuser (boolean) -- 用户是否是超级用户
is_active (boolean) -- 用户是否是活动用户
is_bot (boolean) -- 用户是否是机器人(用于项目范围的令牌)
date_joined (string) -- 创建用户的日期
- PATCH /api/users/(str: username)/¶
更改用户参数。
- 参数:
username (string) -- 用户的用户名
- 响应 JSON 对象:
username (string) -- 用户的用户名
full_name (string) -- 用户的全名
email (string) -- 用户的电子邮箱
is_superuser (boolean) -- 用户是否是超级用户
is_active (boolean) -- 用户是否是活动用户
is_bot (boolean) -- 用户是否是机器人(用于项目范围的令牌)
date_joined (string) -- 创建用户的日期
- DELETE /api/users/(str: username)/¶
删除所有的用户信息并将用户标记为不活动用户。
- 参数:
username (string) -- 用户的用户名
- POST /api/users/(str: username)/groups/¶
将群组与用户关联。
- 参数:
username (string) -- 用户的用户名
- 表单参数:
string group_id -- 唯一的群组 ID
- DELETE /api/users/(str: username)/groups/¶
Added in version 4.13.1.
从组中删除用户。
- 参数:
username (string) -- 用户的用户名
- 表单参数:
string group_id -- 唯一的群组 ID
- GET /api/users/(str: username)/statistics/¶
用户的统计数据列表。
- 参数:
username (string) -- 用户的用户名
- 响应 JSON 对象:
translated (int) -- 用户翻译的数量
suggested (int) -- 用户提交建议的数量
uploaded (int) -- 用户上传次数
commented (int) -- 用户评论的数量
languages (int) -- 用户能够翻译的语言数量
- GET /api/users/(str: username)/contributions/¶
列出用户贡献的翻译。
- 参数:
username (string) -- 用户的用户名
- 响应 JSON 对象:
translations (array) -- 链接到翻译;请参见:
GET /api/translations/(string:project)/(string:component)/(string:language)/
- GET /api/users/(str: username)/notifications/¶
用户的订阅列表。
- 参数:
username (string) -- 用户的用户名
- POST /api/users/(str: username)/notifications/¶
将订阅与用户关联。
- 参数:
username (string) -- 用户的用户名
- 请求 JSON 对象:
notification (string) -- 注册通知的名称
scope (int) -- 可用选项的通知范围
frequency (int) -- 通知的频率选项
- GET /api/users/(str: username)/notifications/(int: subscription_id)/¶
获得与用户关联的订阅。
- 参数:
username (string) -- 用户的用户名
subscription_id (int) -- 已注册通知ID
- PUT /api/users/(str: username)/notifications/(int: subscription_id)/¶
编辑与用户关联的订阅。
- 参数:
username (string) -- 用户的用户名
subscription_id (int) -- 已注册通知ID
- 请求 JSON 对象:
notification (string) -- 注册通知的名称
scope (int) -- 可用选项的通知范围
frequency (int) -- 通知的频率选项
- PATCH /api/users/(str: username)/notifications/(int: subscription_id)/¶
编辑与用户关联的订阅。
- 参数:
username (string) -- 用户的用户名
subscription_id (int) -- 已注册通知ID
- 请求 JSON 对象:
notification (string) -- 注册通知的名称
scope (int) -- 可用选项的通知范围
frequency (int) -- 通知的频率选项
- DELETE /api/users/(str: username)/notifications/(int: subscription_id)/¶
删除与用户关联的订阅。
- 参数:
username (string) -- 用户的用户名
subscription_id -- 注册通知的名称
subscription_id -- int
群组¶
Added in version 4.0.
- GET /api/groups/¶
返回群组列表,如果有权限看到管理群组的话,如果没有,那么会只看到用户所在的群组。
参见
群组对象属性记录在
GET /api/groups/(int:id)/。
- POST /api/groups/¶
创建新的群组。
- 参数:
name (string) -- 组名
project_selection (int) -- 给定选项的项目选择的群组
language_selection (int) -- 给定选项的语言选择的群组
defining_project (str) -- 链接到定义项目,用于 管理每个项目的访问控制;请参见
GET /api/projects/(string:project)/
- GET /api/groups/(int: id)/¶
返回有关群组的信息。
- 参数:
id (int) -- 群组的 ID
- 响应 JSON 对象:
name (string) -- 群组的名称
project_selection (int) -- 相应于对象群组的整数
language_selection (int) -- 相应于语言群组的整数
roles (array) -- 相关联角色的连接;请参见
GET /api/roles/(int:id)/projects (array) -- 相关联项目的连接;请参见
GET /api/projects/(string:project)/components (array) -- 相关联部件的连接;请参见
GET /api/components/(string:project)/(string:component)/componentlists (array) -- 相关联部件列表的连接;请参见
GET /api/component-lists/(str:slug)/defining_project (str) -- 链接到定义项目,用于 管理每个项目的访问控制;请参见
GET /api/projects/(string:project)/admins (array) -- 连接到关联的管理员;见
GET /api/users/(str:username)/
示例 JSON 数据:
{ "name": "Guests", "defining_project": null, "project_selection": 3, "language_selection": 1, "url": "http://example.com/api/groups/1/", "roles": [ "http://example.com/api/roles/1/", "http://example.com/api/roles/2/" ], "languages": [ "http://example.com/api/languages/en/", "http://example.com/api/languages/cs/", ], "projects": [ "http://example.com/api/projects/demo1/", "http://example.com/api/projects/demo/" ], "componentlist": "http://example.com/api/component-lists/new/", "components": [ "http://example.com/api/components/demo/weblate/" ], "admins": [ "http://example.com/api/users/exampleusername/" ] }
- PUT /api/groups/(int: id)/¶
更改群组参数。
- 参数:
id (int) -- 群组的 ID
- 响应 JSON 对象:
name (string) -- 群组的名称
project_selection (int) -- 相应于对象群组的整数
language_selection (int) -- 相应于语言群组的整数
- PATCH /api/groups/(int: id)/¶
更改群组参数。
- 参数:
id (int) -- 群组的 ID
- 响应 JSON 对象:
name (string) -- 群组的名称
project_selection (int) -- 相应于对象群组的整数
language_selection (int) -- 相应于语言群组的整数
- DELETE /api/groups/(int: id)/¶
删除群组。
- 参数:
id (int) -- 群组的 ID
- POST /api/groups/(int: id)/roles/¶
将角色与群组关联。
- 参数:
id (int) -- 群组的 ID
- 表单参数:
string role_id -- 唯一的角色 ID
- DELETE /api/groups/(int: id)/roles/(int: role_id)¶
从群组删除角色。
- 参数:
id (int) -- 群组的 ID
role_id (int) -- 唯一的角色 ID
- POST /api/groups/(int: id)/components/¶
将部件与群组关联。
- 参数:
id (int) -- 群组的 ID
- 表单参数:
string component_id -- 唯一的部件 ID
- DELETE /api/groups/(int: id)/components/(int: component_id)¶
从群组删除部件。
- 参数:
id (int) -- 群组的 ID
component_id (int) -- 唯一的部件 ID
- POST /api/groups/(int: id)/projects/¶
将项目与群组关联。
- 参数:
id (int) -- 群组的 ID
- 表单参数:
string project_id -- 唯一的项目 ID
- DELETE /api/groups/(int: id)/projects/(int: project_id)¶
从群组删除项目。
- 参数:
id (int) -- 群组的 ID
project_id (int) -- 唯一的项目 ID
- POST /api/groups/(int: id)/languages/¶
将语言与群组关联。
- 参数:
id (int) -- 群组的 ID
- 表单参数:
string language_code -- 唯一的语言代码
- DELETE /api/groups/(int: id)/languages/(string: language_code)¶
从群组删除语言。
- 参数:
id (int) -- 群组的 ID
language_code (string) -- 唯一的语言代码
- POST /api/groups/(int: id)/componentlists/¶
将部件列表与群组关联。
- 参数:
id (int) -- 群组的 ID
- 表单参数:
string component_list_id -- 唯一的部件列表 ID
- DELETE /api/groups/(int: id)/componentlists/(int: component_list_id)¶
从群组删除部件列表。
- 参数:
id (int) -- 群组的 ID
component_list_id (int) -- 唯一的部件列表 ID
- POST /api/groups/(int: id)/admins/¶
Added in version 5.5.
添加用户到团队管理。
- 参数:
id (int) -- 群组的 ID
- 表单参数:
string user_id -- 用户 ID
- DELETE /api/groups/(int: id)/admins/(int: user_id)¶
Added in version 5.5.
从团队管理员中删除用户。
- 参数:
id (int) -- 群组的 ID
user_id (integer) -- 用户 ID
角色¶
- GET /api/roles/¶
返回与用户关联的所有角色列表。如果用户是超级用户,那么返回所有现有角色的列表。
参见
角色对象属性记录在
GET /api/roles/(int:id)/。
- POST /api/roles/¶
创建新角色。
- 参数:
name (string) -- 角色名称
permissions (array) -- 权限代号列表
- GET /api/roles/(int: id)/¶
返回有关角色的信息。
- 参数:
id (int) -- 角色的ID
- 响应 JSON 对象:
name (string) -- 角色名称
permissions (array) -- 权限代号列表
示例 JSON 数据:
{ "name": "Access repository", "permissions": [ "vcs.access", "vcs.view" ], "url": "http://example.com/api/roles/1/", }
- PUT /api/roles/(int: id)/¶
更改角色参数。
- 参数:
id (int) -- 角色的ID
- 响应 JSON 对象:
name (string) -- 角色名称
permissions (array) -- 权限代号列表
- PATCH /api/roles/(int: id)/¶
更改角色参数。
- 参数:
id (int) -- 角色的ID
- 响应 JSON 对象:
name (string) -- 角色名称
permissions (array) -- 权限代号列表
- DELETE /api/roles/(int: id)/¶
删除角色。
- 参数:
id (int) -- 角色的ID
语言¶
- GET /api/languages/¶
返回所有语言的列表。
参见
语言对象属性记录在
GET /api/languages/(string:language)/。
- POST /api/languages/¶
创建新的语言。
- 参数:
code (string) -- 语言名称
name (string) -- 语言名称
direction (string) -- 文字方向
population (int) -- 语言使用者数量
plural (object) -- 语言复数公式和数量
- GET /api/languages/(string: language)/¶
返回有关语言的信息。
- 参数:
language (string) -- 语言代码
- 响应 JSON 对象:
code (string) -- 语言代码
direction (string) -- 文字方向
plural (object) -- 语言复数信息的对象
aliases (array) -- 语言别名的数组
- 请求 JSON 对象:
population (int) -- 语言使用者数量
示例 JSON 数据:
{ "code": "en", "direction": "ltr", "name": "English", "population": 159034349015, "plural": { "id": 75, "source": 0, "number": 2, "formula": "n != 1", "type": 1 }, "aliases": [ "english", "en_en", "base", "source", "eng" ], "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/", "statistics_url": "http://example.com/api/languages/en/statistics/" }
- PUT /api/languages/(string: language)/¶
更改语言参数。
- 参数:
language (string) -- 语言的代码
- 请求 JSON 对象:
name (string) -- 语言名称
direction (string) -- 文字方向
population (int) -- 语言使用者数量
plural (object) -- 语言复数的细节
- PATCH /api/languages/(string: language)/¶
更改语言参数。
- 参数:
language (string) -- 语言的代码
- 请求 JSON 对象:
name (string) -- 语言名称
direction (string) -- 文字方向
population (int) -- 语言使用者数量
plural (object) -- 语言复数的细节
- DELETE /api/languages/(string: language)/¶
删除该语言。
- 参数:
language (string) -- 语言的代码
项目¶
- GET /api/projects/¶
返回所有项目的列表。
参见
项目对象属性记录在
GET /api/projects/(string:project)/。
- POST /api/projects/¶
创建新项目。
- 参数:
name (string) -- 项目名称
slug (string) -- 项目标识串
web (string) -- 项目网站
- GET /api/projects/(string: project)/¶
返回有关项目的信息。
- 参数:
project (string) -- 项目 URL 标识符
- 响应 JSON 对象:
name (string) -- 项目名称
slug (string) -- 项目标识串
web (string) -- 项目网站
components_list_url (string) -- 部件列表的 URL;请参见
GET /api/projects/(string:project)/components/repository_url (string) -- 仓库状态的 URL;请参见
GET /api/projects/(string:project)/repository/changes_list_url (string) -- 更改列表的 URL;请参见
GET /api/projects/(string:project)/changes/credits_url (string) -- 列举贡献者致谢信息的 URL;见
GET /api/projects/(string:project)/credits/translation_review (boolean) -- 启用审校
source_review (boolean) -- 启用原文审校
set_language_team (boolean) -- 设置 "Language-Team" 标头
enable_hooks (boolean) -- 启用钩子
instructions (string) -- 翻译说明
language_aliases (string) -- 语言别名
示例 JSON 数据:
{ "name": "Hello", "slug": "hello", "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }
- PATCH /api/projects/(string: project)/¶
Added in version 4.3.
通过 PATCH 请求来编辑一个项目。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- PUT /api/projects/(string: project)/¶
Added in version 4.3.
通过 PUT 请求来编辑一个项目。
- 参数:
project (string) -- 项目 URL 标识符
- DELETE /api/projects/(string: project)/¶
删除项目。
- 参数:
project (string) -- 项目 URL 标识符
- GET /api/projects/(string: project)/changes/¶
返回项目更改的列表。这本质上是一个项目范围的
GET /api/changes/接受相同的参数。- 参数:
project (string) -- 项目 URL 标识符
- 响应 JSON 对象:
results (array) -- 部件对象的数组;请参见
GET /api/changes/(int:id)/
- GET /api/projects/(string: project)/file/¶
Added in version 5.5.
使用请求的格式和语言将与项目关联的所有可用译文作为存档文件下载。
- 参数:
project (string) -- 项目 URL 标识符
- 查询参数:
format (string) -- 要使用的存档格式;如未指定,默认为
zip;受支持的格式:zip和zip:CONVERSION,其中CONVERSION为 下载译文 处列出的转换器之一。language_code (string) -- 要下载的语言码;如未指定,将包括所有语言。
- GET /api/projects/(string: project)/repository/¶
返回版本控制系统仓库状态的信息。这个端点只包含项目所有仓库的整体概况。为了得到更多细节,请使用
GET /api/components/(string:project)/(string:component)/repository/。- 参数:
project (string) -- 项目 URL 标识符
- 响应 JSON 对象:
needs_commit (boolean) -- 是否有任何要提交的待处理更改
needs_merge (boolean) -- 是否有上游更改要合并
needs_push (boolean) -- 是否有本地更改要推送
示例 JSON 数据:
{ "needs_commit": true, "needs_merge": false, "needs_push": true }
- POST /api/projects/(string: project)/repository/¶
在版本控制系统仓库上执行给定的操作。
- 参数:
project (string) -- 项目 URL 标识符
- 请求 JSON 对象:
operation (string) -- 要执行的操作:
push、pull、commit、reset、cleanup、file-sync、file-scan中的一个
- 响应 JSON 对象:
result (boolean) -- 操作的结果
CURL 示例:
curl \ -d operation=pull \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/repository/
JSON 请求的示例:
POST /api/projects/hello/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"operation":"pull"}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS {"result":true}
- GET /api/projects/(string: project)/components/¶
返回给定项目的翻译部件列表。
- 参数:
project (string) -- 项目 URL 标识符
- 响应 JSON 对象:
results (array) -- 部件对象的数组;请参见
GET /api/components/(string:project)/(string:component)/
- POST /api/projects/(string: project)/components/¶
在 4.3 版本发生变更:
zipfile和docfile参数现在可用于无 VCS 的部件,参见 本地文件。在 4.6 版本发生变更: 克隆的仓库现在可以使用 Weblate 内部网址. 使用
disable_autoshare关闭此功能。在给定的项目中新建翻译部件。
提示
从单个版本控制系统仓库创建多个部件时,请使用 Weblate 内部网址。
备注
多数部件的新建发生在后台。检查新建部件的
task_url属性,并按照那里的步骤进行。- 参数:
project (string) -- 项目 URL 标识符
- 表单参数:
file zipfile -- 上传到 Weblate 用于翻译初始化的 ZIP 文件
file docfile -- 要翻译的文档
boolean disable_autoshare -- 禁用通过 Weblate 内部网址 自动共享仓库。
- 请求 JSON 对象:
object -- 部件参数,参见
GET /api/components/(string:project)/(string:component)/
- 响应 JSON 对象:
result (object) -- 新建部件对象;请参见
GET /api/components/(string:project)/(string:component)/
使用
zipfile上传文件时无法使用 JSON 和docfile参数数据必须以 multipart/form-data 的形式上传。CURL 表单请求示例:
curl \ --form docfile=@strings.html \ --form name=Weblate \ --form slug=weblate \ --form file_format=html \ --form new_lang=add \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/components/
CURL JSON 请求的示例:
curl \ --data-binary '{ "branch": "main", "file_format": "po", "file_format_params": { "po_line_wrap": 65535, "po_no_location": true }, "filemask": "po/*.po", "name": "Weblate", "slug": "weblate", "repo": "https://github.com/WeblateOrg/hello.git", "template": "", "new_base": "po/hello.pot", "vcs": "git" }' \ -H "Content-Type: application/json" \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/components/
从 Git 创建新部件的 JSON 请求:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "branch": "main", "file_format": "po", "file_format_params": { "po_line_wrap": 65535, "po_no_location": true }, "filemask": "po/*.po", "name": "Weblate", "slug": "weblate", "repo": "https://github.com/WeblateOrg/hello.git", "template": "", "new_base": "po/hello.pot", "vcs": "git" }
从另一个部件创建新部件的 JSON 请求:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "file_format": "po", "filemask": "po/*.po", "name": "Weblate", "slug": "weblate", "repo": "weblate://weblate/hello", "template": "", "new_base": "po/hello.pot", "vcs": "git" }
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS { "branch": "main", "file_format": "po", "file_format_params": { "po_line_wrap": 65535, "po_no_location": true }, "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "population": 159034349015, "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }
- GET /api/projects/(string: project)/languages/¶
对项目内的所有语言返回编页的统计数据。
- 参数:
project (string) -- 项目 URL 标识符
- 响应 JSON 对象:
results (array) -- 翻译统计数据对象的数组
language (string) -- 语言名称
code (string) -- 语言代码
total (int) -- 字符串的总数
translated (int) -- 已翻译字符串的数量
translated_percent (float) -- 已翻译字符串的百分比
total_words (int) -- 词的总数
translated_words (int) -- 已翻译词的数量
words_percent (float) -- 已翻译词的百分比
- GET /api/projects/(string: project)/statistics/¶
返回项目的统计数据。
- 参数:
project (string) -- 项目 URL 标识符
参见
返回属性的描述,请见 统计信息。
- GET /api/projects/(string: project)/categories/¶
Added in version 5.0: 返回项目的分类。字段定义见
GET /api/categories/(int:id)/.- param project:
项目 URL 标识符
- 输入项目:
字符串
- GET /api/projects/(string: project)/labels/¶
Added in version 5.3: 返回项目标签。
- param project:
项目 URL 标识符
- 输入项目:
字符串
- >json int id:
标签的 ID
- >json string name:
标签名
- >json string color:
标签颜色
- POST /api/projects/(string: project)/labels/¶
Added in version 5.3: 创建项目标签。
- param project:
项目 URL 标识符
- 输入项目:
字符串
- <json string name:
标签名
- <json string color:
标签颜色
- DELETE /api/projects/(string: project)/labels/(int: label_id)/¶
Added in version 5.14: 从项目中删除标签。
- param project:
项目 URL 标识符
- 输入项目:
字符串
- 参数标签id:
要删除的标签的 ID
- 类型标签 id:
整数
- GET /api/projects/(string: project)/credits/¶
返回项目的贡献者致谢信息。
Added in version 5.7.
- 参数:
project (string) -- 项目 URL 标识符
start (date) -- 下界 ISO 8601 时间戳(强制)
end (date) -- 下界 ISO 8601 时间戳(强制)
lang (source_language) -- 要搜索的语言代码
- 响应 JSON 对象:
email (string) -- 贡献者的电子邮箱地址
full_name (string) -- 贡献者的全名
change_count (string) -- 时间范围内所作的更改数
- GET /api/projects/{string:project}/machinery_settings/¶
Added in version 5.9.
返回项目的自动建议设置,由为每个安装的翻译服务定义的配置所组成。
- 参数:
project (string) -- 项目 URL 标识符
- 响应 JSON 对象:
suggestion_settings (object) -- 所有已安装服务的配置。
- POST /api/projects/{string:project}/machinery_settings/¶
Added in version 5.9.
创建或更新项目的服务配置。
- 参数:
project (string) -- 项目 URL 标识符
- 表单参数:
string service -- 服务名称
string configuration -- JSON 格式的服务配置
- GET /api/projects/(string: project)/languages/(string: language_code)/file/¶
在 5.15.1 版本发生变更: Added ability to download ZIP file of all components translations in a project for 1 specific language.
Download a ZIP file of all translation files for a specified
language_codeacross all components for a givenprojectrather than downloading individual translated files and manually zipping them, with the archive named {project-slug}-{language-code}.zip and organized by component paths (e.g., component-slug/po/lang.po).- 参数:
project (string) -- 项目 URL 标识符
language_code (string) -- 语言代码
- 查询参数:
filter (string) -- Optional case-insensitive substring to filter components by slug (e.g.,
?filter=corewill match components with 'core' anywhere in their slug); only components whose slugs contain the substring will be included in the download.format (string) -- 要使用的存档格式;如未指定,默认为
zip;受支持的格式:zip和zip:CONVERSION,其中CONVERSION为 下载译文 处列出的转换器之一。
备注
Possible responses:
200 OKwith the ZIP file of translations for the specified language across all components in the project. If no components have translations for the specified language, an empty ZIP file will be returned.403 Forbiddenif the user does not have permission to the project.404 Not Foundif the project slug does not exist.
部件¶
提示
- GET /api/components/¶
返回一个翻译部件的列表。
参见
部件对象属性记录在
GET /api/components/(string:project)/(string:component)/。
- GET /api/components/(string: project)/(string: component)/¶
返回有关翻译部件的信息。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
project (object) -- 翻译项目;请参见
GET /api/projects/(string:project)/name (string) -- 部件名称
slug (string) -- 部件标识串
vcs (string) -- 版本控制系统
linked_component (string) -- 通过 Weblate 内部网址 链接其仓库的部件
repo (string) -- 源代码仓库,这是实际的仓库 URL,即使在使用 Weblate 内部网址 时也是,使用
linked_component来检测此状况git_export (string) -- 已导出仓库 URL
branch (string) -- 仓库分支,这是实际的仓库分支,即使在使用 Weblate 内部网址 时也是
push (string) -- 仓库推送 URL,这是实际的仓库 URL,即使在使用 Weblate 内部网址 时也是
push_branch (string) -- 推送分支,这是实际的仓库分支,即使在使用 Weblate 内部网址 时也是
filemask (string) -- 文件掩码
template (string) -- 单语言译文模版语言文件
edit_template (string) -- 编辑译文模版文件
intermediate (string) -- 中间语言文件
new_base (string) -- 新语种的翻译模版
file_format (string) -- 文件格式
file_format_params (object) -- 文件格式参数
license (string) -- 翻译许可证
agreement (string) -- 贡献者许可协议
new_lang (string) -- 添加新语种
language_code_style (string) -- 语言代码风格
source_language (object) -- 源语言对象;请参见
GET /api/languages/(string:language)/check_flags (string) -- 翻译标记
priority (string) -- 优先级
enforced_checks (string) -- 强制检查
restricted (string) -- 受限制的访问
repoweb (string) -- 仓库浏览器
report_source_bugs (string) -- 源字符串错误报告地址
merge_style (string) -- 合并方式
commit_message (string) -- 提交、添加、删除、合并、附加组件及合并请求说明
add_message (string) -- 提交、添加、删除、合并、附加组件及合并请求说明
delete_message (string) -- 提交、添加、删除、合并、附加组件及合并请求说明
merge_message (string) -- 提交、添加、删除、合并、附加组件及合并请求说明
addon_message (string) -- 提交、添加、删除、合并、附加组件及合并请求说明
pull_message (string) -- 提交、添加、删除、合并、附加组件及合并请求说明
allow_translation_propagation (string) -- 允许同步翻译
enable_suggestions (string) -- 启用建议
suggestion_voting (string) -- 建议投票
suggestion_autoaccept (string) -- 自动接受建议
push_on_commit (string) -- 提交时推送
locked (bool) -- 不管部件锁定与否,此字段是只读的;见
GET /api/components/(string:project)/(string:component)/lock/commit_pending_age (string) -- 对更改进行提交的延时时间
auto_lock_error (string) -- 出错时锁定
language_regex (string) -- 语言筛选
variant_regex (string) -- 正则表达式变体
is_glossary (bool) -- 用作术语表
glossary_color (string) -- 术语表颜色
repository_url (string) -- 仓库状态的 URL;请参见
GET /api/components/(string:project)/(string:component)/repository/translations_url (string) -- 翻译列表的 URL;请参见
GET /api/components/(string:project)/(string:component)/translations/lock_url (string) -- 锁定状态的 URL;请参见
GET /api/components/(string:project)/(string:component)/lock/changes_list_url (string) -- 更改的列表的 URL;请参见
GET /api/components/(string:project)/(string:component)/changes/task_url (string) -- 后台任务 URL(如果有的话);请参见
GET /api/tasks/(str:uuid)/credits_url (string) -- 列举贡献者致谢信息的 URL;见
GET /api/components/(string:project)/(string:component)/credits/
示例 JSON 数据:
{ "branch": "main", "file_format": "po", "file_format_params": { "po_line_wrap": 65535, "po_no_location": true }, "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "population": 159034349015, "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "source_language": { "code": "en", "direction": "ltr", "population": 159034349015, "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }
- PATCH /api/components/(string: project)/(string: component)/¶
通过 PATCH 请求编辑一个部件。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
source_language (string) -- 项目源语言代码(可选)
- 请求 JSON 对象:
name (string) -- 部件名称
slug (string) -- 部件的标识串
repo (string) -- 版本控制系统仓库的URL
CURL 示例:
curl \ --data-binary '{"name": "new name"}' \ -H "Content-Type: application/json" \ -H "Authorization: Token TOKEN" \ PATCH http://example.com/api/projects/hello/components/
JSON 请求的示例:
PATCH /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "name": "new name" }
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS { "branch": "main", "file_format": "po", "file_format_params": { "po_line_wrap": 65535, "po_no_location": true }, "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "new name", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "population": 159034349015, "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }
- PUT /api/components/(string: project)/(string: component)/¶
通过 PUT 请求编辑一个部件。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 请求 JSON 对象:
branch (string) -- 版本控制系统仓库分支
file_format (string) -- 翻译的文件格式
file_format_params (object) -- 与该文件有关的参数
filemask (string) -- 仓库中翻译的文件掩码
name (string) -- 部件名称
slug (string) -- 部件的标识串
repo (string) -- 版本控制系统仓库的URL
template (string) -- 但语言翻译的翻译模板文件
new_base (string) -- 用于添加新翻译的翻译模板文件
vcs (string) -- 版本控制系统
- DELETE /api/components/(string: project)/(string: component)/¶
删除部件。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- GET /api/components/(string: project)/(string: component)/changes/¶
返回部件更改的列表。这本质是一个部件范围的
GET /api/changes/接受相同的参数。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
results (array) -- 部件对象的数组;请参见
GET /api/changes/(int:id)/
- GET /api/components/(string: project)/(string: component)/file/¶
Added in version 4.9.
使用请求的格式将与部件关联的所有可用翻译作为存档文件下载。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 查询参数:
format (string) -- 要使用的存档格式;如未指定,默认为
zip;受支持的格式:zip和zip:CONVERSION,其中CONVERSION为 下载译文 处列出的转换器之一。
- GET /api/components/(string: project)/(string: component)/screenshots/¶
返回部件屏幕截图的列表。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
results (array) -- 部件屏幕截图的数组;请参见
GET /api/screenshots/(int:id)/
- GET /api/components/(string: project)/(string: component)/lock/¶
返回部件锁定状态。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
locked (boolean) -- 部件是否因更新而锁定
示例 JSON 数据:
{ "locked": false }
- POST /api/components/(string: project)/(string: component)/lock/¶
设置部件锁定状态。
响应时间与
GET /api/components/(string:project)/(string:component)/lock/相同。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 请求 JSON 对象:
lock -- 是否锁定的布尔值。
CURL 示例:
curl \ -d lock=true \ -H "Authorization: Token TOKEN" \ http://example.com/api/components/hello/weblate/repository/
JSON 请求的示例:
POST /api/components/hello/weblate/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"lock": true}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS {"locked":true}
- GET /api/components/(string: project)/(string: component)/repository/¶
返回有关版本控制系统仓库状态的信息。
响应与
GET /api/projects/(string:project)/repository/相同。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
needs_commit (boolean) -- 是否有任何要提交的待处理更改
needs_merge (boolean) -- 是否有上游更改要合并
needs_push (boolean) -- 是否有本地更改要推送
remote_commit (string) -- 远程提交说明
status (string) -- 由版本控制系统报告的 VCS 状态
merge_failure -- 描述合并失败的文本,没有的话为空
- POST /api/components/(string: project)/(string: component)/repository/¶
在版本控制系统仓库执行给定的操作。
文档请参见
POST /api/projects/(string:project)/repository/。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 请求 JSON 对象:
operation (string) -- 执行的操作:
push,pull,commit,reset,cleanup之一
- 响应 JSON 对象:
result (boolean) -- 操作的结果
CURL 示例:
curl \ -d operation=pull \ -H "Authorization: Token TOKEN" \ http://example.com/api/components/hello/weblate/repository/
JSON 请求的示例:
POST /api/components/hello/weblate/repository/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"operation":"pull"}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS {"result":true}
- GET /api/components/(string: project)/(string: component)/monolingual_base/¶
为单语言翻译下载翻译模板文件。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- GET /api/components/(string: project)/(string: component)/new_template/¶
为新的翻译下载模板文件。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- GET /api/components/(string: project)/(string: component)/translations/¶
返回给定部件中翻译对象的列表。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
results (array) -- 翻译对象的数组;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/
- POST /api/components/(string: project)/(string: component)/translations/¶
在给定部件中新建新的翻译。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 请求 JSON 对象:
language_code (string) -- 翻译语言代码;请参见
GET /api/languages/(string:language)/
- 响应 JSON 对象:
result (object) -- 新建的新翻译对象
CURL 示例:
curl \ -d language_code=cs \ -H "Authorization: Token TOKEN" \ http://example.com/api/projects/hello/components/
JSON 请求的示例:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 {"language_code": "cs"}
JSON 响应的示例:
HTTP/1.0 200 OK Date: Tue, 12 Apr 2016 09:32:50 GMT Server: WSGIServer/0.1 Python/2.7.11+ Vary: Accept, Accept-Language, Cookie X-Frame-Options: SAMEORIGIN Content-Type: application/json Content-Language: en Allow: GET, POST, HEAD, OPTIONS { "failing_checks": 0, "failing_checks_percent": 0, "failing_checks_words": 0, "filename": "po/cs.po", "fuzzy": 0, "fuzzy_percent": 0.0, "fuzzy_words": 0, "have_comment": 0, "have_suggestion": 0, "is_template": false, "is_source": false, "language": { "code": "cs", "direction": "ltr", "population": 1303174280 "name": "Czech", "url": "http://example.com/api/languages/cs/", "web_url": "http://example.com/languages/cs/" }, "language_code": "cs", "id": 125, "last_author": null, "last_change": null, "share_url": "http://example.com/engage/hello/cs/", "total": 4, "total_words": 15, "translate_url": "http://example.com/translate/hello/weblate/cs/", "translated": 0, "translated_percent": 0.0, "translated_words": 0, "url": "http://example.com/api/translations/hello/weblate/cs/", "web_url": "http://example.com/projects/hello/weblate/cs/" }
- GET /api/components/(string: project)/(string: component)/statistics/¶
对部件内所有的翻译返回分页的统计数据。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
参见
返回属性的描述,请见 统计信息。
- GET /api/components/(string: project)/(string: component)/links/¶
返回与部件相连的项目。
Added in version 4.5.
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 响应 JSON 对象:
projects (array) -- 相关的项目,请参见
GET /api/projects/(string:project)/
- POST /api/components/(string: project)/(string: component)/links/¶
将项目与一个部件相关联。
Added in version 4.5.
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
- 表单参数:
string project_slug -- 项目标识串
- DELETE /api/components/(string: project)/(string: component)/links/(string: project_slug)/¶
删除项目与部件的关联性。
Added in version 4.5.
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
project_slug (string) -- 要移除的项目的地址
- GET /api/components/(string: project)/(string: component)/credits/¶
返回项目的贡献者致谢信息。
Added in version 5.7.
- 参数:
project (string) -- 项目 URL 标识符
start (date) -- 下界 ISO 8601 时间戳(强制)
end (date) -- 下界 ISO 8601 时间戳(强制)
lang (source_language) -- 要搜索的语言代码
- 响应 JSON 对象:
email (string) -- 贡献者的电子邮箱地址
full_name (string) -- 贡献者的全名
change_count (string) -- 时间范围内所作的更改数
翻译¶
- GET /api/translations/¶
返回翻译的列表。
- GET /api/translations/(string: project)/(string: component)/(string: language)/¶
返回有关翻译的信息。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- 响应 JSON 对象:
component (object) -- 部件对象;请参见
GET /api/components/(string:project)/(string:component)/failing_checks (int) -- 未通过检查的字符串数量
failing_checks_percent (float) -- 未通过检查的字符串百分比
failing_checks_words (int) -- 带有未通过检查的单词数量
filename (string) -- 翻译文件名
fuzzy (int) -- 模糊(标记为需要编辑)字符串的数量
fuzzy_percent (float) -- 模糊字符串(标记为需要编辑)的百分比
fuzzy_words (int) -- 模糊(标记为编辑)字符串中的单词数
have_comment (int) -- 带有评论的字符串数量
have_suggestion (int) -- 带有建议的字符串数量
is_template (boolean) -- 译文是否有单语基础
language (object) -- 源语言对象;请参见
GET /api/languages/(string:language)/language_code (string) -- 仓库中使用的语言代码;这可以不同于语言对象中的语言代码
last_author (string) -- 最后一位作者的姓名
last_change (timestamp) -- 最后更改的时间戳
revision (string) -- 文件的修订哈希值
share_url (string) -- 用于分享的 URL,指向参与页面
total (int) -- 字符串的总数
total_words (int) -- 词的总数
translate_url (string) -- 翻译的 URL
translated (int) -- 已翻译字符串的数量
translated_percent (float) -- 已翻译字符串的百分比
translated_words (int) -- 已翻译词的数量
repository_url (string) -- 仓库状态的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/repository/file_url (string) -- 文件对象的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/file/changes_list_url (string) -- 更改的列表的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/changes/units_list_url (string) -- 字符串列表的 URL;请参见
GET /api/translations/(string:project)/(string:component)/(string:language)/units/
示例 JSON 数据:
{ "component": { "branch": "main", "file_format": "po", "file_format_params": { "po_line_wrap": 65535, "po_no_location": true }, "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "new_base": "", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "population": 159034349015, "name": "English", "url": "http://example.com/api/languages/en/", "web_url": "http://example.com/languages/en/" }, "url": "http://example.com/api/projects/hello/", "web": "https://weblate.org/", "web_url": "http://example.com/projects/hello/" }, "repo": "file:///home/nijel/work/weblate-hello", "slug": "weblate", "template": "", "url": "http://example.com/api/components/hello/weblate/", "vcs": "git", "web_url": "http://example.com/projects/hello/weblate/" }, "failing_checks": 3, "failing_checks_percent": 75.0, "failing_checks_words": 11, "filename": "po/cs.po", "fuzzy": 0, "fuzzy_percent": 0.0, "fuzzy_words": 0, "have_comment": 0, "have_suggestion": 0, "is_template": false, "language": { "code": "cs", "direction": "ltr", "population": 1303174280 "name": "Czech", "url": "http://example.com/api/languages/cs/", "web_url": "http://example.com/languages/cs/" }, "language_code": "cs", "last_author": "Weblate Admin", "last_change": "2016-03-07T10:20:05.499", "revision": "7ddfafe6daaf57fc8654cc852ea6be212b015792", "share_url": "http://example.com/engage/hello/cs/", "total": 4, "total_words": 15, "translate_url": "http://example.com/translate/hello/weblate/cs/", "translated": 4, "translated_percent": 100.0, "translated_words": 15, "url": "http://example.com/api/translations/hello/weblate/cs/", "web_url": "http://example.com/projects/hello/weblate/cs/" }
- DELETE /api/translations/(string: project)/(string: component)/(string: language)/¶
删除翻译。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- GET /api/translations/(string: project)/(string: component)/(string: language)/changes/¶
返回翻译更改的列表。这本质上是一个翻译范围的
GET /api/changes/接受相同的参数。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- 响应 JSON 对象:
results (array) -- 部件对象的数组;请参见
GET /api/changes/(int:id)/
- GET /api/translations/(string: project)/(string: component)/(string: language)/units/¶
返回翻译单元的列表。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
q (string) -- 搜索查询字符串 搜索 (可选)
- 响应 JSON 对象:
results (array) -- 部件对象的数组;请参见
GET /api/units/(int:id)/
- POST /api/translations/(string: project)/(string: component)/(string: language)/units/¶
添加新单元。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- 请求 JSON 对象:
key (string) -- Monolingual translations: 翻译单元的密钥
value (array) -- Monolingual translations: 源字符串(如不创建复数形式,则使用单一字符串)
context (string) -- Bilingual translations: 翻译单元的上下文
source (array) -- Bilingual translations: 源字符串(如不创建复数形式,则使用单一字符串)
target (array) -- Bilingual translations: 目标字符串(如不创建复数形式,则使用单一字符串)
state (int) -- 字符串状态;见
GET /api/units/(int:id)/
- 响应 JSON 对象:
unit (object) -- 新创建的单元;请参见
GET /api/units/(int:id)/
- POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/¶
在 5.13 版本发生变更: 不再支持
filter_type参数,筛选通过q参数进行。触发自动翻译。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- 请求 JSON 对象:
mode (string) -- 自动翻译模式
q (string) -- 自动翻译搜索字符串,请参阅 搜索字符串。
auto_source (string) -- 自动翻译的来源 -
mt或otherscomponent (string) -- 为项目打开对共享翻译记忆库的贡献,以访问其他部件。
engines (array) -- 机器翻译引擎
threshold (string) -- 匹配分数阈值
- GET /api/translations/(string: project)/(string: component)/(string: language)/file/¶
下载存储在版本控制系统中的当前翻译文件(不带
format参数)或将其转换为另一格式(见 下载译文)。备注
这个 API 端点使用了不同于 API 其余的逻辑来输出,它在整个文件而不是在数据上操作。接受的
format参数组不同,没有这个参数会将翻译文件存储在版本控制系统中。- 响应标头:
Last-Modified -- 此文件上次更改的时间戳。
- 请求标头:
If-Modified-Since -- 如果此后文件未被修改过,则跳过响应。
- 查询参数:
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- POST /api/translations/(string: project)/(string: component)/(string: language)/file/¶
上传带有翻译的新文件。
- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- 表单参数:
CURL 示例:
curl -X POST \ -F file=@strings.xml \ -H "Authorization: Token TOKEN" \ http://example.com/api/translations/hello/android/cs/file/
- GET /api/translations/(string: project)/(string: component)/(string: language)/repository/¶
返回有关版本控制系统仓库状态的信息。
响应与
GET /api/components/(string:project)/(string:component)/repository/相同。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- POST /api/translations/(string: project)/(string: component)/(string: language)/repository/¶
在版本控制系统仓库上执行给定的操作。
文档请参见
POST /api/projects/(string:project)/repository/。- 参数:
project (string) -- 项目 URL 标识符
component (string) -- 部件 URL 标识符
language (string) -- 翻译语言代码
- 请求 JSON 对象:
operation (string) -- 执行的操作:
push,pull,commit,reset,cleanup之一
- 响应 JSON 对象:
result (boolean) -- 操作的结果
记忆存储¶
Added in version 4.14.
- GET /api/memory/¶
返回记忆结果列表。
- DELETE /api/memory/(int: memory_object_id)/¶
删除记忆项目
- 参数:
memory_object_id -- 内存对象 ID
单元¶
unit 是翻译的一个单一部分,它将源字符串与相应的已翻译字符串配对,还包含一些相关的元数据。该术语衍生自 Translate Toolkit 中的 translate.storage.base.TranslationUnit 和 XLFF。
- GET /api/units/¶
返回翻译单元的列表。
- 参数:
q (string) -- 搜索查询字符串 搜索 (可选)
参见
单元对象属性记录在
GET /api/units/(int:id)/。
- GET /api/units/(int: id)/¶
在 4.3 版本发生变更:
target和source现在是数组了,可以正确处理复数字符串。在 5.6 版本发生变更: 现在暴露
last_updated属性。返回有关翻译单元的信息。
- 参数:
id (int) -- 单元 ID
- 响应 JSON 对象:
translation (string) -- 相关翻译对象的 URL
source (array) -- 源字符串
previous_source (string) -- 用于模糊匹配的之前的源字符串
target (array) -- 目标字符串
id_hash (string) -- 单元的唯一标识符
content_hash (string) -- 源字符串的唯一标识符
location (string) -- 源代码中单元的位置
context (string) -- 翻译单元的上下文
note (string) -- 翻译单元的注解
flags (string) -- 翻译单元的标记
labels (array) -- 译文单元标签,在原文单元上可用
state (int) -- 单元状态,0——未翻译、10——需要编辑、20——已翻译、30——已核准、100——只读
fuzzy (boolean) -- 该单元是模糊的还是标记为需要复查
translated (boolean) -- 单元是否被翻译
approved (boolean) -- 译文是否已核准
position (int) -- 单元在翻译文件中的位次
has_suggestion (boolean) -- 单元是否有翻译建议
has_comment (boolean) -- 单元是否有评论
has_failing_check (boolean) -- 单元是否有未通过的检查
num_words (int) -- 原文单词数
priority (int) -- 翻译优先级;100为默认值
id (int) -- 单元的标识符
explanation (string) -- 字符串的解释,可在源单元获得,请参见 源字符串另外的信息
extra_flags (string) -- 另外的字符串标记,可在源单元获得,请参见 使用标记定制行为
web_url (string) -- 单元可以被编辑的 URL
source_unit (string) -- 源单元链接;请参见
GET /api/units/(int:id)/pending (boolean) -- 该单元是否待写入
timestamp (timestamp) -- 字符串添加时间
last_updated (timestamp) -- 上次字符串更新
- PATCH /api/units/(int: id)/¶
Added in version 4.3.
对翻译单元执行部分更新。
- PUT /api/units/(int: id)/¶
Added in version 4.3.
对翻译单元执行完整翻译。
- DELETE /api/units/(int: id)/¶
Added in version 4.3.
删除一个翻译单元。
- 参数:
id (int) -- 单元 ID
- GET /api/units/(int: id)/translations/¶
Added in version 5.11.
返回给定原文翻译单元的所有目标翻译单元的列表。
- POST /api/units/(int: id)/comments/¶
Added in version 5.12.
在给定翻译单元上创建新评论。
- 参数:
id (int) -- 单元 ID
- 请求 JSON 对象:
scope (string) -- 评论范围 - 全局, 翻译 (在所有非源语言单元上可用), 报告 (需要启用审核工作流程,见 专门的审校员)
comment (string) -- 新评论的内容,你可以使用 Markdown 并通过 @username 提及用户。
user_email (string) -- 评论者的电子信箱仅能由项目管理员设置且默认为经身份认证的用户。
timestamp (string) -- 评论的创建时间戳仅能由项目管理员设置且默认为“现在”。
- 响应 JSON 对象:
id (int) -- 评论标识符
comment (string) -- 新评论的内容
user (string) -- 评论者对象的 URL
timestamp (string) -- 评论的生成时间戳
- GET /api/units/(int: id)/comments/¶
Added in version 5.15.
返回给定翻译单元的评论列表
- 参数:
id (int) -- 单元 ID
- 响应 JSON 对象:
id (int) -- 评论标识符
comment (string) -- 评论内容
timestamp (string) -- 评论的生成时间戳
user (string) -- 评论者对象的 URL
变化¶
- GET /api/changes/¶
在 4.1 版本发生变更: 更改的筛选在 4.1 版本引入。
返回翻译更改的列表。
参见
更改对象属性记录在
GET /api/changes/(int:id)/。- 查询参数:
user (string) -- 筛选用户的用户名
action (int) -- 操作筛选,可以多次使用
timestamp_after (timestamp) -- ISO 8601 格式的时间戳,列出此时间之后的更改
timestamp_before (timestamp) -- ISO 8601 格式的时间戳,列出此时间之前的更改
- GET /api/changes/(int: id)/¶
返回有关翻译更改的信息。
- 参数:
id (int) -- 更改的ID
- 响应 JSON 对象:
unit (string) -- 相关单元对象的 URL
translation (string) -- 相关翻译对象的 URL
component (string) -- 相关部件对象的 URL
user (string) -- 相关用户对象的 URL
author (string) -- 相关作者对象的 URL
timestamp (timestamp) -- 事件时间戳
action (int) -- 操作的数字标识
action_name (string) -- 操作的文本描述
target (string) -- 事件更改了文本
old (string) -- 先前文本
details (object) -- 关于更改的附加详情
id (int) -- 变更的标识符
截屏¶
- GET /api/screenshots/¶
返回屏幕截图字符串信息的列表。
参见
屏幕截图对象属性记录在
GET /api/screenshots/(int:id)/。
- GET /api/screenshots/(int: id)/¶
返回有关屏幕截图的信息。
- 参数:
id (int) -- 截图 ID
- 响应 JSON 对象:
name (string) -- 屏幕截图的名称
component (string) -- 相关部件对象的 URL
file_url (string) -- 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/units (array) -- 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- GET /api/screenshots/(int: id)/file/¶
下载屏幕截图的图片。
- 参数:
id (int) -- 截图 ID
- POST /api/screenshots/(int: id)/file/¶
替换屏幕截图。
- 参数:
id (int) -- 截图 ID
- 表单参数:
file image -- 上传文件
CURL 示例:
curl -X POST \ -F image=@image.png \ -H "Authorization: Token TOKEN" \ http://example.com/api/screenshots/1/file/
- POST /api/screenshots/(int: id)/units/¶
与屏幕截图相关的源字符串。
- 参数:
id (int) -- 截图 ID
- 表单参数:
string unit_id -- 单元 ID
- 响应 JSON 对象:
name (string) -- 屏幕截图的名称
translation (string) -- 相关翻译对象的 URL
file_url (string) -- 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/units (array) -- 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- DELETE /api/screenshots/(int: id)/units/(int: unit_id)¶
删除与截图关联的源字符串。
- 参数:
id (int) -- 截图 ID
unit_id -- 源字符串单元 ID
- POST /api/screenshots/¶
新建新的屏幕截图。
- 表单参数:
file image -- 上传文件
string name -- 截图名称
string project_slug -- 项目标识串
string component_slug -- 部件标识串
string language_code -- 语言代码
- 响应 JSON 对象:
name (string) -- 屏幕截图的名称
component (string) -- 相关部件对象的 URL
file_url (string) -- 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/units (array) -- 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- PATCH /api/screenshots/(int: id)/¶
编辑截屏的部分信息。
- 参数:
id (int) -- 截图 ID
- 响应 JSON 对象:
name (string) -- 屏幕截图的名称
component (string) -- 相关部件对象的 URL
file_url (string) -- 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/units (array) -- 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- PUT /api/screenshots/(int: id)/¶
编辑截屏的完整信息。
- 参数:
id (int) -- 截图 ID
- 响应 JSON 对象:
name (string) -- 屏幕截图的名称
component (string) -- 相关部件对象的 URL
file_url (string) -- 下载文件的 URL;请参见
GET /api/screenshots/(int:id)/file/units (array) -- 与源字符串信息相关的链接;请参见
GET /api/units/(int:id)/
- DELETE /api/screenshots/(int: id)/¶
删除截图。
- 参数:
id (int) -- 截图 ID
附加组件¶
Added in version 4.4.1.
- GET /api/addons/¶
返回附加组件的列表。
参见
附加组件对象属性记录在
GET /api/addons/(int:id)/。
- GET /api/addons/(int: id)/¶
返回有关附加组件的信息。
- 参数:
id (int) -- 附加组件 ID
- 响应 JSON 对象:
name (string) -- 附加组件名称
component (string) -- 相关部件对象的 URL
configuration (object) -- 可选的附加组件配置
参见
- POST /api/components/(string: project)/(string: component)/addons/¶
创建新附加组件。
- 参数:
project_slug (string) -- 项目标识串
component_slug (string) -- 部件标识串
- 请求 JSON 对象:
name (string) -- 附加组件名称
configuration (object) -- 可选的附加组件配置
- PATCH /api/addons/(int: id)/¶
编辑附加组件的部分信息。
- 参数:
id (int) -- 附加组件 ID
- 响应 JSON 对象:
configuration (object) -- 可选的附加组件配置
- PUT /api/addons/(int: id)/¶
编辑附加组件的完整信息。
- 参数:
id (int) -- 附加组件 ID
- 响应 JSON 对象:
configuration (object) -- 可选的附加组件配置
- DELETE /api/addons/(int: id)/¶
删除附加组件。
- 参数:
id (int) -- 附加组件 ID
部件列表¶
Added in version 4.0.
- GET /api/component-lists/¶
返回一个部件列表的列表。
参见
部件列表对象属性记录在
GET /api/component-lists/(str:slug)/。
- GET /api/component-lists/(str: slug)/¶
返回部件列表的信息。
- 参数:
slug (string) -- 部件列表的标识串
- 响应 JSON 对象:
name (string) -- 部件列表的名称
slug (string) -- 部件列表的表示串
show_dashboard (boolean) -- 是否在操作面板上显示
components (array) -- 相关联部件的连接;请参见
GET /api/components/(string:project)/(string:component)/auto_assign (array) -- 自动分配规则
- PUT /api/component-lists/(str: slug)/¶
更改部件列表参数。
- 参数:
slug (string) -- 部件列表的标识串
- 请求 JSON 对象:
name (string) -- 部件列表的名称
slug (string) -- 部件列表的表示串
show_dashboard (boolean) -- 是否在操作面板上显示
- PATCH /api/component-lists/(str: slug)/¶
更改部件列表参数。
- 参数:
slug (string) -- 部件列表的标识串
- 请求 JSON 对象:
name (string) -- 部件列表的名称
slug (string) -- 部件列表的表示串
show_dashboard (boolean) -- 是否在操作面板上显示
- DELETE /api/component-lists/(str: slug)/¶
删除部件列表。
- 参数:
slug (string) -- 部件列表的标识串
- GET /api/component-lists/(str: slug)/components/¶
Added in version 5.0.1: 列出部件列表中的部件。
- 参数标识串:
部件列表的标识串
- type slug:
字符串
- 从字符串 component_id:
部件 ID
- >json array results:
部件对象的数组;请参见
GET /api/components/(string:project)/(string:component)/
- POST /api/component-lists/(str: slug)/components/¶
使部件与部件列表相关。
- 参数:
slug (string) -- 部件列表的标识串
- 表单参数:
string component_id -- 部件 ID
- DELETE /api/component-lists/(str: slug)/components/(str: component_slug)¶
取消部件与部件列表的关联。
- 参数:
slug (string) -- 部件列表的标识串
component_slug (string) -- 部件标识串
术语表¶
在 4.5 版本发生变更: 术语表现在存储为常规部件、翻译和字符串,请改用相应的 API。
任务¶
Added in version 4.4.
- GET /api/tasks/¶
任务列表当前不可用。
- GET /api/tasks/(str: uuid)/¶
返回任务信息。
- 参数:
uuid (string) -- 任务 UUID
- 响应 JSON 对象:
completed (boolean) -- 任务是否已完成
progress (int) -- 任务进度百分比
result (object) -- 任务结果或过程细节
log (string) -- 任务日志
统计信息¶
- GET /api/(str: object)/statistics/¶
有几个对象的统计端点,所有端点包含相同的结构。
- 参数:
object (string) -- URL 路径
- 响应 JSON 对象:
total (int) -- 字符串的总数
total_words (int) -- 词的总数
total_chars (int) -- 总字符数
last_change (timestamp) -- 最后一次更改的日期
translated (int) -- 已翻译字符串的数量
translated_percent (float) -- 已翻译字符串的百分比
translated_words (int) -- 已翻译词的数量
translated_words_percent (float) -- 已翻译词的百分比
translated_chars (int) -- 已翻译字符的数量
translated_chars_percent (float) -- 已翻译字符的百分比
fuzzy (int) -- 模糊(标记为需要编辑)字符串的数量
fuzzy_words (int) -- 模糊(标记为需要编辑)的单词数
fuzzy_chars (int) -- 模糊(标记为需要编辑)的字符串数量
fuzzy_percent (float) -- 模糊字符串(标记为需要编辑)的百分比
fuzzy_words_percent (float) -- 模糊单词(标记为需要编辑)的百分比
fuzzy_chars_percent (float) -- 模糊字符(标记为需要编辑)的百分比
failing (int) -- 未通过检查的数量
failing_percent (float) -- 未通过检查的百分比
approved (int) -- 已批准字符串的数目
approved_words (int) -- 已批准的单词数
approved_chars (int) -- 已批准的字符数
approved_percent (float) -- 已批准的字符串所占比例
approved_words_percent (float) -- 已批准的单词所占百分比
approved_chars_percent (float) -- 已批准的字符所占百分比
readonly (int) -- 只读字符串的数目
readonly_words (int) -- 只读单词的数目
readonly -- 只读字符的数量
readonly_percent (float) -- 只读字符串所占比例
readonly_words_percent (float) -- 只读单词所占百分比
readonly_char_percent (float) -- 只读字符的百分比
suggestions (int) -- 带建议的字符串数量
comments (int) -- 带评论的字符串数量
name (string) -- 对象名称
url (string) -- 访问对象的 URL(如果适用)
url_translate (string) -- 访问翻译的 URL(如果适用)
code (string) -- 语言代码(如果适用)
指标¶
- GET /api/metrics/¶
返回服务器指标。
在 5.6.1 版本发生变更: 通过
?format=openmetrics现在可以用兼容 OpenMetrics 的格式暴露 Metrics 了。- 响应 JSON 对象:
units (int) -- 单元数量
units_translated (int) -- 已翻译单元数量
users (int) -- 用户数量
changes (int) -- 更改次数
projects (int) -- 项目数量
components (int) -- 部件数量
translations (int) -- 翻译数量
languages (int) -- 所用语言数量
checks (int) -- 触发的质量检查数
configuration_errors (int) -- 配置错误的数量
suggestions (int) -- 待处理建议数量
celery_queues (object) -- Celery 队列长度,见 使用 Celery 的后台任务
name (string) -- 配置的服务器名
搜索¶
- GET /api/search/¶
Added in version 4.18.
以列表形式返回全站搜索结果。结果集不分页,每个分类仅返回前几个匹配项。
搜索查找:
项目
类别
部件
语言
用户
- 参数:
q -- 搜索查询字符串
- 响应 JSON 对象:
name (str) -- 匹配项的名称。
url (str) -- 匹配项的 Web URL。
category (str) -- 匹配项类别。
类别¶
- GET /api/categories/¶
Added in version 5.0.
列出可用的类别。字段定义见
GET /api/categories/(int:id)/.
- POST /api/categories/¶
Added in version 5.0.
创建新类别。字段定义见
GET /api/categories/(int:id)/.
- GET /api/categories/(int: id)/¶
Added in version 5.0.
- 参数:
id (int) -- 类别 ID
- 响应 JSON 对象:
name (str) -- 类别名。
slug (str) -- 类别标识符。
project (str) -- 项目链接。
category (str) -- 主类别链接。
- PATCH /api/categories/(int: id)/¶
Added in version 5.0: 编辑分类的部分信息。
- 参数 id:
类别 ID
- 类型 id:
int
- >json object configuration:
可选的分类配置
- PUT /api/categories/(int: id)/¶
Added in version 5.0: 编辑分类的完整信息。
- 参数 id:
类别 ID
- 类型 id:
int
- >json object configuration:
可选的分类配置
- DELETE /api/categories/(int: id)/¶
Added in version 5.0: 删除分类。
- 参数 id:
类别 ID
- 类型 id:
int
通知钩子¶
通知钩子允许外部应用来通知 Weblate 版本控制系统仓库已经更新。
可以为项目、部件和翻译使用仓库端点来更新各自的仓库;文档请参见 POST /api/projects/(string:project)/repository/。
- GET /hooks/update/(string: project)/(string: component)/¶
自 2.6 版本弃用: 请使用
POST /api/components/(string:project)/(string:component)/repository/来替代,它使用 ACL 限制的身份认证而工作正常。Removed in version 5.14.
- GET /hooks/update/(string: project)/¶
自 2.6 版本弃用: 请使用
POST /api/projects/(string:project)/repository/来替代,它使用 ACL 限制的身份认证而工作正常。Removed in version 5.14.
- POST /hooks/github/¶
处理 GitHub 通知与自动更新匹配部件的特殊钩子。
备注
GitHub 包括了对通知 Weblate 的直接支持:在仓库设置中启动 Weblate 服务钩子,并将 URL 设置为你的 Weblate 安装的 URL。
参见
- 从 GitHub 自动接收更改
关于设置 GitHub 集成的指令
- https://docs.github.com/en/get-started/customizing-your-github-workflow/exploring-integrations/about-webhooks
GitHub Webhooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
- POST /hooks/gitlab/¶
处理 GitLab 通知并自动更新匹配部件的特殊钩子。
参见
- 从 GitLab 自动接收更改
关于设置 GitLab 集成的指示
- https://docs.gitlab.com/user/project/integrations/webhooks/
关于 GitLab Webhooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
- POST /hooks/bitbucket/¶
处理 Bitbucket 通知并自动更新匹配的部件的特殊钩子。
参见
- 从 Bitbucket 自动接收更改
关于设置 Bitbucket 集成的指示
- https://support.atlassian.com/bitbucket-cloud/docs/manage-webhooks/
关于 Bitbucket Webhooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
- POST /hooks/pagure/¶
处理 Pagure 通知并自动更新匹配的部件的特殊钩子。
参见
- 从 Pagure 自动接受更改
关于设置 Pagure 集成的指示
- https://docs.pagure.org/pagure/usage/using_webhooks.html
关于 Pagure Webhooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
- POST /hooks/azure/¶
处理 Azure DevOps 通知并自动更新匹配的部件的特殊钩子。
备注
请确保 Resource details to send 设置为 All,否则 Weblate 将无法匹配你的 Azure 仓库。
参见
- 从 Azure Repos 自动接收更改
关于设置 Azure 集成的指示
- https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops
关于 Azure DevOps Web Hooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
- POST /hooks/gitea/¶
处理 Gitea Webhook 通知并自动更新匹配的部件的特殊钩子。
参见
- 从 Gitea Repos 自动接收更改
关于设置 Gitea 集成的指示
- https://docs.gitea.io/en-us/webhooks/
关于 Gitea Webhooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
- POST /hooks/gitee/¶
处理 Gitee Webhook 通知并自动更新匹配的部件的特殊钩子。
参见
- 从 Gitee Repos 自动接收更改
关于设置 Gitee 集成的指示
- https://gitee.com/help/categories/40
关于 Gitee Webhooks 的一般信息
ENABLE_HOOKS关于对整个 Weblate 启动钩子
RSS 订阅源¶
翻译的变更会导出到 RSS 订阅源中。
- GET /exports/rss/(string: project)/(string: component)/(string: language)/¶
返回带有翻译近期变更的 RSS 订阅源。
- GET /exports/rss/(string: project)/(string: component)/¶
返回带有部件近期变更的 RSS 订阅源。
- GET /exports/rss/(string: project)/¶
返回带有项目近期变更的 RSS 订阅源。
- GET /exports/rss/language/(string: language)/¶
返回带有语言近期变更的 RSS 订阅源。
- GET /exports/rss/¶
返回带有 Weblate 实例近期变更的 RSS 订阅源。
参见