Weblate 的 REST API¶
2.6 新版功能: 从 Weblate 2.6 开始可以使用 REST API。
API 可以在 /api/
URL上访问,并且它基于 Django REST framework。你可以直接使用或参考 Weblate 客户端。
身份验证和通用参数¶
公共项目 API 不需要身份验证就可用,尽管没有身份验证的请求导致严重的瓶颈(默认每天 100 个请求),所以推荐使用身份验证。身份验证使用令牌,这可以在你的简介中得到。在 Authorization
标头中使用它:
-
ANY
/
¶ 对于 API的普通请求行为,标头、状态编码和参数在这里也应用于所有端点。
- 查询参数
format – 响应格式(否决了 Accept)。可能的值依赖于 REST 框架设置,默认支持
json
和api
。后者为 API 提供了 web 浏览器接口。
- 请求标头
Authorization – 进行身份验证的可选令牌
- 响应标头
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 – 当请求被正确地处理时
400 Bad Request – 当缺少表格参数时
403 Forbidden – 当访问被拒绝时
429 Too Many Requests – 当出现瓶颈时
身份验证的例子¶
示例请求:
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/
频次限制¶
这个 API 请求限制了速率;对于匿名用户默认配置限制为每天 100 个请求,对于身份验证的用户限制为每小时 5000 个请求。
速率限制可以在 settings.py
中调整;如何配置它的更多细节请参见 Throttling in Django REST framework documentation 。
速率限制在后面的标头中报告:
|
要执行的对速率限制进行限制的请求 |
|
保持限制的请求 |
|
直到速率限制窗口重置时的秒数 |
在 4.1 版更改: 添加速率限制状态的标头。
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/" }
用户¶
4.0 新版功能.
-
GET
/api/users/
¶ 返回用户列表,如果有权限查看管理用户的话。如果没有,那么会只看到自己的具体信息。
参见
用户对象属性被归档在
GET /api/users/(str:username)/
。
-
POST
/api/users/
¶ 创建新用户。
- 参数
username (string) – 用户名
full_name (string) – 用户全名
email (string) – 用户电子邮箱
is_superuser (boolean) – 用户是超级用户吗?(可选的)
is_active (boolean) – 用户是活动用户吗?(可选的)
-
GET
/api/users/
(str: username)/
¶ 返回用户的信息。
- 参数
username (string) – 用户的用户名
- 响应 JSON 对象
username (string) – 用户的用户名
full_name (string) – 用户的全名
email (string) – 用户的电子邮箱
is_superuser (boolean) – 用户是否是超级用户
is_active (boolean) – 用户是否是活动用户
date_joined (string) – 创建用户的日期
groups (array) – 连接到关联的组;请参见
GET /api/groups/(int:id)/
示例 JSON 数据:
{ "email": "user@example.com", "full_name": "Example User", "username": "exampleusername", "groups": [ "http://example.com/api/groups/2/", "http://example.com/api/groups/3/" ], "is_superuser": true, "is_active": true, "date_joined": "2020-03-29T18:42:42.617681Z", "url": "http://example.com/api/users/exampleusername/", "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) – 用户是否是活动用户
date_joined (string) – 创建用户的日期
-
PATCH
/api/users/
(str: username)/
¶ 更改用户参数。
- 参数
username (string) – 用户的用户名
- 响应 JSON 对象
username (string) – 用户的用户名
full_name (string) – 用户的全名
email (string) – 用户的电子邮箱
is_superuser (boolean) – 用户是否是超级用户
is_active (boolean) – 用户是否是活动用户
date_joined (string) – 创建用户的日期
-
DELETE
/api/users/
(str: username)/
¶ 删除所有的用户信息并将用户标记为不活动用户。
- 参数
username (string) – 用户的用户名
-
POST
/api/users/
(str: username)/groups/
¶ 将群组与用户关联。
- 参数
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)/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
群组¶
4.0 新版功能.
-
GET
/api/groups/
¶ 返回群组列表,如果有权限看到管理群组的话,如果没有,那么会只看到用户所在的群组。
参见
群组对象属性归档在
GET /api/groups/(int:id)/
。
-
POST
/api/groups/
¶ 创建新的群组。
- 参数
name (string) – 组名
project_selection (int) – 给定选项的项目选择的群组
language_selection (int) – 给定选项的语言选择的群组
-
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)/
componentlist (array) – 相关联组件列表的连接;请参见
GET /api/component-lists/(str:slug)/
示例 JSON 数据:
{ "name": "Guests", "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/" ] }
-
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
-
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
角色¶
-
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) – 语言方向
plural (object) – 语言复数形式与数字
-
GET
/api/languages/
(string: language)/
¶ 返回语言的信息。
- 参数
language (string) – 语言代码
- 响应 JSON 对象
code (string) – 语言代码
direction (string) – 文字方向
plural (object) – 语言复数信息的对象
aliases (array) – 语言别名的数组
示例 JSON 数据:
{ "code": "en", "direction": "ltr", "name": "English", "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) – 语言方向
plural (object) – 语言复数的细节
-
PATCH
/api/languages/
(string: language)/
¶ 更改语言参数。
- 参数
language (string) – 语言的编码
- 请求 JSON 对象
name (string) – 语言名称
direction (string) – 语言方向
plural (object) – 语言复数的细节
-
DELETE
/api/languages/
(string: language)/
¶ 删除语言。
- 参数
language (string) – 语言的编码
-
GET
/api/languages/
(string: language)/statistics/
¶ 返回语言的统计。
- 参数
language (string) – 语言代码
- 响应 JSON 对象
total (int) – 字符串的总数
total_words (int) – 词的总数
last_change (timestamp) – 语言的上一次更改
recent_changes (int) – 更改的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
translated_words (int) – 已翻译词的数量
translated_words_percent (int) – 已翻译词的百分比
translated_chars (int) – 已翻译字符的数量
translated_chars_percent (int) – 已翻译字符的百分比
total_chars (int) – 总字符的数量
fuzzy (int) – 模糊字符串的数量
fuzzy_percent (int) – 模糊字符串的百分比
failing (int) – 失败字符串的数量
failing – 失败字符串的百分比
项目¶
-
GET
/api/projects/
¶ 返回所有项目的列表。
参见
项目对象的属性存档在
GET /api/projects/(string:project)/
。
-
POST
/api/projects/
¶ 3.9 新版功能.
创建新项目。
- 参数
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)/repository/
示例 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)/
¶ 4.3 新版功能.
通过补丁请求来编辑项目。
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
-
PUT
/api/projects/
(string: project)/
¶ 4.3 新版功能.
通过推送请求来编辑项目。
- 参数
project (string) – 项目 URL 标识串
-
DELETE
/api/projects/
(string: project)/
¶ 3.9 新版功能.
删除项目。
- 参数
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)/repository/
¶ 返回版本控制系统(VCS)仓库状态的信息。这个端点只包含项目所有仓库的整体概况。为了得到更多细节,请使用
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/
¶ 在版本控制系统(VCS)仓库上执行给定的操作。
- 参数
project (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/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/
¶ 3.9 新版功能.
在 4.3 版更改: 现在对于没有版本控制系统(VCS)的组件接受参数
zipfile
和docfile
,请参见 Local files。Creates translation components in the given project.
- 参数
project (string) – 项目 URL 标识串
- 请求 JSON 对象
zipfile (file) – ZIP file to upload into Weblate for translations initialization
docfile (file) – 要翻译的文档
- 响应 JSON 对象
result (object) – Created component object; see
GET /api/components/(string:project)/(string:component)/
CURL 示例:
curl \ --data-binary '{ "branch": "master", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "vcs": "git" }' \ -H "Content-Type: application/json" \ -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 { "branch": "master", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "repo": "file:///home/nijel/work/weblate-hello", "template": "", "new_base": "", "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": "master", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "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/
¶ Returns paginated statistics for all languages within a project.
3.8 新版功能.
- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
results (array) – array of translation statistics objects
language (string) – language name
code (string) – language code
total (int) – 字符串的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
total_words (int) – 词的总数
translated_words (int) – 已翻译词的数量
words_percent (float) – 已翻译词的百分比
-
GET
/api/projects/
(string: project)/statistics/
¶ Returns statistics for a project.
3.8 新版功能.
- 参数
project (string) – 项目 URL 标识串
- 响应 JSON 对象
total (int) – 字符串的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
total_words (int) – 词的总数
translated_words (int) – 已翻译词的数量
words_percent (float) – 已翻译词的百分比
组件¶
-
GET
/api/components/
¶ Returns a list of translation components.
参见
Component object attributes are documented at
GET /api/components/(string:project)/(string:component)/
.
-
GET
/api/components/
(string: project)/
(string: component)/
¶ Returns information about translation component.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
project (object) – the translation project; see
GET /api/projects/(string:project)/
name (string) – 组件名称
slug (string) – 组件标识串
vcs (string) – 版本控制系统
repo (string) – 源代码库
git_export (string) – 已导出代码库 URL
branch (string) – 仓库分支
push_branch (string) – 推送分支
filemask (string) – 文件掩码
template (string) – 单语言译文模版语言文件
edit_template (string) – 编辑译文模版文件
intermediate (string) – 中间语言文件
new_base (string) – 新翻译的译文模版
file_format (string) – 文件格式
license (string) – 翻译许可证
agreement (string) – 贡献者协议
new_lang (string) – 添加新翻译
language_code_style (string) – 语言代码风格
source_language (object) – source language object; see
GET /api/languages/(string:language)/
push (string) – 代码库推送 URL
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) – 提交、添加、删除、合并以及插件消息
allow_translation_propagation (string) – 允许同步翻译
enable_suggestions (string) – 启用建议
suggestion_voting (string) – 建议投票
suggestion_autoaccept (string) – 自动接受建议
push_on_commit (string) – 提交时推送
commit_pending_age (string) – 对变更进行提交的延时时间
auto_lock_error (string) – 出错时锁定
language_regex (string) – 语言筛选
variant_regex (string) – 正则表达式变体
repository_url (string) – URL to repository status; see
GET /api/components/(string:project)/(string:component)/repository/
translations_url (string) – URL to translations list; see
GET /api/components/(string:project)/(string:component)/translations/
lock_url (string) – URL to lock status; see
GET /api/components/(string:project)/(string:component)/lock/
changes_list_url (string) – URL to changes list; see
GET /api/components/(string:project)/(string:component)/changes/
示例 JSON 数据:
{ "branch": "master", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "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", "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)/
¶ Edit a component by a patch request.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
source_language (string) – Project source language code (optional)
- 请求 JSON 对象
name (string) – name of component
slug (string) – slug of component
repo (string) – VCS repository 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": "master", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "new name", "slug": "weblate", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "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)/
¶ Edit a component by a put request.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
branch (string) – VCS repository branch
file_format (string) – file format of translations
filemask (string) – mask of translation files in the repository
name (string) – name of component
slug (string) – slug of component
repo (string) – VCS repository URL
template (string) – base file for monolingual translations
new_base (string) – base file for adding new translations
vcs (string) – version control system
-
DELETE
/api/components/
(string: project)/
(string: component)/
¶ 3.9 新版功能.
Deletes a component.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
-
GET
/api/components/
(string: project)/
(string: component)/changes/
¶ Returns a list of component changes. This is essentially a component scoped
GET /api/changes/
accepting same params.- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/changes/(int:id)/
-
GET
/api/components/
(string: project)/
(string: component)/screenshots/
¶ Returns a list of component screenshots.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – array of component screenshots; see
GET /api/screenshots/(int:id)/
-
GET
/api/components/
(string: project)/
(string: component)/lock/
¶ Returns component lock status.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
locked (boolean) – whether component is locked for updates
示例 JSON 数据:
{ "locked": false }
-
POST
/api/components/
(string: project)/
(string: component)/lock/
¶ Sets component lock status.
Response is same as
GET /api/components/(string:project)/(string:component)/lock/
.- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
lock – Boolean whether to lock or not.
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/
¶ Returns information about VCS repository status.
The response is same as for
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) – Remote commit information
status (string) – VCS repository status as reported by VCS
merge_failure – Text describing merge failure or null if there is none
-
POST
/api/components/
(string: project)/
(string: component)/repository/
¶ Performs the given operation on a VCS repository.
See
POST /api/projects/(string:project)/repository/
for documentation.- 参数
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/
¶ Downloads base file for monolingual translations.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
-
GET
/api/components/
(string: project)/
(string: component)/new_template/
¶ Downloads template file for new translations.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
-
GET
/api/components/
(string: project)/
(string: component)/translations/
¶ Returns a list of translation objects in the given component.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – array of translation objects; see
GET /api/translations/(string:project)/(string:component)/(string:language)/
-
POST
/api/components/
(string: project)/
(string: component)/translations/
¶ Creates new translation in the given component.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 请求 JSON 对象
language_code (string) – translation language code; see
GET /api/languages/(string:language)/
- 响应 JSON 对象
result (object) – new translation object created
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", "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/
¶ Returns paginated statistics for all translations within component.
2.7 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
- 响应 JSON 对象
results (array) – array of translation statistics objects; see
GET /api/translations/(string:project)/(string:component)/(string:language)/statistics/
翻译¶
-
GET
/api/translations/
¶ Returns a list of translations.
参见
Translation object attributes are documented at
GET /api/translations/(string:project)/(string:component)/(string:language)/
.
-
GET
/api/translations/
(string: project)/
(string: component)/
(string: language)/
¶ Returns information about a translation.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 响应 JSON 对象
component (object) – component object; see
GET /api/components/(string:project)/(string:component)/
failing_checks (int) – 未通过检查的字符串数目
failing_checks_percent (float) – 未通过检查的字符串比重
failing_checks_words (int) – 未通过检查的单词数目
filename (string) – translation filename
fuzzy (int) – number of strings marked for review
fuzzy_percent (float) – percentage of strings marked for review
fuzzy_words (int) – number of words marked for review
have_comment (int) – number of strings with comment
have_suggestion (int) – number of strings with suggestion
is_template (boolean) – 译文是否有单语基础
language (object) – source language object; see
GET /api/languages/(string:language)/
language_code (string) – language code used in the repository; this can be different from language code in the language object
last_author (string) – name of last author
last_change (timestamp) – last change timestamp
revision (string) – revision hash for the file
share_url (string) – URL for sharing leading to engagement page
total (int) – 字符串的总数
total_words (int) – 词的总数
translate_url (string) – URL for translating
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
translated_words (int) – 已翻译词的数量
repository_url (string) – URL to repository status; see
GET /api/translations/(string:project)/(string:component)/(string:language)/repository/
file_url (string) – URL to file object; see
GET /api/translations/(string:project)/(string:component)/(string:language)/file/
changes_list_url (string) – URL to changes list; see
GET /api/translations/(string:project)/(string:component)/(string:language)/changes/
units_list_url (string) – URL to strings list; see
GET /api/translations/(string:project)/(string:component)/(string:language)/units/
示例 JSON 数据:
{ "component": { "branch": "master", "file_format": "po", "filemask": "po/*.po", "git_export": "", "license": "", "license_url": "", "name": "Weblate", "new_base": "", "project": { "name": "Hello", "slug": "hello", "source_language": { "code": "en", "direction": "ltr", "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", "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)/
¶ 3.9 新版功能.
Deletes a translation.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
-
GET
/api/translations/
(string: project)/
(string: component)/
(string: language)/changes/
¶ Returns a list of translation changes. This is essentially a translations-scoped
GET /api/changes/
accepting the same parameters.- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 响应 JSON 对象
results (array) – 组件对象的矩阵;请参见
GET /api/changes/(int:id)/
-
GET
/api/translations/
(string: project)/
(string: component)/
(string: language)/units/
¶ Returns a list of translation units.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
q (string) – Search query string Searching (optional)
- 响应 JSON 对象
results (array) – array of component objects; see
GET /api/units/(int:id)/
-
POST
/api/translations/
(string: project)/
(string: component)/
(string: language)/units/
¶ Add new monolingual unit.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 请求 JSON 对象
key (string) – Name of translation unit
value (string) – The translation unit value
-
POST
/api/translations/
(string: project)/
(string: component)/
(string: language)/autotranslate/
¶ Trigger automatic translation.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 请求 JSON 对象
mode (string) – 自动翻译模式
filter_type (string) – Automatic translation filter type
auto_source (string) – 自动翻译来源
component (string) – 为项目打开对共享翻译记忆库的贡献,以访问其他组件。
engines (string) – 机器翻译引擎
threshold (string) – 匹配分数阈值
-
GET
/api/translations/
(string: project)/
(string: component)/
(string: language)/file/
¶ Download current translation file as stored in VCS (without
format
parameter) or as converted to a standard format (currently supported: Gettext PO, MO, XLIFF and TBX).注解
This API endpoint uses different logic for output than rest of API as it operates on whole file rather than on data. Set of accepted
format
parameter differs and without such parameter you get translation file as stored in VCS.- 查询参数
format – File format to use; if not specified no format conversion happens; supported file formats:
po
,mo
,xliff
,xliff11
,tbx
,csv
,xlsx
,json
,aresource
,strings
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
-
POST
/api/translations/
(string: project)/
(string: component)/
(string: language)/file/
¶ Upload new file with translations.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 表格参数
string conflicts – How to deal with conflicts (
ignore
,replace-translated
orreplace-approved
)file file – Uploaded file
string email – 作者邮箱
string author – 作者姓名
string method – Upload method (
translate
,approve
,suggest
,fuzzy
,replace
,source
), see Import methodsstring fuzzy – Fuzzy strings processing (empty,
process
,approve
)
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/
¶ Returns information about VCS repository status.
The response is same as for
GET /api/components/(string:project)/(string:component)/repository/
.- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
-
POST
/api/translations/
(string: project)/
(string: component)/
(string: language)/repository/
¶ 在版本控制系统(VCS)仓库上执行给定的操作。
See
POST /api/projects/(string:project)/repository/
for documentation.- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 请求 JSON 对象
operation (string) – 执行的操作:
push
,pull
,commit
,reset
, ``cleanup``之一
- 响应 JSON 对象
result (boolean) – 操作的结果
-
GET
/api/translations/
(string: project)/
(string: component)/
(string: language)/statistics/
¶ Returns detailed translation statistics.
2.7 新版功能.
- 参数
project (string) – 项目 URL 标识串
component (string) – 组件 URL 标识串
language (string) – Translation language code
- 响应 JSON 对象
code (string) – language code
failing (int) – number of failing checks
failing_percent (float) – percentage of failing checks
fuzzy (int) – number of strings needing review
fuzzy_percent (float) – percentage of strings needing review
total_words (int) – 词的总数
translated_words (int) – 已翻译词的数量
last_author (string) – name of last author
last_change (timestamp) – date of last change
name (string) – language name
total (int) – 字符串的总数
translated (int) – 已翻译的字符串数量
translated_percent (float) – 已翻译字符串的百分比
url (string) – URL to access the translation (engagement URL)
url_translate (string) – URL to access the translation (real translation URL)
Units¶
2.10 新版功能.
-
GET
/api/units/
¶ Returns list of translation units.
参见
Unit object attributes are documented at
GET /api/units/(int:id)/
.
-
GET
/api/units/
(int: id)/
¶ 在 4.3 版更改: The
target
andsource
are now arrays to properly handle plural strings.Returns information about translation unit.
- 参数
id (int) – Unit ID
- 响应 JSON 对象
translation (string) – URL of a related translation object
source (array) – source string
previous_source (string) – previous source string used for fuzzy matching
target (array) – target string
id_hash (string) – unique identifier of the unit
content_hash (string) – unique identifier of the source string
location (string) – location of the unit in source code
context (string) – translation unit context
note (string) – translation unit note
flags (string) – translation unit flags
state (int) – unit state, 0 - not translated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read only
fuzzy (boolean) – 是否该单元是模糊的或标记为需要检查
translated (boolean) – 单元是否被翻译
approved (boolean) – 翻译是否被核准
position (int) – unit position in translation file
has_suggestion (boolean) – 单元是否有翻译建议
has_comment (boolean) – 单元是否有注释
has_failing_check (boolean) – 单元是否有未通过检查的翻译
num_words (int) – number of source words
priority (int) – translation priority; 100 is default
id (int) – unit identifier
explanation (string) – String explanation, available on source units, see 源字符串另外的信息
extra_flags (string) – Additional string flags, available on source units, see 定制行为
web_url (string) – URL where the unit can be edited
souce_unit (string) – Source unit link; see
GET /api/units/(int:id)/
-
PATCH
/api/units/
(int: id)/
¶ 4.3 新版功能.
对翻译单元执行部分更新。
- 参数
id (int) – Unit ID
- 请求 JSON 对象
state (int) – unit state, 0 - not translated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read only
target (array) – target string
explanation (string) – String explanation, available on source units, see 源字符串另外的信息
extra_flags (string) – Additional string flags, available on source units, see 定制行为
-
PUT
/api/units/
(int: id)/
¶ 4.3 新版功能.
对翻译单元执行完整翻译。
- 参数
id (int) – Unit ID
- 请求 JSON 对象
state (int) – unit state, 0 - not translated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read only
target (array) – target string
explanation (string) – String explanation, available on source units, see 源字符串另外的信息
extra_flags (string) – Additional string flags, available on source units, see 定制行为
-
DELETE
/api/units/
(int: id)/
¶ 4.3 新版功能.
删除一个翻译单元。
- 参数
id (int) – Unit ID
修改¶
2.10 新版功能.
-
GET
/api/changes/
¶ 在 4.1 版更改: Filtering of changes was introduced in the 4.1 release.
Returns a list of translation changes.
参见
Change object attributes are documented at
GET /api/changes/(int:id)/
.- 查询参数
user (string) – Username of user to filters
action (int) – Action to filter, can be used several times
timestamp_after (timestamp) – ISO 8601 formatted timestamp to list changes after
timestamp_before (timestamp) – ISO 8601 formatted timestamp to list changes before
-
GET
/api/changes/
(int: id)/
¶ Returns information about translation change.
- 参数
id (int) – Change ID
- 响应 JSON 对象
unit (string) – URL of a related unit object
translation (string) – URL of a related translation object
component (string) – URL of a related component object
glossary_term (string) – URL of a related glossary term object
user (string) – URL of a related user object
author (string) – URL of a related author object
timestamp (timestamp) – event timestamp
action (int) – numeric identification of action
action_name (string) – text description of action
target (string) – event changed text or detail
id (int) – change identifier
截图¶
2.14 新版功能.
-
GET
/api/screenshots/
¶ Returns a list of screenshot string information.
参见
Screenshot object attributes are documented at
GET /api/screenshots/(int:id)/
.
-
GET
/api/screenshots/
(int: id)/
¶ Returns information about screenshot information.
- 参数
id (int) – Screenshot ID
- 响应 JSON 对象
name (string) – name of a screenshot
component (string) – URL of a related component object
file_url (string) – URL to download a file; see
GET /api/screenshots/(int:id)/file/
units (array) – link to associated source string information; see
GET /api/units/(int:id)/
-
GET
/api/screenshots/
(int: id)/file/
¶ Download the screenshot image.
- 参数
id (int) – Screenshot ID
-
POST
/api/screenshots/
(int: id)/file/
¶ Replace screenshot image.
- 参数
id (int) – Screenshot ID
- 表格参数
file image – Uploaded file
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/
¶ Associate source string with screenshot.
- 参数
id (int) – Screenshot ID
- 表格参数
string unit_id – Unit ID
- 响应 JSON 对象
name (string) – name of a screenshot
translation (string) – URL of a related translation object
file_url (string) – URL to download a file; see
GET /api/screenshots/(int:id)/file/
units (array) – link to associated source string information; see
GET /api/units/(int:id)/
-
DELETE
/api/screenshots/
(int: id)/units/
(int: unit_id)¶ 删除与截图关联的源字符串。
- 参数
id (int) – Screenshot ID
unit_id – 源字符串单元 ID
-
POST
/api/screenshots/
¶ Creates a new screenshot.
- 表格参数
file image – Uploaded file
string name – 截图名称
string project_slug – 项目标识串
string component_slug – 组件标识串
string language_code – 语言代码
- 响应 JSON 对象
name (string) – name of a screenshot
component (string) – URL of a related component object
file_url (string) – URL to download a file; see
GET /api/screenshots/(int:id)/file/
units (array) – link to associated source string information; see
GET /api/units/(int:id)/
-
PATCH
/api/screenshots/
(int: id)/
¶ 编辑截屏的部分信息。
- 参数
id (int) – Screenshot ID
- 响应 JSON 对象
name (string) – name of a screenshot
component (string) – URL of a related component object
file_url (string) – URL to download a file; see
GET /api/screenshots/(int:id)/file/
units (array) – link to associated source string information; see
GET /api/units/(int:id)/
-
PUT
/api/screenshots/
(int: id)/
¶ 编辑截屏的完整信息。
- 参数
id (int) – Screenshot ID
- 响应 JSON 对象
name (string) – name of a screenshot
component (string) – URL of a related component object
file_url (string) – URL to download a file; see
GET /api/screenshots/(int:id)/file/
units (array) – link to associated source string information; see
GET /api/units/(int:id)/
-
DELETE
/api/screenshots/
(int: id)/
¶ 删除截图。
- 参数
id (int) – Screenshot ID
组件列表¶
4.0 新版功能.
-
GET
/api/component-lists/
¶ Returns a list of component lists.
参见
Component list object attributes are documented at
GET /api/component-lists/(str:slug)/
.
-
GET
/api/component-lists/
(str: slug)/
¶ Returns information about component list.
- 参数
slug (string) – Component list slug
- 响应 JSON 对象
name (string) – name of a component list
slug (string) – slug of a component list
show_dashboard (boolean) – whether to show it on a dashboard
components (array) – 相关联组件的连接;请参见
GET /api/components/(string:project)/(string:component)/
auto_assign (array) – automatic assignment rules
-
PUT
/api/component-lists/
(str: slug)/
¶ Changes the component list parameters.
- 参数
slug (string) – Component list slug
- 请求 JSON 对象
name (string) – name of a component list
slug (string) – slug of a component list
show_dashboard (boolean) – whether to show it on a dashboard
-
PATCH
/api/component-lists/
(str: slug)/
¶ Changes the component list parameters.
- 参数
slug (string) – Component list slug
- 请求 JSON 对象
name (string) – name of a component list
slug (string) – slug of a component list
show_dashboard (boolean) – whether to show it on a dashboard
-
DELETE
/api/component-lists/
(str: slug)/
¶ Deletes the component list.
- 参数
slug (string) – Component list slug
-
POST
/api/component-lists/
(str: slug)/components/
¶ Associate component with a component list.
- 参数
slug (string) – Component list slug
- 表格参数
string component_id – Component ID
-
DELETE
/api/component-lists/
(str: slug)/components/
(str: component_slug)¶ Disassociate a component from the component list.
- 参数
slug (string) – Component list slug
component_slug (string) – 组件标识串
词汇表¶
-
GET
/api/glossary/
¶ Returns a list of all glossaries which are associated with a project that user has access to.
参见
语言对象属性存档在
GET /api/languages/(string:language)/
。
-
GET
/api/glossary/
(int: id)/
¶ 返回关于一条词汇表的信息。
- 参数
id (int) – 词汇表 id
- 响应 JSON 对象
name (string) – 语言代码
color (string) – 文字方向
source_language (object) – 语言复数信息的对象
projects (array) – 相关联项目的连接;请参见
GET /api/projects/(string:project)/
示例 JSON 数据:
{ "name": "Hello", "id": 1, "color": "silver", "source_language": { "code": "en", "name": "English", "plural": { "id": 75, "source": 0, "number": 2, "formula": "n != 1", "type": 1 }, "aliases": [ "english", "en_en", "base", "source", "eng" ], "direction": "ltr", "web_url": "http://example.com/languages/en/", "url": "http://example.com/api/languages/en/", "statistics_url": "http://example.com/api/languages/en/statistics/" }, "project": { "name": "Hello", "slug": "hello", "id": 1, "source_language": { "code": "en", "name": "English", "plural": { "id": 75, "source": 0, "number": 2, "formula": "n != 1", "type": 1 }, "aliases": [ "english", "en_en", "base", "source", "eng" ], "direction": "ltr", "web_url": "http://example.com/languages/en/", "url": "http://example.com/api/languages/en/", "statistics_url": "http://example.com/api/languages/en/statistics/" }, "web_url": "http://example.com/projects/demo1/", "url": "http://example.com/api/projects/demo1/", "components_list_url": "http://example.com/api/projects/demo1/components/", "repository_url": "http://example.com/api/projects/demo1/repository/", "statistics_url": "http://example.com/api/projects/demo1/statistics/", "changes_list_url": "http://example.com/api/projects/demo1/changes/", "languages_url": "http://example.com/api/projects/demo1/languages/" }, "projects_url": "http://example.com/api/glossary/7/projects/", "terms_url": "http://example.com/api/glossary/7/terms/", "url": "http://example.com/api/glossary/7/" }
-
PUT
/api/glossary/
(int: id)/
¶ 更改词汇表参数。
- 参数
id (int) – 词汇表 id
- 请求 JSON 对象
name (string) – 语言名称
color (string) – 语言方向
source_language (object) – 语言复数的细节
-
PATCH
/api/glossary/
(int: id)/
¶ 更改词汇表参数。
- 参数
id (int) – 词汇表 id
- 请求 JSON 对象
name (string) – 语言名称
color (string) – 语言方向
source_language (object) – 语言复数的细节
-
DELETE
/api/glossary/
(int: id)/
¶ 删除词汇表。
- 参数
id (int) – 词汇表 id
-
GET
/api/glossary/
(int: id)/projects/
¶ Returns projects linked with a glossary.
- 参数
id (int) – 词汇表 id
- 响应 JSON 对象
projects (array) – associated projects; see
GET /api/projects/(string:project)/
-
POST
/api/glossary/
(int: id)/projects/
¶ Associate project with a glossary.
- 参数
id (int) – 词汇表 id
- 表格参数
string project_slug – 项目标识串
-
DELETE
/api/glossary/
(int: id)/projects/
¶ 删除项目与词汇表的关联性。
- 参数
id (int) – 词汇表 id
- 表格参数
string project_slug – 项目标识串
-
GET
/api/glossary/
(int: id)/terms/
¶ 列出词汇表的项。
- 参数
id (int) – 词汇表 id
-
POST
/api/glossary/
(int: id)/terms/
¶ 将术语与词汇表关联。
- 参数
id (int) – 词汇表 id
- 请求 JSON 对象
language (object) – 术语的语言
source (string) – 术语的源字符串
target (string) – 术语的目标字符串
-
GET
/api/glossary/
(int: id)/terms/
(int: term_id)/
¶ 获取与词汇表相关联的术语。
- 参数
id (int) – 词汇表 id
term_id (int) – ID of term
-
PUT
/api/glossary/
(int: id)/terms/
(int: term_id)/
¶ 编辑与词汇表关联的术语。
- 参数
id (int) – 词汇表 id
term_id (int) – ID of term
- 请求 JSON 对象
language (object) – 术语的语言
source (string) – 术语的源字符串
target (string) – 术语的目标字符串
-
PATCH
/api/glossary/
(int: id)/terms/
(int: term_id)/
¶ 编辑与词汇表关联的术语。
- 参数
id (int) – 词汇表 id
term_id (int) – ID of term
- 请求 JSON 对象
language (object) – 术语的语言
source (string) – 术语的源字符串
target (string) – 术语的目标字符串
-
DELETE
/api/glossary/
(int: id)/terms/
(int: term_id)/
¶ Delete a term associated with a glossary.
- 参数
id (int) – 词汇表 id
term_id (int) – ID of term
通知钩子¶
Notification hooks allow external applications to notify Weblate that the VCS repository has been updated.
You can use repository endpoints for projects, components and translations to
update individual repositories; see
POST /api/projects/(string:project)/repository/
for documentation.
-
GET
/hooks/update/
(string: project)/
(string: component)/
¶ 2.6 版后已移除: Please use
POST /api/components/(string:project)/(string:component)/repository/
instead which works properly with authentication for ACL limited projects.Triggers update of a component (pulling from VCS and scanning for translation changes).
-
GET
/hooks/update/
(string: project)/
¶ 2.6 版后已移除: Please use
POST /api/projects/(string:project)/repository/
instead which works properly with authentication for ACL limited projects.Triggers update of all components in a project (pulling from VCS and scanning for translation changes).
-
POST
/hooks/github/
¶ Special hook for handling GitHub notifications and automatically updating matching components.
注解
GitHub includes direct support for notifying Weblate: enable Weblate service hook in repository settings and set the URL to the URL of your Weblate installation.
参见
- 从 GitHub 自动接收更改
For instruction on setting up GitHub integration
- https://docs.github.com/en/github/extending-github/about-webhooks
Generic information about GitHub Webhooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
-
POST
/hooks/gitlab/
¶ Special hook for handling GitLab notifications and automatically updating matching components.
参见
- 从 GitLab 自动接收更改
For instruction on setting up GitLab integration
- https://docs.gitlab.com/ce/user/project/integrations/webhooks.html
Generic information about GitLab Webhooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
-
POST
/hooks/bitbucket/
¶ Special hook for handling Bitbucket notifications and automatically updating matching components.
参见
- 从 Bitbucket 自动接收更改
For instruction on setting up Bitbucket integration
- https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html
Generic information about Bitbucket Webhooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
-
POST
/hooks/pagure/
¶ 3.3 新版功能.
Special hook for handling Pagure notifications and automatically updating matching components.
参见
- 从 Pagure 自动接受更改
For instruction on setting up Pagure integration
- https://docs.pagure.org/pagure/usage/using_webhooks.html
Generic information about Pagure Webhooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
-
POST
/hooks/azure/
¶ 3.8 新版功能.
Special hook for handling Azure Repos notifications and automatically updating matching components.
参见
- 从 Azure Repos 自动接收更改
For instruction on setting up Azure integration
- https://docs.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks
Generic information about Azure Repos Web Hooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
-
POST
/hooks/gitea/
¶ 3.9 新版功能.
Special hook for handling Gitea Webhook notifications and automatically updating matching components.
参见
- 从 Gitea Repos 自动接收更改
For instruction on setting up Gitea integration
- https://docs.gitea.io/en-us/webhooks/
Generic information about Gitea Webhooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
-
POST
/hooks/gitee/
¶ 3.9 新版功能.
Special hook for handling Gitee Webhook notifications and automatically updating matching components.
参见
- 从 Gitee Repos 自动接收更改
For instruction on setting up Gitee integration
- https://gitee.com/help/categories/40
Generic information about Gitee Webhooks
ENABLE_HOOKS
For enabling hooks for whole Weblate
Exports¶
Weblate provides various exports to allow you to further process the data.
-
GET
/exports/stats/
(string: project)/
(string: component)/
¶ - 查询参数
format (string) – Output format: either
json
orcsv
2.6 版后已移除: Please use
GET /api/components/(string:project)/(string:component)/statistics/
andGET /api/translations/(string:project)/(string:component)/(string:language)/statistics/
instead; it allows access to ACL controlled projects as well.Retrieves statistics for given component in given format.
Example request:
GET /exports/stats/weblate/master/ HTTP/1.1 Host: example.com Accept: application/json, text/javascript
Example response:
HTTP/1.1 200 OK Vary: Accept Content-Type: application/json [ { "code": "cs", "failing": 0, "failing_percent": 0.0, "fuzzy": 0, "fuzzy_percent": 0.0, "last_author": "Michal Čihař", "last_change": "2012-03-28T15:07:38+00:00", "name": "Czech", "total": 436, "total_words": 15271, "translated": 436, "translated_percent": 100.0, "translated_words": 3201, "url": "http://hosted.weblate.org/engage/weblate/cs/", "url_translate": "http://hosted.weblate.org/projects/weblate/master/cs/" }, { "code": "nl", "failing": 21, "failing_percent": 4.8, "fuzzy": 11, "fuzzy_percent": 2.5, "last_author": null, "last_change": null, "name": "Dutch", "total": 436, "total_words": 15271, "translated": 319, "translated_percent": 73.2, "translated_words": 3201, "url": "http://hosted.weblate.org/engage/weblate/nl/", "url_translate": "http://hosted.weblate.org/projects/weblate/master/nl/" }, { "code": "el", "failing": 11, "failing_percent": 2.5, "fuzzy": 21, "fuzzy_percent": 4.8, "last_author": null, "last_change": null, "name": "Greek", "total": 436, "total_words": 15271, "translated": 312, "translated_percent": 71.6, "translated_words": 3201, "url": "http://hosted.weblate.org/engage/weblate/el/", "url_translate": "http://hosted.weblate.org/projects/weblate/master/el/" } ]
RSS 频道¶
Changes in translations are exported in RSS feeds.
-
GET
/exports/rss/
(string: project)/
(string: component)/
(string: language)/
¶ Retrieves RSS feed with recent changes for a translation.
-
GET
/exports/rss/
(string: project)/
(string: component)/
¶ Retrieves RSS feed with recent changes for a component.
-
GET
/exports/rss/
(string: project)/
¶ Retrieves RSS feed with recent changes for a project.
-
GET
/exports/rss/language/
(string: language)/
¶ Retrieves RSS feed with recent changes for a language.
-
GET
/exports/rss/
¶ Retrieves RSS feed with recent changes for Weblate instance.