Weblate 的 REST API¶
API 可以在 /api/ URL上存取,並且它基於 Django REST framework。您可以直接使用或參考 Weblate 用戶端。
The API is also documented using OpenAPI 3.1 on the /api/schema/ URL, you
can browse at /api/docs/.
備註
OpenAPI is available as a feature preview. The documentation is most likely incomplete at this point and subject to change. Please consult the documentation below for more detailed information on the API.
身分驗證和通用參數¶
The read-only API is available without authentication unless
REQUIRE_LOGIN is turned on. Unauthenticated requests are heavily
throttled (by default to 100 requests per day), so it is recommended to use
authentication.
The authentication uses a token, which you can get in your profile. Use it in
the Authorization header:
- ANY /¶
Generic request behaviour for the API, the headers, status codes and parameters here apply to all endpoints as well.
- Query Parameters:
format -- Response format (overrides Accept). Possible values depends on REST framework setup, by default
json,csvandapiare supported. The latter provides web browser interface for API.page -- Returns given page of paginated results (use next and previous fields in response to automate the navigation).
page_size -- Return the given number of items per request. The default is 50 and the maximum is 1000. For the units endpoints the default is 100 with a maximum of 10000. The default value is also configurable using the PAGE_SIZE setting.
- Request Headers:
Accept -- the response content type depends on Accept header
Authorization -- optional token to authenticate as
Authorization: Token YOUR-TOKEN
- Response Headers:
Content-Type -- this depends on Accept header of request
Allow -- list of allowed HTTP methods on object
- Response JSON Object:
detail (string) -- verbose description of the result (for HTTP status codes other than 200 OK)
count (int) -- total item count for object lists
next (string) -- next page URL for object lists
previous (string) -- previous page URL for object lists
results (array) -- results for object lists
url (string) -- URL to access this resource using the API
web_url (string) -- URL to access this resource using web browser
- Status Codes:
200 OK -- when request was correctly handled
201 Created -- when a new object was created successfully
204 No Content -- when an object was deleted successfully
400 Bad Request -- when form parameters are missing
403 Forbidden -- when access is denied
429 Too Many Requests -- when throttling is in place
身分驗證權杖¶
在 4.10 版的變更: Project scoped tokens were introduced in the 4.10 release.
Each user has a personal access token which can be obtained in the user
profile. Newly generated user tokens have the wlu_ prefix.
It is possible to create project scoped tokens for API access to given project
only. These tokens can be identified by the wlp_ prefix.
身分驗證範例¶
範例請求:
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/
組件與類別¶
To access a component which is nested inside a 類別, you need to URL
encode the category name into a component name separated with a slash. For
example usage placed in a docs category needs to be used as
docs%252Fusage. Full URL in this case would be for example
https://example.com/api/components/hello/docs%252Fusage/repository/.
API 速率限制¶
這個 API 請求限制了速率;對於匿名使用者預設配置限制為每天 100 個請求,對於身分驗證的使用者限制為每小時 5000 個請求。
速率限制可以在 settings.py 中調整;如何配置它的更多細節請參閱 Throttling in Django REST framework documentation。
In the Docker container this can be configured using
WEBLATE_API_RATELIMIT_ANON and WEBLATE_API_RATELIMIT_USER.
速率限制在後面的標頭中報告:
|
允許執行的請求數 |
|
剩餘的執行請求數 |
|
直到速率限制視窗重設時的秒數 |
在 4.1 版的變更: 新增速率限制狀態的標頭。
錯誤回應¶
在 5.10 版的變更: Error responses were endpoint specific before this release.
Weblate error responses are formatted based on Error Response Format.
API 入口點¶
- GET /api/¶
The API root entry point.
範例請求:
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/¶
Returns a list of users if you have permissions to see manage users. If not, then you get to see only your own details.
- Query Parameters:
username (string) -- Username to search for
id (int) -- User ID to search for
email (string) -- Email to search for (case-insensitive, exact match). Requires
user.vieworuser.editpermission; the parameter is ignored for unprivileged users.
也參考
Users object attributes are documented at
GET /api/users/(str:username)/.
- POST /api/users/¶
Creates a new user.
Requires the global
user.editpermission. See 存取控制 for the user management permission model.- 參數值:
username (string) -- 使用者名稱
full_name (string) -- User full name
email (string) -- User email
is_superuser (boolean) -- Is user superuser? (optional)
is_active (boolean) -- Is user active? (optional)
is_bot (boolean) -- Is user bot? (optional) (used for project scoped tokens)
- GET /api/users/(str: username)/¶
Returns information about users.
- 參數值:
username (string) -- User's username
- Response JSON Object:
username (string) -- username of a user
full_name (string) -- full name of a user
email (string) -- email of a user
is_superuser (boolean) -- whether the user is a super user
is_active (boolean) -- whether the user is active
is_bot (boolean) -- whether the user is bot (used for project scoped tokens)
date_joined (string) -- date the user is created
last_login (string) -- date the user last signed in
groups (array) -- link to associated groups; see
GET /api/groups/(int:id)/languages (array) -- link to translated languages; see
GET /api/languages/(string:language)/
Example JSON data:
{ "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)/¶
Changes the user parameters.
Requires the global
user.editpermission unless a user is updating their own basic profile fields. See 存取控制 for the user management permission model.- 參數值:
username (string) -- User's username
- Response JSON Object:
username (string) -- username of a user
full_name (string) -- full name of a user
email (string) -- email of a user
is_superuser (boolean) -- whether the user is a super user
is_active (boolean) -- whether the user is active
is_bot (boolean) -- whether the user is bot (used for project scoped tokens)
date_joined (string) -- date the user is created
- PATCH /api/users/(str: username)/¶
Changes the user parameters.
Requires the global
user.editpermission unless a user is updating their own basic profile fields. See 存取控制 for the user management permission model.- 參數值:
username (string) -- User's username
- Response JSON Object:
username (string) -- username of a user
full_name (string) -- full name of a user
email (string) -- email of a user
is_superuser (boolean) -- whether the user is a super user
is_active (boolean) -- whether the user is active
is_bot (boolean) -- whether the user is bot (used for project scoped tokens)
date_joined (string) -- date the user is created
- DELETE /api/users/(str: username)/¶
Deletes all user information and marks the user inactive.
Requires the global
user.editpermission. See 存取控制 for the user management permission model.- 參數值:
username (string) -- User's username
- POST /api/users/(str: username)/groups/¶
Associate groups with a user.
Requires the global
user.editpermission. See 存取控制 for the user management permission model.- 參數值:
username (string) -- User's username
- Form Parameters:
string group_id -- The unique group ID
- DELETE /api/users/(str: username)/groups/¶
在 4.13.1 版被加入.
Remove user from a group.
Requires the global
user.editpermission. See 存取控制 for the user management permission model.- 參數值:
username (string) -- User's username
- Form Parameters:
string group_id -- The unique group ID
- GET /api/users/(str: username)/statistics/¶
List statistics of a user.
- 參數值:
username (string) -- User's username
- Response JSON Object:
translated (int) -- Number of translations by user
suggested (int) -- Number of suggestions by user
uploaded (int) -- Number of uploads by user
commented (int) -- Number of comments by user
languages (int) -- Number of languages user can translate
- GET /api/users/(str: username)/contributions/¶
List translations with contributions from a user.
- 參數值:
username (string) -- User's username
- Response JSON Object:
translations (array) -- link to translations; see
GET /api/translations/(string:project)/(string:component)/(string:language)/
- GET /api/users/(str: username)/notifications/¶
List subscriptions of a user.
- 參數值:
username (string) -- User's username
- POST /api/users/(str: username)/notifications/¶
Associate subscriptions with a user.
- 參數值:
username (string) -- User's username
- Request JSON Object:
notification (string) -- Name of notification registered
scope (int) -- Scope of notification from the available choices
frequency (int) -- Frequency choices for notifications
- GET /api/users/(str: username)/notifications/(int: subscription_id)/¶
Get a subscription associated with a user.
- 參數值:
username (string) -- User's username
subscription_id (int) -- ID of notification registered
- PUT /api/users/(str: username)/notifications/(int: subscription_id)/¶
Edit a subscription associated with a user.
- 參數值:
username (string) -- User's username
subscription_id (int) -- ID of notification registered
- Request JSON Object:
notification (string) -- Name of notification registered
scope (int) -- Scope of notification from the available choices
frequency (int) -- Frequency choices for notifications
- PATCH /api/users/(str: username)/notifications/(int: subscription_id)/¶
Edit a subscription associated with a user.
- 參數值:
username (string) -- User's username
subscription_id (int) -- ID of notification registered
- Request JSON Object:
notification (string) -- Name of notification registered
scope (int) -- Scope of notification from the available choices
frequency (int) -- Frequency choices for notifications
- DELETE /api/users/(str: username)/notifications/(int: subscription_id)/¶
Delete a subscription associated with a user.
- 參數值:
username (string) -- User's username
subscription_id -- Name of notification registered
subscription_id -- int
群組¶
在 4.0 版被加入.
- GET /api/groups/¶
Returns a list of groups if you have permissions to see manage groups. If not, then you get to see only the groups the user is a part of.
也參考
Group object attributes are documented at
GET /api/groups/(int:id)/.
- POST /api/groups/¶
Creates a new group.
- 參數值:
name (string) -- Group name
project_selection (int) -- Group of project selection from given options
language_selection (int) -- Group of languages selected from given options
defining_project (str) -- link to the defining project, used for 管理個別專案存取控制; see
GET /api/projects/(string:project)/
- GET /api/groups/(int: id)/¶
Returns information about the group.
- 參數值:
id (int) -- Group's ID
- Response JSON Object:
name (string) -- name of a group
project_selection (int) -- integer corresponding to group of projects
language_selection (int) -- integer corresponding to group of languages
roles (array) -- link to associated roles; see
GET /api/roles/(int:id)/projects (array) -- link to associated projects; see
GET /api/projects/(string:project)/components (array) -- link to associated components; see
GET /api/components/(string:project)/(string:component)/componentlists (array) -- link to associated componentlist; see
GET /api/component-lists/(str:slug)/defining_project (str) -- link to the defining project, used for 管理個別專案存取控制; see
GET /api/projects/(string:project)/admins (array) -- link to associated administrators; see
GET /api/users/(str:username)/
Example JSON data:
{ "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)/¶
Changes the group parameters.
- 參數值:
id (int) -- Group's ID
- Response JSON Object:
name (string) -- name of a group
project_selection (int) -- integer corresponding to group of projects
language_selection (int) -- integer corresponding to group of languages
- PATCH /api/groups/(int: id)/¶
Changes the group parameters.
- 參數值:
id (int) -- Group's ID
- Response JSON Object:
name (string) -- name of a group
project_selection (int) -- integer corresponding to group of projects
language_selection (int) -- integer corresponding to group of languages
- DELETE /api/groups/(int: id)/¶
Deletes the group.
- 參數值:
id (int) -- Group's ID
- POST /api/groups/(int: id)/roles/¶
Associate roles with a group.
- 參數值:
id (int) -- Group's ID
- Form Parameters:
string role_id -- The unique role ID
- DELETE /api/groups/(int: id)/roles/(int: role_id)¶
Delete role from a group.
- 參數值:
id (int) -- Group's ID
role_id (int) -- The unique role ID
- POST /api/groups/(int: id)/components/¶
Associate components with a group.
- 參數值:
id (int) -- Group's ID
- Form Parameters:
string component_id -- The unique component ID
- DELETE /api/groups/(int: id)/components/(int: component_id)¶
Delete component from a group.
- 參數值:
id (int) -- Group's ID
component_id (int) -- The unique component ID
- POST /api/groups/(int: id)/projects/¶
Associate projects with a group.
- 參數值:
id (int) -- Group's ID
- Form Parameters:
string project_id -- The unique project ID
- DELETE /api/groups/(int: id)/projects/(int: project_id)¶
Delete project from a group.
- 參數值:
id (int) -- Group's ID
project_id (int) -- The unique project ID
- POST /api/groups/(int: id)/languages/¶
Associate languages with a group.
- 參數值:
id (int) -- Group's ID
- Form Parameters:
string language_code -- The unique language code
- DELETE /api/groups/(int: id)/languages/(string: language_code)¶
Delete language from a group.
- 參數值:
id (int) -- Group's ID
language_code (string) -- The unique language code
- POST /api/groups/(int: id)/componentlists/¶
Associate componentlists with a group.
- 參數值:
id (int) -- Group's ID
- Form Parameters:
string component_list_id -- The unique componentlist ID
- DELETE /api/groups/(int: id)/componentlists/(int: component_list_id)¶
Delete componentlist from a group.
- 參數值:
id (int) -- Group's ID
component_list_id (int) -- The unique componentlist ID
- POST /api/groups/(int: id)/admins/¶
在 5.5 版被加入.
Add user to team admins.
- 參數值:
id (int) -- Group's ID
- Form Parameters:
string user_id -- The user's ID
- DELETE /api/groups/(int: id)/admins/(int: user_id)¶
在 5.5 版被加入.
Delete user from team admins.
- 參數值:
id (int) -- Group's ID
user_id (integer) -- The user's ID
角色¶
- GET /api/roles/¶
Returns a list of all roles associated with user. If user is superuser, then list of all existing roles is returned.
也參考
Roles object attributes are documented at
GET /api/roles/(int:id)/.
- POST /api/roles/¶
Creates a new role.
- 參數值:
name (string) -- Role name
permissions (array) -- List of codenames of permissions
- GET /api/roles/(int: id)/¶
Returns information about the role.
- 參數值:
id (int) -- Role's ID
- Response JSON Object:
name (string) -- Role name
permissions (array) -- list of codenames of permissions
Example JSON data:
{ "name": "Access repository", "permissions": [ "vcs.access", "vcs.view" ], "url": "http://example.com/api/roles/1/", }
- PUT /api/roles/(int: id)/¶
Changes the role parameters.
- 參數值:
id (int) -- Role's ID
- Response JSON Object:
name (string) -- Role name
permissions (array) -- list of codenames of permissions
- PATCH /api/roles/(int: id)/¶
Changes the role parameters.
- 參數值:
id (int) -- Role's ID
- Response JSON Object:
name (string) -- Role name
permissions (array) -- list of codenames of permissions
- DELETE /api/roles/(int: id)/¶
Deletes the role.
- 參數值:
id (int) -- Role's ID
語言¶
- GET /api/languages/¶
Returns a list of all languages.
也參考
Language object attributes are documented at
GET /api/languages/(string:language)/.
- POST /api/languages/¶
Creates a new language.
- 參數值:
code (string) -- 語言名稱
name (string) -- 語言名稱
direction (string) -- 文字方向
population (int) -- 語言使用者數量
plural (object) -- Language plural formula and number
- GET /api/languages/(string: language)/¶
Returns information about the language.
- 參數值:
language (string) -- 語言代碼
- Response JSON Object:
code (string) -- 語言代碼
direction (string) -- 文字方向
plural (object) -- Object of language plural information
aliases (array) -- Array of aliases for language
- Request JSON Object:
population (int) -- 語言使用者數量
Example JSON data:
{ "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)/¶
Changes the language parameters.
- 參數值:
language (string) -- Language's code
- Request JSON Object:
name (string) -- 語言名稱
direction (string) -- 文字方向
population (int) -- 語言使用者數量
plural (object) -- Language plural details
- PATCH /api/languages/(string: language)/¶
Changes the language parameters.
- 參數值:
language (string) -- Language's code
- Request JSON Object:
name (string) -- 語言名稱
direction (string) -- 文字方向
population (int) -- 語言使用者數量
plural (object) -- Language plural details
- DELETE /api/languages/(string: language)/¶
Deletes the language.
- 參數值:
language (string) -- Language's code
專案¶
- GET /api/projects/¶
Returns a list of all projects.
也參考
Project object attributes are documented at
GET /api/projects/(string:project)/.
- POST /api/projects/¶
Creates a new project.
- 參數值:
name (string) -- 專案名稱
slug (string) -- 專案 slug
web (string) -- 專案網站
- GET /api/projects/(string: project)/¶
Returns information about the project.
- 參數值:
project (string) -- Project URL slug
- Response JSON Object:
name (string) -- project name
slug (string) -- project slug
web (string) -- project website
components_list_url (string) -- URL to components list; see
GET /api/projects/(string:project)/components/repository_url (string) -- URL to repository status; see
GET /api/projects/(string:project)/repository/changes_list_url (string) -- URL to changes list; see
GET /api/projects/(string:project)/changes/credits_url (string) -- URL to list contributor credits; see
GET /api/projects/(string:project)/credits/translation_review (boolean) -- 啟用檢閱
source_review (boolean) -- 啟用來源檢閱
enable_hooks (boolean) -- 啟用掛勾
instructions (string) -- 翻譯指示
language_aliases (string) -- 語言別名
announcements_url (string) -- URL to announcements; see
GET /api/projects/(string:project)/announcements/
Example JSON data:
{ "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 版被加入.
Edit a project by a PATCH request.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- PUT /api/projects/(string: project)/¶
在 4.3 版被加入.
Edit a project by a PUT request.
- 參數值:
project (string) -- Project URL slug
- DELETE /api/projects/(string: project)/¶
Deletes a project.
- 參數值:
project (string) -- Project URL slug
- GET /api/projects/(string: project)/changes/¶
Returns a list of project changes. This is essentially a project scoped
GET /api/changes/accepting same params.- 參數值:
project (string) -- Project URL slug
- Response JSON Object:
results (array) -- array of component objects; see
GET /api/changes/(int:id)/
- GET /api/projects/(string: project)/file/¶
在 5.5 版被加入.
Downloads all available translations associated with the project as an archive file using the requested format and language.
- 參數值:
project (string) -- Project URL slug
- Query Parameters:
format (string) -- The archive format to use; If not specified, defaults to
zip; Supported formats:zipandzip:CONVERSIONwhereCONVERSIONis one of converters listed at 下載翻譯.language_code (string) -- The language code to download; If not specified, all languages are included.
- GET /api/projects/(string: project)/repository/¶
Returns information about the VCS repository status. This endpoint contains only an overall summary for all repositories for the project. To get more detailed status use
GET /api/components/(string:project)/(string:component)/repository/.- 參數值:
project (string) -- Project URL slug
- Response JSON Object:
needs_commit (boolean) -- whether there are any pending changes to commit
needs_merge (boolean) -- whether there are any upstream changes to merge
needs_push (boolean) -- whether there are any local changes to push
Example JSON data:
{ "needs_commit": true, "needs_merge": false, "needs_push": true }
- POST /api/projects/(string: project)/repository/¶
Performs given operation on the VCS repository.
- 參數值:
project (string) -- Project URL slug
- Request JSON Object:
operation (string) -- Operation to perform: one of
push,pull,commit,reset,cleanup,file-sync,file-scan
- Response JSON Object:
result (boolean) -- result of the operation
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 response example:
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/¶
Returns a list of translation components in the given project.
- 參數值:
project (string) -- Project URL slug
- Response JSON Object:
results (array) -- array of component objects; see
GET /api/components/(string:project)/(string:component)/
- POST /api/projects/(string: project)/components/¶
在 4.3 版的變更: The
zipfileanddocfileparameters are now accepted for VCS-less components, see 本地檔案.在 4.6 版的變更: The cloned repositories are now automatically shared within a project using Weblate 內部 URL. Use
disable_autoshareto turn off this.Creates translation components in the given project.
提示
Use Weblate 內部 URL when creating multiple components from a single VCS repository.
備註
Most of the component creation happens in the background. Check the
task_urlattribute of created component and follow the progress there.- 參數值:
project (string) -- Project URL slug
- Form Parameters:
file zipfile -- ZIP file to upload into Weblate for translations initialization
file docfile -- Document to translate
string from_component -- Optional source component reference used to duplicate the new component. Accepts either a numeric component ID or a full Weblate component path. When provided, the new component inherits the source component configuration and translations into a new local repository. Repository fields such as
repo,vcs,branch,push, andpush_branchcan not be combined with this option.boolean disable_autoshare -- Disables automatic repository sharing via Weblate 內部 URL.
- Request JSON Object:
object -- Component parameters, see
GET /api/components/(string:project)/(string:component)/
- Response JSON Object:
result (object) -- Created component object; see
GET /api/components/(string:project)/(string:component)/
JSON can not be used when uploading the files using the
zipfileanddocfileparameters. The data has to be uploaded as multipart/form-data.CURL form request example:
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 request example:
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/
JSON request to create a new component from Git:
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 request to create a new component from another one:
POST /api/projects/hello/components/ HTTP/1.1 Host: example.com Accept: application/json Content-Type: application/json Authorization: Token TOKEN Content-Length: 20 { "from_component": "hello/weblate", "name": "Weblate", "slug": "weblate" }
JSON response example:
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/¶
Returns paginated statistics for all languages within a project.
- 參數值:
project (string) -- Project URL slug
- Response JSON Object:
results (array) -- array of translation statistics objects
language (string) -- language name
code (string) -- language code
total (int) -- total number of strings
translated (int) -- number of translated strings
translated_percent (float) -- percentage of translated strings
total_words (int) -- total number of words
translated_words (int) -- number of translated words
words_percent (float) -- percentage of translated words
- GET /api/projects/(string: project)/statistics/¶
Returns statistics for a project.
- 參數值:
project (string) -- Project URL slug
也參考
Returned attributes are described in 統計資料.
- GET /api/projects/(string: project)/categories/¶
在 5.0 版被加入: Returns categories for a project. See
GET /api/categories/(int:id)/for field definitions.- param project:
Project URL slug
- type project:
string
- GET /api/projects/(string: project)/labels/¶
在 5.3 版被加入: Returns labels for a project.
- param project:
Project URL slug
- type project:
string
- >json int id:
ID of the label
- >json string name:
name of the label
- >json string color:
color of the label
- POST /api/projects/(string: project)/labels/¶
在 5.3 版被加入: Creates a label for a project.
- param project:
Project URL slug
- type project:
string
- <json string name:
name of the label
- <json string color:
color of the label
- DELETE /api/projects/(string: project)/labels/(int: label_id)/¶
在 5.14 版被加入: Deletes a label from a project.
- param project:
Project URL slug
- type project:
string
- param label_id:
ID of the label to delete
- type label_id:
integer
- GET /api/projects/(string: project)/credits/¶
Returns contributor credits for a project.
在 5.7 版被加入.
- 參數值:
project (string) -- Project URL slug
start (date) -- Lower-bound ISO 8601 timestamp (mandatory)
end (date) -- Upper-bound ISO 8601 timestamp (mandatory)
lang (source_language) -- Language code to search for
- Response JSON Object:
email (string) -- Email of the contributor
full_name (string) -- Full name of the contributor
change_count (string) -- Number of changes done in the time range
- GET /api/projects/(string: project)/machinery_settings/¶
在 5.9 版被加入.
Returns automatic suggestion settings for a project, consisting of the configurations defined for each translation service installed.
- 參數值:
project (string) -- Project URL slug
- Response JSON Object:
suggestion_settings (object) -- Configuration for all installed services.
- POST /api/projects/(string: project)/machinery_settings/¶
在 5.9 版被加入.
Create or update the service configuration for a project.
- 參數值:
project (string) -- Project URL slug
- Form Parameters:
string service -- Service name
string configuration -- Service configuration in 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) -- Project URL slug
language_code (string) -- 語言代碼
- Query Parameters:
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) -- The archive format to use; If not specified, defaults to
zip; Supported formats:zipandzip:CONVERSIONwhereCONVERSIONis one of converters listed at 下載翻譯.
備註
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/projects/(string: project)/announcements/¶
在 5.17 版被加入: Returns announcements for a project.
- param project:
Project URL slug
- type project:
string
- >json int id:
ID of the announcement
- >json string message:
announcement text
- >json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- >json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- >json bool notify:
send notification to subscribed users? (optional)
- POST /api/projects/(string: project)/announcements/¶
在 5.17 版被加入: Creates an announcement for a project.
- param project:
Project URL slug
- type project:
string
- <json string message:
announcement text
- <json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- <json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- <json bool notify:
send notification to subscribed users? (optional)
- DELETE /api/projects/(string: project)/announcements/(int: announcement_id)/¶
在 5.17 版被加入: Deletes an announcement from a project.
- param project:
Project URL slug
- type project:
string
- param announcement_id:
ID of the announcement to delete
- type announcement_id:
integer
組件¶
提示
Use POST /api/projects/(string:project)/components/ to create new components.
- 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 the translation component.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
project (object) -- the translation project; see
GET /api/projects/(string:project)/name (string) -- 組件名稱
slug (string) -- 組件標識串
vcs (string) -- 版本控制系統
linked_component (string) -- component whose repository is linked via Weblate 內部 URL
repo (string) -- 原始碼儲存庫, this is the actual repository URL even when Weblate 內部 URL are used, use
linked_componentto detect this situationgit_export (string) -- 已匯出儲存庫 URL
branch (string) -- 儲存庫分支, this is the actual repository branch even when Weblate 內部 URL are used
push (string) -- 儲存庫推送 URL, this is the actual repository URL even when Weblate 內部 URL are used
push_branch (string) -- 推送分支, this is the actual repository branch even when Weblate 內部 URL are used
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) -- source language object; see
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) -- Commit, add, delete, merge, add-on, and merge request messages
add_message (string) -- Commit, add, delete, merge, add-on, and merge request messages
delete_message (string) -- Commit, add, delete, merge, add-on, and merge request messages
merge_message (string) -- Commit, add, delete, merge, add-on, and merge request messages
addon_message (string) -- Commit, add, delete, merge, add-on, and merge request messages
pull_message (string) -- Commit, add, delete, merge, add-on, and merge request messages
allow_translation_propagation (string) -- 允許翻譯再用
enable_suggestions (string) -- 啟用建議
suggestion_voting (string) -- 建議投票
suggestion_autoaccept (string) -- 自動接受建議
push_on_commit (boolean) -- 提交時一併推送; linked repositories expose the effective value from the linked component
locked (bool) -- Whether component is locked, this field is read-only; see
GET /api/components/(string:project)/(string:component)/lock/commit_pending_age (integer) -- 變更後提交的經過時間; linked repositories expose the effective value from the linked component
auto_lock_error (boolean) -- 有錯誤時鎖定; linked repositories expose the effective value from the linked component
language_regex (string) -- 語言篩選
variant_regex (string) -- 變體的正規表達式
is_glossary (bool) -- 當作詞彙表
glossary_color (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/task_url (string) -- URL to a background task (if any); see
GET /api/tasks/(str:uuid)/credits_url (string) -- URL to list contributor credits; see
GET /api/components/(string:project)/(string:component)/credits/announcements_url (string) -- URL to announcements; see
GET /api/components/(string:project)/(string:component)/announcements/
Example JSON data:
{ "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)/¶
Edit a component by a PATCH request.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
source_language (string) -- Project source language code (optional)
- Request JSON Object:
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 response example:
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)/¶
Edit a component by a PUT request.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Request JSON Object:
branch (string) -- VCS repository branch
file_format (string) -- file format of translations
file_format_params (object) -- parameters related to the file
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)/¶
Deletes a component.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- 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) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
results (array) -- array of component objects; see
GET /api/changes/(int:id)/
- GET /api/components/(string: project)/(string: component)/file/¶
在 4.9 版被加入.
Downloads all available translations associated with the component as an archive file using the requested format.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Query Parameters:
format (string) -- The archive format to use; If not specified, defaults to
zip; Supported formats:zipandzip:CONVERSIONwhereCONVERSIONis one of converters listed at 下載翻譯.
- GET /api/components/(string: project)/(string: component)/screenshots/¶
Returns a list of component screenshots.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
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) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
locked (boolean) -- whether component is locked for updates
Example JSON data:
{ "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) -- Project URL slug
component (string) -- Component URL slug
- Request JSON Object:
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 response example:
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 the VCS repository status.
The response is same as for
GET /api/projects/(string:project)/repository/.- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
needs_commit (boolean) -- whether there are any pending changes to commit
needs_merge (boolean) -- whether there are any upstream changes to merge
needs_push (boolean) -- whether there are any local changes to push
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) -- Project URL slug
component (string) -- Component URL slug
- Request JSON Object:
operation (string) -- Operation to perform: one of
push,pull,commit,reset,cleanup
- Response JSON Object:
result (boolean) -- result of the operation
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 response example:
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) -- Project URL slug
component (string) -- Component URL slug
- GET /api/components/(string: project)/(string: component)/new_template/¶
Downloads template file for new translations.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- GET /api/components/(string: project)/(string: component)/translations/¶
Returns a list of translation objects in the given component.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
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) -- Project URL slug
component (string) -- Component URL slug
- Request JSON Object:
language_code (string) -- translation language code; see
GET /api/languages/(string:language)/from_component (array) -- optional ordered list of source component references used for automatic translation. Accepts numeric component IDs or full Weblate component paths. For form submissions this field can be provided multiple times.
- Response JSON Object:
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", "from_component": ["hello/weblate", 123] }
JSON response example:
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/¶
Returns paginated statistics for all translations within component.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
也參考
Returned attributes are described in 統計資料.
- GET /api/components/(string: project)/(string: component)/links/¶
Returns projects linked with a component.
在 4.5 版被加入.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Response JSON Object:
projects (array) -- associated projects; see
GET /api/projects/(string:project)/
- POST /api/components/(string: project)/(string: component)/links/¶
Associate project with a component.
在 4.5 版被加入.
在 5.17 版的變更.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
- Form Parameters:
string project_slug -- 專案 slug
int category_id -- Category ID in the target project (optional). The category must belong to the specified project.
- DELETE /api/components/(string: project)/(string: component)/links/(string: project_slug)/¶
Remove association of a project with a component.
在 4.5 版被加入.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
project_slug (string) -- Slug of the project to remove
- GET /api/components/(string: project)/(string: component)/credits/¶
Returns contributor credits for a project.
在 5.7 版被加入.
- 參數值:
project (string) -- Project URL slug
start (date) -- Lower-bound ISO 8601 timestamp (mandatory)
end (date) -- Upper-bound ISO 8601 timestamp (mandatory)
lang (source_language) -- Language code to search for
- Response JSON Object:
email (string) -- Email of the contributor
full_name (string) -- Full name of the contributor
change_count (string) -- Number of changes done in the time range
- GET /api/components/(string: project)/(string: component)/announcements/¶
在 5.17 版被加入: Returns announcements for a component.
- param project:
Project URL slug
- type project:
string
- param component:
Component URL slug
- type component:
string
- >json int id:
ID of the announcement
- >json string message:
announcement text
- >json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- >json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- >json bool notify:
send notification to subscribed users? (optional)
- POST /api/components/(string: project)/(string: component)/announcements/¶
在 5.17 版被加入: Creates an announcement for a component.
- param project:
Project URL slug
- type project:
string
- param component:
Component URL slug
- type component:
string
- <json string message:
announcement text
- <json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- <json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- <json bool notify:
send notification to subscribed users? (optional)
- DELETE /api/components/(string: project)/(string: component)/announcements/(int: announcement_id)/¶
在 5.17 版被加入: Deletes an announcement from a component.
- param project:
Project URL slug
- type project:
string
- param component:
Component URL slug
- type component:
string
- param announcement_id:
ID of the announcement to delete
- type announcement_id:
integer
翻譯¶
- 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 the translation.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- Response JSON Object:
component (object) -- component object; see
GET /api/components/(string:project)/(string:component)/failing_checks (int) -- number of strings failing checks
failing_checks_percent (float) -- percentage of strings failing checks
failing_checks_words (int) -- number of words with failing checks
filename (string) -- translation filename
fuzzy (int) -- number of fuzzy (marked for edit) strings
fuzzy_percent (float) -- percentage of fuzzy (marked for edit) strings
fuzzy_words (int) -- number of words in fuzzy (marked for edit) strings
have_comment (int) -- number of strings with comment
have_suggestion (int) -- number of strings with suggestion
is_template (boolean) -- whether the translation has a monolingual base
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 number of strings
total_words (int) -- total number of words
translate_url (string) -- URL for translating
translated (int) -- number of translated strings
translated_percent (float) -- percentage of translated strings
translated_words (int) -- number of translated words
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/announcements_url (string) -- URL to announcements; see
GET /api/translations/(string:project)/(string:component)/(string:language)/announcements/
Example JSON data:
{ "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)/¶
Deletes a translation.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- 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) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- Response JSON Object:
results (array) -- array of component objects; see
GET /api/changes/(int:id)/
- GET /api/translations/(string: project)/(string: component)/(string: language)/units/¶
Returns a list of translation units.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
q (string) -- Search query string 搜尋 (optional)
- Response JSON Object:
results (array) -- array of component objects; see
GET /api/units/(int:id)/
- POST /api/translations/(string: project)/(string: component)/(string: language)/units/¶
Add new unit.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- Request JSON Object:
key (string) -- Monolingual translations: Key of translation unit
value (array) -- Monolingual translations: Source strings (use single string if not creating plural)
context (string) -- Bilingual translations: Context of a translation unit
source (array) -- Bilingual translations: Source strings (use single string if not creating plural)
target (array) -- Bilingual translations: Target strings (use single string if not creating plural)
state (int) -- String state; see
GET /api/units/(int:id)/
- Response JSON Object:
unit (object) -- newly created unit; see
GET /api/units/(int:id)/
- POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/¶
在 5.13 版的變更: The
filter_typeparameter is no longer supported and filtering is done by theqparameter.Trigger automatic translation.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- Request JSON Object:
mode (string) -- 自動翻譯模式
q (string) -- Automatic translation search string, see 搜尋字串.
auto_source (string) -- Automatic translation source -
mtorotherscomponent (string) -- Turn on contribution to shared translation memory for the project to get access to additional components.
engines (array) -- 機器翻譯引擎
threshold (string) -- 分數閾值
- GET /api/translations/(string: project)/(string: component)/(string: language)/file/¶
Download current translation file as it is stored in the VCS (without the
formatparameter) or converted to another format (see 下載翻譯).備註
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
formatparameter differs and without such parameter you get translation file as stored in VCS.- Response Headers:
Last-Modified -- Timestamp of last change to this file.
- Request Headers:
If-Modified-Since -- Skips response if the file has not been modified since that time.
- Query Parameters:
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- POST /api/translations/(string: project)/(string: component)/(string: language)/file/¶
Upload new file with translations.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- Form Parameters:
string conflicts -- How to deal with conflicts (
ignore,replace-translatedorreplace-approved), see 衝突處理file file -- Uploaded file
string author_email -- Author e-mail
string author_name -- Author name
string method -- Upload method (
translate,approve,suggest,fuzzy,replace,source,add), see 匯入方法string fuzzy -- 模糊 (標記為需要編輯)的字串處理(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 the VCS repository status.
The response is same as for
GET /api/components/(string:project)/(string:component)/repository/.- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- POST /api/translations/(string: project)/(string: component)/(string: language)/repository/¶
Performs given operation on the VCS repository.
See
POST /api/projects/(string:project)/repository/for documentation.- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
- Request JSON Object:
operation (string) -- Operation to perform: one of
push,pull,commit,reset,cleanup
- Response JSON Object:
result (boolean) -- result of the operation
- GET /api/translations/(string: project)/(string: component)/(string: language)/statistics/¶
Returns detailed translation statistics.
- 參數值:
project (string) -- Project URL slug
component (string) -- Component URL slug
language (string) -- 翻譯語言代碼
也參考
Returned attributes are described in 統計資料.
- GET /api/translations/(string: project)/(string: component)/(string: language)/announcements/¶
在 5.17 版被加入: Returns announcements for a translation.
- param project:
Project URL slug
- type project:
string
- param component:
Component URL slug
- type component:
string
- param language:
翻譯語言代碼
- type language:
string
- >json int id:
ID of the announcement
- >json string message:
announcement text
- >json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- >json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- >json bool notify:
send notification to subscribed users? (optional)
- POST /api/translations/(string: project)/(string: component)/(string: language)/announcements/¶
在 5.17 版被加入: Creates an announcement for a translation.
- param project:
Project URL slug
- type project:
string
- param component:
Component URL slug
- type component:
string
- param language:
翻譯語言代碼
- type language:
string
- <json string message:
announcement text
- <json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- <json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- <json bool notify:
send notification to subscribed users? (optional)
- DELETE /api/translations/(string: project)/(string: component)/(string: language)/announcements/(int: announcement_id)/¶
在 5.17 版被加入: Deletes an announcement from a translation.
- param project:
Project URL slug
- type project:
string
- param component:
Component URL slug
- type component:
string
- param language:
翻譯語言代碼
- type language:
string
- param announcement_id:
ID of the announcement to delete
- type announcement_id:
integer
記憶¶
在 4.14 版被加入.
- GET /api/memory/¶
Returns a list of memory results.
- Query Parameters:
source -- Case-insensitive substring filter on source text (optional)
source_language -- Source language code filter (optional)
target_language -- Target language code filter (optional)
project -- Project slug filter (optional)
- POST /api/memory/lookup/¶
Looks up translation memory matches for the provided source strings.
- Query Parameters:
source_language -- Source language code
target_language -- Target language code
project -- Project slug filter (optional)
exact -- Return exact matches only and skip fuzzy matching (optional)
- Request JSON Object:
strings (array) -- List of source strings to look up
- Response JSON Object:
results (array) -- Ordered lookup results with the best match for each query or
nullwhen no match was found
- DELETE /api/memory/(int: memory_object_id)/¶
Deletes a memory object
- 參數值:
memory_object_id -- Memory Object ID
單位¶
A unit is a single piece of a translation which pairs a source string with a
corresponding translated string and also contains some related metadata. The
term is derived from the translate.storage.base.TranslationUnit in Translate Toolkit
and XLIFF.
- GET /api/units/¶
Returns a list of translation units.
- 參數值:
q (string) -- Search query string 搜尋 (optional)
也參考
Unit object attributes are documented at
GET /api/units/(int:id)/.
- GET /api/units/(int: id)/¶
在 4.3 版的變更: The
targetandsourceare now arrays to properly handle plural strings.在 5.6 版的變更: The
last_updatedattribute is now exposed.Returns information about the translation unit.
- 參數值:
id (int) -- Unit ID
- Response JSON Object:
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
labels (array) -- translation unit labels, available on source units
state (int) -- unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved, 100 - read-only
fuzzy (boolean) -- whether the unit is fuzzy or marked for review
translated (boolean) -- whether the unit is translated
approved (boolean) -- whether the translation is approved
position (int) -- unit position in translation file
has_suggestion (boolean) -- whether the unit has suggestions
has_comment (boolean) -- whether the unit has comments
has_failing_check (boolean) -- whether the unit has failing checks
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
source_unit (string) -- Source unit link; see
GET /api/units/(int:id)/pending (boolean) -- whether the unit is pending for write
timestamp (timestamp) -- string age
last_updated (timestamp) -- last string update
- PATCH /api/units/(int: id)/¶
在 4.3 版被加入.
Performs partial update on translation unit.
- 參數值:
id (int) -- Unit ID
- Request JSON Object:
state (int) -- unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved (need review workflow enabled, see 專門的檢閱者)
target (array) -- target string
explanation (string) -- String explanation, available on source units, see 來源字串另外的資訊
extra_flags (string) -- Additional string flags, available on source units, see 使用標誌自訂行為
labels (array) -- labels, available on source units
- PUT /api/units/(int: id)/¶
在 4.3 版被加入.
Performs full update on translation unit.
- 參數值:
id (int) -- Unit ID
- Request JSON Object:
state (int) -- unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved (need review workflow enabled, see 專門的檢閱者)
target (array) -- target string
explanation (string) -- String explanation, available on source units, see 來源字串另外的資訊
extra_flags (string) -- Additional string flags, available on source units, see 使用標誌自訂行為
labels (array) -- labels, available on source units
- DELETE /api/units/(int: id)/¶
在 4.3 版被加入.
Deletes a translation unit.
- 參數值:
id (int) -- Unit ID
- GET /api/units/(int: id)/translations/¶
在 5.11 版被加入.
Returns a list of all target translation units for the given source translation unit.
- POST /api/units/(int: id)/comments/¶
在 5.12 版被加入.
Create a new comment on the given translation unit.
- 參數值:
id (int) -- Unit ID
- Request JSON Object:
scope (string) -- comment scope - global, translation (available on all non-source units), report (need review workflow enabled, see 專門的檢閱者)
comment (string) -- content of the new comment, you can use Markdown and mention users by @username.
user_email (string) -- commenter's email, can be set only by project admins and defaults to the authenticated user.
timestamp (string) -- creation timestamp of the comment, can be set only by project admins and defaults to now.
- Response JSON Object:
id (int) -- comment identifier
comment (string) -- content of the new comment
user (string) -- URL of the commenter's object
timestamp (string) -- creation timestamp of the comment
- GET /api/units/(int: id)/comments/¶
在 5.15 版被加入.
Returns a list of comments on a given translation unit
- 參數值:
id (int) -- Unit ID
- Response JSON Object:
id (int) -- comment identifier
comment (string) -- content of the comment
timestamp (string) -- creation timestamp of the comment
user (string) -- URL of the commenter's object
變更¶
- 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)/.- Query Parameters:
user (string) -- Username of the user to filter by
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 the translation change.
- 參數值:
id (int) -- Change ID
- Response JSON Object:
unit (string) -- URL of a related unit object
translation (string) -- URL of a related translation object
component (string) -- URL of a related component 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
old (string) -- previous text
details (object) -- additional details about the change
id (int) -- change identifier
螢幕擷圖¶
- GET /api/screenshots/¶
Returns a list of screenshots.
也參考
Screenshot object attributes are documented at
GET /api/screenshots/(int:id)/.
- GET /api/screenshots/(int: id)/¶
Returns information about the screenshot.
- 參數值:
id (int) -- Screenshot ID
- Response JSON Object:
name (string) -- name of a screenshot
repository_filename (string) -- repository path used to match repository-based screenshot updates
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)/
- 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
- Form Parameters:
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
- Form Parameters:
string unit_id -- Unit ID
- Response JSON Object:
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)¶
Remove source string association with screenshot.
- 參數值:
id (int) -- Screenshot ID
unit_id -- Source string unit ID
- POST /api/screenshots/¶
Creates a new screenshot.
- Form Parameters:
file image -- Uploaded file
string name -- Screenshot name
string project_slug -- 專案 slug
string component_slug -- 組件標識串
string language_code -- 語言代碼
string repository_filename -- Optional repository path used to associate later repository updates
- Response JSON Object:
name (string) -- name of a screenshot
repository_filename (string) -- repository path used to match repository-based screenshot updates
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)/
- PATCH /api/screenshots/(int: id)/¶
Edit partial information about screenshot.
- 參數值:
id (int) -- Screenshot ID
- Response JSON Object:
name (string) -- name of a screenshot
repository_filename (string) -- repository path used to match repository-based screenshot updates
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)/
- PUT /api/screenshots/(int: id)/¶
Edit full information about screenshot.
- 參數值:
id (int) -- Screenshot ID
- Response JSON Object:
name (string) -- name of a screenshot
repository_filename (string) -- repository path used to match repository-based screenshot updates
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)/¶
Delete screenshot.
- 參數值:
id (int) -- Screenshot ID
附加元件¶
在 4.4.1 版被加入.
- GET /api/addons/¶
Returns a list of add-ons.
也參考
Add-on object attributes are documented at
GET /api/addons/(int:id)/.
- GET /api/addons/(int: id)/¶
Returns information about add-on information.
- 參數值:
id (int) -- 附加元件 ID
- Response JSON Object:
name (string) -- name of an add-on
component (string) -- URL of a related component object
configuration (object) -- Optional add-on configuration
也參考
- POST /api/components/(string: project)/(string: component)/addons/¶
Creates a new add-on.
- 參數值:
project_slug (string) -- 專案 slug
component_slug (string) -- 組件標識串
- Request JSON Object:
name (string) -- name of an add-on
configuration (object) -- Optional add-on configuration
- PATCH /api/addons/(int: id)/¶
Edit partial information about add-on.
- 參數值:
id (int) -- 附加元件 ID
- Response JSON Object:
configuration (object) -- Optional add-on configuration
- PUT /api/addons/(int: id)/¶
Edit full information about add-on.
- 參數值:
id (int) -- 附加元件 ID
- Response JSON Object:
configuration (object) -- Optional add-on configuration
- DELETE /api/addons/(int: id)/¶
Delete add-on.
- 參數值:
id (int) -- 附加元件 ID
- POST /api/addons/(int: id)/trigger/¶
Trigger a manual run of an add-on that supports manual triggering.
在 5.17.1 版被加入.
- 參數值:
id (int) -- 附加元件 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
- Response JSON Object:
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) -- link to associated components; see
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
- Request JSON Object:
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
- Request JSON Object:
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
- GET /api/component-lists/(str: slug)/components/¶
在 5.0.1 版被加入: List components in a component list.
- param slug:
Component list slug
- type slug:
string
- form string component_id:
Component ID
- >json array results:
array of component objects; see
GET /api/components/(string:project)/(string:component)/
- POST /api/component-lists/(str: slug)/components/¶
Associate component with a component list.
- 參數值:
slug (string) -- Component list slug
- Form Parameters:
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) -- 組件標識串
詞彙表¶
在 4.5 版的變更: 表格現在儲存為常規組件,翻譯和字串,請使用相應的API。
工作¶
在 4.4 版被加入.
- GET /api/tasks/¶
Listing of the tasks is currently not available.
- GET /api/tasks/(str: uuid)/¶
Returns information about a task.
- 參數值:
uuid (string) -- Task UUID
- Response JSON Object:
completed (boolean) -- Whether the task has completed
progress (int) -- Task progress in percent
result (object) -- Task result or progress details
log (string) -- Task log
統計資料¶
- GET /api/(str: object)/statistics/¶
There are several statistics endpoints for objects and all of them contain same structure.
- 參數值:
object (string) -- URL path
- Response JSON Object:
total (int) -- total number of strings
total_words (int) -- total number of words
total_chars (int) -- total number of characters
last_change (timestamp) -- date of last change
translated (int) -- number of translated strings
translated_percent (float) -- percentage of translated strings
translated_words (int) -- number of translated words
translated_words_percent (float) -- percentage of translated words
translated_chars (int) -- number of translated characters
translated_chars_percent (float) -- percentage of translated characters
fuzzy (int) -- number of fuzzy (marked for edit) strings
fuzzy_words (int) -- number of fuzzy (marked for edit) words
fuzzy_chars (int) -- number of fuzzy (marked for edit) characters
fuzzy_percent (float) -- percentage of fuzzy (marked for edit) strings
fuzzy_words_percent (float) -- percentage of fuzzy (marked for edit) words
fuzzy_chars_percent (float) -- percentage of fuzzy (marked for edit) characters
failing (int) -- number of failing checks
failing_percent (float) -- percentage of failing checks
approved (int) -- number of approved strings
approved_words (int) -- number of approved words
approved_chars (int) -- number of approved characters
approved_percent (float) -- percentage of approved strings
approved_words_percent (float) -- percentage of approved words
approved_chars_percent (float) -- percentage of approved characters
readonly (int) -- number of read-only strings
readonly_words (int) -- number of read-only words
readonly -- number of read-only characters
readonly_percent (float) -- percentage of read-only strings
readonly_words_percent (float) -- percentage of read-only words
readonly_char_percent (float) -- percentage of read-only characters
suggestions (int) -- number of strings with suggestions
comments (int) -- number of strings with comments
name (string) -- object name
url (string) -- URL to access the object (if applicable)
url_translate (string) -- URL to access the translation (if applicable)
code (string) -- language code (if applicable)
指標¶
- GET /api/metrics/¶
Returns server metrics.
在 5.6.1 版的變更: Metrics can now be exposed in OpenMetrics compatible format with
?format=openmetrics.- Response JSON Object:
units (int) -- Number of units
units_translated (int) -- Number of translated units
users (int) -- Number of users
changes (int) -- Number of changes
projects (int) -- Number of projects
components (int) -- Number of components
translations (int) -- Number of translations
languages (int) -- Number of used languages
checks (int) -- Number of triggered quality checks
configuration_errors (int) -- Number of configuration errors
suggestions (int) -- Number of pending suggestions
celery_queues (object) -- Lengths of Celery queues, see 使用 Celery 的背景工作
name (string) -- Configured server name
version (string) -- Running Weblate version, included when
VERSION_DISPLAYisshoworsoft
In OpenMetrics format, the version is exposed as
weblate_info{version="..."} 1whenVERSION_DISPLAYisshoworsoft.
搜尋¶
- GET /api/search/¶
在 4.18 版被加入.
Returns site-wide search results as a list. There is no pagination on the result set, only first few matches are returned for each category.
The search looks for:
專案
類別
組件
語言
使用者
- 參數值:
q -- Search query string
- Response JSON Object:
name (str) -- Name of the matched item.
url (str) -- Web URL of the matched item.
category (str) -- Category of the matched item.
類別¶
- GET /api/categories/¶
在 5.0 版被加入.
Lists available categories. See
GET /api/categories/(int:id)/for field definitions.
- POST /api/categories/¶
在 5.0 版被加入.
Creates a new category. See
GET /api/categories/(int:id)/for field definitions.
- GET /api/categories/(int: id)/¶
在 5.0 版被加入.
- 參數值:
id (int) -- Category ID
- Response JSON Object:
name (str) -- Name of category.
slug (str) -- Slug of category.
project (str) -- Link to a project.
category (str) -- Link to a parent category.
announcements_url (string) -- URL to announcements; see
GET /api/categories/(int:id)/announcements/
- PATCH /api/categories/(int: id)/¶
在 5.0 版被加入: Edit partial information about category.
- param id:
Category ID
- type id:
int
- >json object configuration:
Optional category configuration
- PUT /api/categories/(int: id)/¶
在 5.0 版被加入: Edit full information about category.
- param id:
Category ID
- type id:
int
- >json object configuration:
Optional category configuration
- DELETE /api/categories/(int: id)/¶
在 5.0 版被加入: Delete category.
- param id:
Category ID
- type id:
int
- GET /api/categories/(int: id)/statistics/¶
在 5.5 版被加入.
Returns statistics for a category.
- 參數值:
id (int) -- Category ID
也參考
Returned attributes are described in 統計資料.
- GET /api/categories/(int: id)/announcements/¶
在 5.17.1 版被加入: Returns announcements for a category.
- param id:
Category ID
- type id:
int
- >json int id:
ID of the announcement
- >json string message:
announcement text
- >json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- >json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- >json bool notify:
send notification to subscribed users? (optional)
- POST /api/categories/(int: id)/announcements/¶
在 5.17.1 版被加入: Creates an announcement for a category.
- param id:
Category ID
- type id:
int
- <json string message:
announcement text
- <json string severity:
color of the message, one of
info(light blue),warning(yellow),danger(red),success(green)- <json date expiry:
hide after this date, ISO 8601 extended format date (optional)
- <json bool notify:
send notification to subscribed users? (optional)
- DELETE /api/categories/(int: id)/announcements/(int: announcement_id)/¶
在 5.17.1 版被加入: Deletes an announcement from a category.
- param id:
Category ID
- type id:
int
- param announcement_id:
ID of the announcement to delete
- type announcement_id:
integer
通知掛勾¶
通知鉤子允許外部應用來通知 Weblate 版本控制系統(VCS)儲存庫已經更新。
可以為專案、組件和翻譯使用儲存庫端點來更新各自的儲存庫;文件請參閱 POST /api/projects/(string:project)/repository/。
- 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.在 5.14 版被移除.
- 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.在 5.14 版被移除.
- 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 notifications
For instruction on setting up GitHub integration
- https://docs.github.com/en/get-started/customizing-your-github-workflow/exploring-integrations/about-webhooks
Generic information about GitHub Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/gitlab/¶
Special hook for handling GitLab notifications and automatically updating matching components.
也參考
- GitLab notifications
For instruction on setting up GitLab integration
- https://docs.gitlab.com/user/project/integrations/webhooks/
Generic information about GitLab Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/bitbucket/¶
Special hook for handling Bitbucket notifications and automatically updating matching components.
也參考
- Bitbucket notifications
For instruction on setting up Bitbucket integration
- https://support.atlassian.com/bitbucket-cloud/docs/manage-webhooks/
Generic information about Bitbucket Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/pagure/¶
Special hook for handling Pagure notifications and automatically updating matching components.
也參考
- Pagure notifications
For instruction on setting up Pagure integration
- https://docs.pagure.org/pagure/usage/using_webhooks.html
Generic information about Pagure Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/azure/¶
Special hook for handling Azure DevOps notifications and automatically updating matching components.
備註
Please ensure that Resource details to send is set to All, otherwise Weblate will not be able to match your Azure repository.
也參考
- Azure Repos notifications
For instruction on setting up Azure integration
- https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops
Generic information about Azure DevOps Web Hooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/gitea/¶
Special hook for handling Gitea Webhook notifications and automatically updating matching components.
也參考
- Gitea notifications
For instruction on setting up Gitea integration
- https://docs.gitea.io/en-us/webhooks/
Generic information about Gitea Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/forgejo/¶
Special hook for handling Forgejo Webhook notifications and automatically updating matching components.
也參考
- Forgejo notifications
For instruction on setting up Forgejo integration
- https://forgejo.org/docs/latest/user/webhooks/
Generic information about Forgejo Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
- POST /hooks/gitee/¶
Special hook for handling Gitee Webhook notifications and automatically updating matching components.
也參考
- Gitee notifications
For instruction on setting up Gitee integration
- https://gitee.com/help/categories/40
Generic information about Gitee Webhooks
ENABLE_HOOKSFor enabling hooks for whole Weblate
RSS 消息來源¶
翻譯的變更匯出到 RSS 頻道。
Filtered RSS feeds are available from the changes browser. These accept the same
filters as the changes page, for example action, user, exclude_user,
and period.
- GET /changes/rss/¶
Retrieves RSS feed with recent changes matching changes browsing filters.
- GET /changes/rss/(string: project)/(string: component)/(string: language)/¶
Retrieves RSS feed with recent changes matching changes browsing filters in a translation.
- GET /changes/rss/(string: project)/(string: component)/¶
Retrieves RSS feed with recent changes matching changes browsing filters in a component.
- GET /changes/rss/(string: project)/-/(string: language)/¶
Retrieves RSS feed with recent changes matching changes browsing filters in a project language.
- GET /changes/rss/-/-/(string: language)/¶
Retrieves RSS feed with recent changes matching changes browsing filters in a language.
- 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.
也參考