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.

身份驗證和通用參數

公開專案 API 不需要身份驗證就可用,儘管沒有身份驗證的請求導致嚴重的瓶頸(預設每天 100 個請求),所以推薦使用身份驗證。身份驗證使用令牌,這可以在您的簡介中得到。在 Authorization 標頭中使用它:

ANY /

對於 API的普通請求行為,標頭、狀態編碼和參數在這裡也應用於所有端點。

查詢參數:
  • format -- Response format (overrides Accept). Possible values depends on REST framework setup, by default json, csv and api are 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.

請求標頭:
  • Accept -- 相應內容的類型相依於 Accept 標頭

  • Authorization -- optional token to authenticate as Authorization: Token YOUR-TOKEN

響應標頭:
回應 JSON 物件:
  • detail (string) -- 結果的詳細描述(對於 200 OK 以外的 HTTP 狀態編碼)

  • count (int) -- 對象列表的總項目計數

  • next (string) -- 對象列表的下一頁 URL

  • previous (string) -- 對象列表的上一頁 URL

  • results (array) -- 對象列表的結果

  • url (string) -- 使用 API 存取這個資源的 URL

  • web_url (string) -- 使用瀏覽器存取這個資源的 URL

狀態編碼:

Authentication tokens

在 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)。

Form request example:

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/

Components and categories

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.

速率限制在後面的標頭中報告:

X-RateLimit-Limit

允許執行的請求數

X-RateLimit-Remaining

剩餘的執行請求數

X-RateLimit-Reset

直到速率限制窗口重設時的秒數

在 4.1 版的變更: 新增速率限制狀態的標頭。

Error responses

在 5.10 版的變更: Error responses were endpoint specific before this release.

Weblate error responses are formatted based on Error Response Format.

API 入口點

GET /api/

API 根入口點。

示例請求:

GET /api/ HTTP/1.1
Host: example.com
Accept: application/json, text/javascript
Authorization: Token YOUR-TOKEN

示例響應:

HTTP/1.0 200 OK
Date: Fri, 25 Mar 2016 09:46:12 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, HEAD, OPTIONS

{
    "projects":"http://example.com/api/projects/",
    "components":"http://example.com/api/components/",
    "translations":"http://example.com/api/translations/",
    "languages":"http://example.com/api/languages/"
}

使用者

在 4.0 版被加入.

GET /api/users/

返回使用者列表,如果有權限查看管理使用者的話。如果沒有,那麼會只看到自己的具體資訊。

查詢參數:
  • username (string) -- Username to search for

  • id (int) -- User ID to search for

也參考

使用者對象屬性被歸檔在 GET /api/users/(str:username)/

POST /api/users/

建立新使用者。

參數值:
  • username (string) -- 使用者名稱

  • full_name (string) -- 使用者全名

  • email (string) -- 使用者電子郵箱

  • is_superuser (boolean) -- 使用者是超級使用者嗎? (可選的)

  • is_active (boolean) -- 使用者是活動使用者嗎? (可選的)

  • is_bot (boolean) -- Is user bot? (optional) (used for project scoped tokens)

GET /api/users/(str: username)/

返回使用者的資訊。

參數值:
  • username (string) -- 使用者的使用者名

回應 JSON 物件:
  • username (string) -- 使用者的使用者名

  • full_name (string) -- 使用者的全名

  • email (string) -- 使用者的電子郵箱

  • is_superuser (boolean) -- 使用者是否是超級使用者

  • is_active (boolean) -- 使用者是否是活動使用者

  • is_bot (boolean) -- whether the user is bot (used for project scoped tokens)

  • date_joined (string) -- 建立使用者的日期

  • last_login (string) -- date the user last signed in

  • 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,
    "is_bot": false,
    "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) -- 使用者是否是活動使用者

  • is_bot (boolean) -- whether the user is bot (used for project scoped tokens)

  • date_joined (string) -- 建立使用者的日期

PATCH /api/users/(str: username)/

更改使用者參數。

參數值:
  • username (string) -- 使用者的使用者名

回應 JSON 物件:
  • username (string) -- 使用者的使用者名

  • full_name (string) -- 使用者的全名

  • email (string) -- 使用者的電子郵箱

  • is_superuser (boolean) -- 使用者是否是超級使用者

  • is_active (boolean) -- 使用者是否是活動使用者

  • is_bot (boolean) -- whether the user is bot (used for project scoped tokens)

  • date_joined (string) -- 建立使用者的日期

DELETE /api/users/(str: username)/

刪除所有的使用者資訊並將使用者標記為不活動使用者。

參數值:
  • username (string) -- 使用者的使用者名

POST /api/users/(str: username)/groups/

將群組與使用者關聯。

參數值:
  • username (string) -- 使用者的使用者名

表格參數:
  • string group_id -- 唯一的群組 ID

DELETE /api/users/(str: username)/groups/

在 4.13.1 版被加入.

Remove user from a group.

參數值:
  • username (string) -- 使用者的使用者名

表格參數:
  • string group_id -- 唯一的群組 ID

GET /api/users/(str: username)/statistics/

使用者的統計資料列表。

參數值:
  • username (string) -- 使用者的使用者名

回應 JSON 物件:
  • 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)/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 of notification registered

PUT /api/users/(str: username)/notifications/(int: subscription_id)/

編輯與使用者關聯的訂閱。

參數值:
  • username (string) -- 使用者的使用者名

  • subscription_id (int) -- ID of notification registered

請求 JSON 物件:
  • notification (string) -- 註冊通知的名稱

  • scope (int) -- 來自可用選擇的通知範圍

  • frequency (int) -- 通知的頻率選擇

PATCH /api/users/(str: username)/notifications/(int: subscription_id)/

編輯與使用者關聯的訂閱。

參數值:
  • username (string) -- 使用者的使用者名

  • subscription_id (int) -- ID of notification registered

請求 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/

建立新的群組。

參數值:
GET /api/groups/(int: id)/

Returns information about the group.

參數值:
  • id (int) -- 群組的 ID

回應 JSON 物件:

範例 JSON 資料:

{
    "name": "Guests",
    "defining_project": null,
    "project_selection": 3,
    "language_selection": 1,
    "url": "http://example.com/api/groups/1/",
    "roles": [
        "http://example.com/api/roles/1/",
        "http://example.com/api/roles/2/"
    ],
    "languages": [
        "http://example.com/api/languages/en/",
        "http://example.com/api/languages/cs/",
    ],
    "projects": [
        "http://example.com/api/projects/demo1/",
        "http://example.com/api/projects/demo/"
    ],
    "componentlist": "http://example.com/api/component-lists/new/",
    "components": [
        "http://example.com/api/components/demo/weblate/"
    ]
}
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

POST /api/groups/(int: id)/admins/

在 5.5 版被加入.

Add user to team admins.

參數值:
  • id (int) -- 群組的 ID

表格參數:
  • 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) -- 群組的 ID

  • user_id (integer) -- The user's ID

角色

GET /api/roles/

返回與使用者關聯的所有角色列表。如果使用者是超級使用者,那麼返回所有現有角色的列表。

也參考

角色對象屬性歸檔在 GET /api/roles/(int:id)/

POST /api/roles/

建立新角色。

參數值:
  • name (string) -- 角色名稱

  • permissions (array) -- 權限編碼名稱的列表

GET /api/roles/(int: id)/

Returns information about the role.

參數值:
  • id (int) -- 角色的ID

回應 JSON 物件:
  • name (string) -- 角色名稱

  • permissions (array) -- 權限編碼名稱的列表

範例 JSON 資料:

{
    "name": "Access repository",
    "permissions": [
        "vcs.access",
        "vcs.view"
    ],
    "url": "http://example.com/api/roles/1/",
}
PUT /api/roles/(int: id)/

更改角色參數。

參數值:
  • id (int) -- 角色的ID

回應 JSON 物件:
  • name (string) -- 角色名稱

  • permissions (array) -- 權限編碼名稱的列表

PATCH /api/roles/(int: id)/

更改角色參數。

參數值:
  • id (int) -- 角色的ID

回應 JSON 物件:
  • name (string) -- 角色名稱

  • permissions (array) -- 權限編碼名稱的列表

DELETE /api/roles/(int: id)/

刪除角色。

參數值:
  • id (int) -- 角色的ID

語言

GET /api/languages/

返回所有語言的列表。

也參考

語言對象屬性存檔在 GET /api/languages/(string:language)/

POST /api/languages/

建立新的語言。

參數值:
  • code (string) -- 語言名稱

  • name (string) -- 語言名稱

  • direction (string) -- 文字方向

  • population (int) -- 語言使用者數量

  • plural (object) -- 語言複數形式與數字

GET /api/languages/(string: language)/

Returns information about the language.

參數值:
  • language (string) -- 語言碼

回應 JSON 物件:
  • code (string) -- 語言碼

  • direction (string) -- 文字方向

  • plural (object) -- 語言複數資訊的對象

  • aliases (array) -- 語言別名的數組

請求 JSON 物件:
  • population (int) -- 語言使用者數量

範例 JSON 資料:

{
    "code": "en",
    "direction": "ltr",
    "name": "English",
    "population": 159034349015,
    "plural": {
        "id": 75,
        "source": 0,
        "number": 2,
        "formula": "n != 1",
        "type": 1
    },
    "aliases": [
        "english",
        "en_en",
        "base",
        "source",
        "eng"
    ],
    "url": "http://example.com/api/languages/en/",
    "web_url": "http://example.com/languages/en/",
    "statistics_url": "http://example.com/api/languages/en/statistics/"
}
PUT /api/languages/(string: language)/

更改語言參數。

參數值:
  • language (string) -- 語言的編碼

請求 JSON 物件:
  • name (string) -- 語言名稱

  • direction (string) -- 文字方向

  • population (int) -- 語言使用者數量

  • plural (object) -- 語言複數形細節

PATCH /api/languages/(string: language)/

更改語言參數。

參數值:
  • language (string) -- 語言的編碼

請求 JSON 物件:
  • name (string) -- 語言名稱

  • direction (string) -- 文字方向

  • population (int) -- 語言使用者數量

  • plural (object) -- 語言複數形細節

DELETE /api/languages/(string: language)/

刪除語言。

參數值:
  • language (string) -- 語言的編碼

GET /api/languages/(string: language)/statistics/

返回語言的統計資料。

參數值:
  • language (string) -- 語言碼

也參考

Returned attributes are described in 統計數據.

專案

GET /api/projects/

返回所有項目的列表。

也參考

項目對象的屬性存檔在 GET /api/projects/(string:project)/

POST /api/projects/

建立新項目。

參數值:
  • name (string) -- 專案名稱

  • slug (string) -- 項目標識串

  • web (string) -- 專案網站

GET /api/projects/(string: project)/

Returns information about the project.

參數值:
  • project (string) -- 專案 URL slug

回應 JSON 物件:

範例 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 版被加入.

透過 PATCH 請求來編輯一個專案。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

PUT /api/projects/(string: project)/

在 4.3 版被加入.

透過 PUT 請求來編輯一個專案。

參數值:
  • project (string) -- 專案 URL slug

DELETE /api/projects/(string: project)/

刪除專案。

參數值:
  • project (string) -- 專案 URL slug

GET /api/projects/(string: project)/changes/

返回項目更改的列表。這本質上是仔細檢查的項目 GET /api/changes/ 接收相同的參數。

參數值:
  • project (string) -- 專案 URL slug

回應 JSON 物件:
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) -- 專案 URL slug

查詢參數:
  • format (string) -- The archive format to use; If not specified, defaults to zip; Supported formats: zip and zip:CONVERSION where CONVERSION is 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) -- 專案 URL slug

回應 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 slug

請求 JSON 物件:
  • operation (string) -- Operation to perform: one of push, pull, commit, reset, cleanup, file-sync, file-scan

回應 JSON 物件:
  • result (boolean) -- 操作的結果

CURL 示例:

curl \
    -d operation=pull \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/projects/hello/repository/

JSON 請求範例:

POST /api/projects/hello/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20

{"operation":"pull"}

JSON 回應範例:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, POST, HEAD, OPTIONS

{"result":true}
GET /api/projects/(string: project)/components/

返回給定項目的翻譯組件列表。

參數值:
  • project (string) -- 專案 URL slug

回應 JSON 物件:
POST /api/projects/(string: project)/components/

在 4.3 版的變更: zipfiledocfile 參數現在可被無 VCS 的元件所接受,見 本地檔案.

在 4.6 版的變更: The cloned repositories are now automatically shared within a project using Weblate 內部網址. Use disable_autoshare to turn off this.

在給定的項目中新建翻譯組件。

提示

Use Weblate 內部網址 when creating multiple components from a single VCS repository.

備註

多數元件的新建發生在後台。檢查新建元件的 task_url 屬性,並按照那裡的步驟進行。

參數值:
  • project (string) -- 專案 URL slug

表格參數:
  • file zipfile -- 上傳到 Weblate 用於翻譯初始化的 ZIP 文件

  • file docfile -- 要翻譯的文件

  • boolean disable_autoshare -- Disables automatic repository sharing via Weblate 內部網址.

請求 JSON 物件:
回應 JSON 物件:

JSON can not be used when uploading the files using the zipfile and docfile parameters. 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",
        "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",
    "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

{
    "file_format": "po",
    "filemask": "po/*.po",
    "name": "Weblate",
    "slug": "weblate",
    "repo": "weblate://weblate/hello",
    "template": "",
    "new_base": "po/hello.pot",
    "vcs": "git"
}

JSON 回應範例:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, POST, HEAD, OPTIONS

{
    "branch": "main",
    "file_format": "po",
    "filemask": "po/*.po",
    "git_export": "",
    "license": "",
    "license_url": "",
    "name": "Weblate",
    "slug": "weblate",
    "project": {
        "name": "Hello",
        "slug": "hello",
        "source_language": {
            "code": "en",
            "direction": "ltr",
             "population": 159034349015,
            "name": "English",
            "url": "http://example.com/api/languages/en/",
            "web_url": "http://example.com/languages/en/"
        },
        "url": "http://example.com/api/projects/hello/",
        "web": "https://weblate.org/",
        "web_url": "http://example.com/projects/hello/"
    },
    "repo": "file:///home/nijel/work/weblate-hello",
    "template": "",
    "new_base": "",
    "url": "http://example.com/api/components/hello/weblate/",
    "vcs": "git",
    "web_url": "http://example.com/projects/hello/weblate/"
}
GET /api/projects/(string: project)/languages/

對項目內的所有語言返回編頁的統計資料。

參數值:
  • project (string) -- 專案 URL slug

回應 JSON 物件:
  • results (array) -- 翻譯統計資料對象的矩陣

  • language (string) -- 語言名稱

  • code (string) -- 語言代碼

  • total (int) -- 字串的總數

  • translated (int) -- 已翻譯的字串數量

  • translated_percent (float) -- 已翻譯字串的百分比

  • total_words (int) -- 詞的總數

  • translated_words (int) -- 已翻譯詞的數量

  • words_percent (float) -- 已翻譯詞的百分比

GET /api/projects/(string: project)/statistics/

返回項目的統計資料。

參數值:
  • project (string) -- 專案 URL 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:

專案 URL slug

type project:

字串

GET /api/projects/(string: project)/labels/

在 5.3 版被加入: Returns labels for a project.

param project:

專案 URL slug

type project:

字串

>json int id:

標籤 ID

>json string name:

標籤名稱

>json string color:

標籤顏色

POST /api/projects/(string: project)/labels/

在 5.3 版被加入: Creates a label for a project.

param project:

專案 URL slug

type project:

字串

<json string name:

標籤名稱

<json string color:

標籤顏色

GET /api/projects/(string: project)/credits/

Returns contributor credits for a project.

在 5.7 版被加入.

參數值:
  • project (string) -- 專案 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

回應 JSON 物件:
  • 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) -- 專案 URL slug

回應 JSON 物件:
  • 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) -- 專案 URL slug

表格參數:
  • string service -- Service name

  • string configuration -- Service configuration in JSON

組件

提示

Use POST /api/projects/(string:project)/components/ to create new components.

GET /api/components/

返回翻譯組件的列表。

也參考

組件對象屬性存檔在 GET /api/components/(string:project)/(string:component)/

GET /api/components/(string: project)/(string: component)/

Returns information about the translation component.

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:

範例 JSON 資料:

{
    "branch": "main",
    "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",
             "population": 159034349015,
            "name": "English",
            "url": "http://example.com/api/languages/en/",
            "web_url": "http://example.com/languages/en/"
        },
        "url": "http://example.com/api/projects/hello/",
        "web": "https://weblate.org/",
        "web_url": "http://example.com/projects/hello/"
    },
    "source_language": {
        "code": "en",
        "direction": "ltr",
        "population": 159034349015,
        "name": "English",
        "url": "http://example.com/api/languages/en/",
        "web_url": "http://example.com/languages/en/"
    },
    "repo": "file:///home/nijel/work/weblate-hello",
    "template": "",
    "new_base": "",
    "url": "http://example.com/api/components/hello/weblate/",
    "vcs": "git",
    "web_url": "http://example.com/projects/hello/weblate/"
}
PATCH /api/components/(string: project)/(string: component)/

透過 PATCH 請求來編輯一個元件。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • source_language (string) -- 項目源語言代碼(可選)

請求 JSON 物件:
  • name (string) -- 組件名稱

  • slug (string) -- 組件的 slug

  • repo (string) -- VCS 儲存庫網址

CURL 示例:

curl \
    --data-binary '{"name": "new name"}' \
    -H "Content-Type: application/json" \
    -H "Authorization: Token TOKEN" \
    PATCH http://example.com/api/projects/hello/components/

JSON 請求範例:

PATCH /api/projects/hello/components/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20

{
    "name": "new name"
}

JSON 回應範例:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, POST, HEAD, OPTIONS

{
    "branch": "main",
    "file_format": "po",
    "filemask": "po/*.po",
    "git_export": "",
    "license": "",
    "license_url": "",
    "name": "new name",
    "slug": "weblate",
    "project": {
        "name": "Hello",
        "slug": "hello",
        "source_language": {
            "code": "en",
            "direction": "ltr",
            "population": 159034349015,
            "name": "English",
            "url": "http://example.com/api/languages/en/",
            "web_url": "http://example.com/languages/en/"
        },
        "url": "http://example.com/api/projects/hello/",
        "web": "https://weblate.org/",
        "web_url": "http://example.com/projects/hello/"
    },
    "repo": "file:///home/nijel/work/weblate-hello",
    "template": "",
    "new_base": "",
    "url": "http://example.com/api/components/hello/weblate/",
    "vcs": "git",
    "web_url": "http://example.com/projects/hello/weblate/"
}
PUT /api/components/(string: project)/(string: component)/

透過 PUT 請求來編輯一個元件。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

請求 JSON 物件:
  • branch (string) -- VCS 儲存庫分支

  • file_format (string) -- 翻譯的文件格式

  • filemask (string) -- 儲存庫中翻譯檔的遮罩

  • name (string) -- 組件名稱

  • slug (string) -- 組件的 slug

  • repo (string) -- VCS 儲存庫網址

  • template (string) -- 但語言翻譯的譯文模板文件

  • new_base (string) -- 用於新增新翻譯的譯文模板文件

  • vcs (string) -- 版本控制系統

DELETE /api/components/(string: project)/(string: component)/

刪除一個組件。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

GET /api/components/(string: project)/(string: component)/changes/

返回組件更改的列表。這本質上是仔細檢查的組件 GET /api/changes/ 接相同參數。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:
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) -- 專案 URL slug

  • component (string) -- 組件 URL slug

查詢參數:
  • format (string) -- The archive format to use; If not specified, defaults to zip; Supported formats: zip and zip:CONVERSION where CONVERSION is one of converters listed at 下載翻譯.

GET /api/components/(string: project)/(string: component)/screenshots/

返回組件螢幕截圖的列表。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:
GET /api/components/(string: project)/(string: component)/lock/

返回組件鎖定狀態。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:
  • locked (boolean) -- 組件是否因更新而鎖定

範例 JSON 資料:

{
    "locked": false
}
POST /api/components/(string: project)/(string: component)/lock/

設定組件鎖定狀態。

響應時間與 GET /api/components/(string:project)/(string:component)/lock/ 相同。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

請求 JSON 物件:
  • lock -- 是否鎖定的布爾值。

CURL 示例:

curl \
    -d lock=true \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/components/hello/weblate/repository/

JSON 請求範例:

POST /api/components/hello/weblate/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20

{"lock": true}

JSON 回應範例:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, POST, HEAD, OPTIONS

{"locked":true}
GET /api/components/(string: project)/(string: component)/repository/

Returns information about the VCS repository status.

響應與 GET /api/projects/(string:project)/repository/ 的相同。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:
  • needs_commit (boolean) -- 是否有待定的更改要送交

  • needs_merge (boolean) -- 是否有上游更改要合併

  • needs_push (boolean) -- 是否有本地更改要推送

  • remote_commit (string) -- Remote commit information

  • status (string) -- 由版本控制系統(VCS)報告的 VCS 狀態

  • merge_failure -- 描述合併失敗的文本,沒有的話為空

POST /api/components/(string: project)/(string: component)/repository/

在版本控制系統(VCS)儲存庫執行給定的操作。

文件請參見 POST /api/projects/(string:project)/repository/

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

請求 JSON 物件:
  • operation (string) -- 執行的操作: push, pull, commit, reset, cleanup 之一

回應 JSON 物件:
  • result (boolean) -- 操作的結果

CURL 示例:

curl \
    -d operation=pull \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/components/hello/weblate/repository/

JSON 請求範例:

POST /api/components/hello/weblate/repository/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20

{"operation":"pull"}

JSON 回應範例:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, POST, HEAD, OPTIONS

{"result":true}
GET /api/components/(string: project)/(string: component)/monolingual_base/

為單語言翻譯下載譯文模板文件。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

GET /api/components/(string: project)/(string: component)/new_template/

為新的翻譯下載模板文件。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

GET /api/components/(string: project)/(string: component)/translations/

返回給定組件中翻譯對象的列表。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:
POST /api/components/(string: project)/(string: component)/translations/

在給定組件中新建新的翻譯。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

請求 JSON 物件:
回應 JSON 物件:
  • result (object) -- 新建的新翻譯對象

CURL 示例:

curl \
    -d language_code=cs \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/projects/hello/components/

JSON 請求範例:

POST /api/projects/hello/components/ HTTP/1.1
Host: example.com
Accept: application/json
Content-Type: application/json
Authorization: Token TOKEN
Content-Length: 20

{"language_code": "cs"}

JSON 回應範例:

HTTP/1.0 200 OK
Date: Tue, 12 Apr 2016 09:32:50 GMT
Server: WSGIServer/0.1 Python/2.7.11+
Vary: Accept, Accept-Language, Cookie
X-Frame-Options: SAMEORIGIN
Content-Type: application/json
Content-Language: en
Allow: GET, POST, HEAD, OPTIONS

{
    "failing_checks": 0,
    "failing_checks_percent": 0,
    "failing_checks_words": 0,
    "filename": "po/cs.po",
    "fuzzy": 0,
    "fuzzy_percent": 0.0,
    "fuzzy_words": 0,
    "have_comment": 0,
    "have_suggestion": 0,
    "is_template": false,
    "is_source": false,
    "language": {
        "code": "cs",
        "direction": "ltr",
        "population": 1303174280
        "name": "Czech",
        "url": "http://example.com/api/languages/cs/",
        "web_url": "http://example.com/languages/cs/"
    },
    "language_code": "cs",
    "id": 125,
    "last_author": null,
    "last_change": null,
    "share_url": "http://example.com/engage/hello/cs/",
    "total": 4,
    "total_words": 15,
    "translate_url": "http://example.com/translate/hello/weblate/cs/",
    "translated": 0,
    "translated_percent": 0.0,
    "translated_words": 0,
    "url": "http://example.com/api/translations/hello/weblate/cs/",
    "web_url": "http://example.com/projects/hello/weblate/cs/"
}
GET /api/components/(string: project)/(string: component)/statistics/

對組件內所有的翻譯返回分頁的統計資料。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

也參考

Returned attributes are described in 統計數據.

Returns projects linked with a component.

在 4.5 版被加入.

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

回應 JSON 物件:
POST /api/components/(string: project)/(string: component)/links/

Associate project with a component.

在 4.5 版被加入.

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

表格參數:
  • string project_slug -- 項目標識串

Remove association of a project with a component.

在 4.5 版被加入.

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 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) -- 專案 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

回應 JSON 物件:
  • 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/translations/

返回翻譯的列表。

GET /api/translations/(string: project)/(string: component)/(string: language)/

Returns information about the translation.

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

回應 JSON 物件:

範例 JSON 資料:

{
    "component": {
        "branch": "main",
        "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",
                "population": 159034349015,
                "name": "English",
                "url": "http://example.com/api/languages/en/",
                "web_url": "http://example.com/languages/en/"
            },
            "url": "http://example.com/api/projects/hello/",
            "web": "https://weblate.org/",
            "web_url": "http://example.com/projects/hello/"
        },
        "repo": "file:///home/nijel/work/weblate-hello",
        "slug": "weblate",
        "template": "",
        "url": "http://example.com/api/components/hello/weblate/",
        "vcs": "git",
        "web_url": "http://example.com/projects/hello/weblate/"
    },
    "failing_checks": 3,
    "failing_checks_percent": 75.0,
    "failing_checks_words": 11,
    "filename": "po/cs.po",
    "fuzzy": 0,
    "fuzzy_percent": 0.0,
    "fuzzy_words": 0,
    "have_comment": 0,
    "have_suggestion": 0,
    "is_template": false,
    "language": {
        "code": "cs",
        "direction": "ltr",
        "population": 1303174280
        "name": "Czech",
        "url": "http://example.com/api/languages/cs/",
        "web_url": "http://example.com/languages/cs/"
    },
    "language_code": "cs",
    "last_author": "Weblate Admin",
    "last_change": "2016-03-07T10:20:05.499",
    "revision": "7ddfafe6daaf57fc8654cc852ea6be212b015792",
    "share_url": "http://example.com/engage/hello/cs/",
    "total": 4,
    "total_words": 15,
    "translate_url": "http://example.com/translate/hello/weblate/cs/",
    "translated": 4,
    "translated_percent": 100.0,
    "translated_words": 15,
    "url": "http://example.com/api/translations/hello/weblate/cs/",
    "web_url": "http://example.com/projects/hello/weblate/cs/"
}
DELETE /api/translations/(string: project)/(string: component)/(string: language)/

刪除一個翻譯。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

GET /api/translations/(string: project)/(string: component)/(string: language)/changes/

返回翻譯更改的列表。這本質上是仔細檢查的翻譯 GET /api/changes/ 接受相同參數。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

回應 JSON 物件:
GET /api/translations/(string: project)/(string: component)/(string: language)/units/

返回翻譯單元的列表。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

  • q (string) -- Search query string 搜尋 (optional)

回應 JSON 物件:
POST /api/translations/(string: project)/(string: component)/(string: language)/units/

Add new unit.

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

請求 JSON 物件:
  • 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)/

回應 JSON 物件:
POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/

觸發自動翻譯。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

請求 JSON 物件:
  • mode (string) -- 自動翻譯模式

  • filter_type (string) -- 自動翻譯篩選類型

  • auto_source (string) -- Automatic translation source - mt or others

  • component (string) -- 啟用對專案共享翻譯記憶庫的貢獻,以獲取額外組件的存取權限。

  • engines (array) -- 機器翻譯引擎

  • threshold (string) -- 分數閾值

GET /api/translations/(string: project)/(string: component)/(string: language)/file/

下載儲存在 VCS 中的目前翻譯文件(不帶 format 參數)或將其轉換為另一格式(見 下載翻譯)。

備註

這個 API 端點使用了不同於API其餘的邏輯來輸出,它在整個文件而不是在資料上操作。接受的``format``參數組不同,沒有這個參數會將翻譯文件儲存在版本控制系統(VCS)中。

響應標頭:
請求標頭:
  • If-Modified-Since -- Skips response if the file has not been modified since that time.

查詢參數:
  • format -- File format to use; if not specified no format conversion happens; see 下載翻譯 for supported formats

  • q (string) -- Filter downloaded strings, see 搜尋頁面, only applicable when conversion is in place (format is specified).

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

POST /api/translations/(string: project)/(string: component)/(string: language)/file/

上傳帶有翻譯的新文件。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

表格參數:
  • string conflicts -- How to deal with conflicts (ignore, replace-translated or replace-approved), see 衝突處理

  • file file -- 上傳文件

  • string email -- 作者郵件信箱

  • string author -- 作者姓名

  • 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.

響應與 GET /api/components/(string:project)/(string:component)/repository/ 的相同。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

POST /api/translations/(string: project)/(string: component)/(string: language)/repository/

在版本控制系統(VCS)儲存庫上執行給定的操作。

文件請參見 POST /api/projects/(string:project)/repository/

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

請求 JSON 物件:
  • operation (string) -- 執行的操作: push, pull, commit, reset, cleanup 之一

回應 JSON 物件:
  • result (boolean) -- 操作的結果

GET /api/translations/(string: project)/(string: component)/(string: language)/statistics/

返回具體的翻譯統計資料。

參數值:
  • project (string) -- 專案 URL slug

  • component (string) -- 組件 URL slug

  • language (string) -- 翻譯語言代碼

也參考

Returned attributes are described in 統計數據.

記憶

在 4.14 版被加入.

GET /api/memory/

Returns a list of memory results.

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/

返回翻譯單元的列表。

參數值:
  • q (string) -- Search query string 搜尋 (optional)

也參考

單元對象屬性存檔在 GET /api/units/(int:id)/

GET /api/units/(int: id)/

在 4.3 版的變更: targetsource 現在是矩陣,來適當的處理多個字串。

在 5.6 版的變更: The last_updated attribute is now exposed.

Returns information about the translation unit.

參數值:
  • id (int) -- 單元 ID

回應 JSON 物件:
  • translation (string) -- 相關翻譯對象的 URL

  • source (array) -- 來源字串

  • previous_source (string) -- 用於模糊匹配的之前的源字串

  • target (array) -- 目標字串

  • id_hash (string) -- 單元的唯一識別文字

  • content_hash (string) -- 源字串的唯一識別文字

  • location (string) -- 來源碼中單元的位置

  • context (string) -- 翻譯單元的語境

  • note (string) -- 翻譯單元的註解

  • flags (string) -- 翻譯單元的標記

  • labels (array) -- 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) -- 是否為 fuzzy 或標記為需檢閱

  • translated (boolean) -- whether the unit is translated

  • approved (boolean) -- whether the translation is approved

  • position (int) -- 翻譯文件中的單元位置

  • 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) -- 源詞彙的數量

  • priority (int) -- 翻譯優先級;100為預設值

  • id (int) -- 單元識別問題

  • explanation (string) -- 字串的解釋,可在源單元獲得,請參見 源字串另外的資訊

  • extra_flags (string) -- 另外的字串標記,可在源單元獲得,請參見 使用標誌自定義行為

  • web_url (string) -- 單元可以被編輯的 URL

  • source_unit (string) -- 源單元連結;請參見 GET /api/units/(int:id)/

  • pending (boolean) -- 是否為等候寫入

  • timestamp (timestamp) -- string age

  • last_updated (timestamp) -- last string update

PATCH /api/units/(int: id)/

在 4.3 版被加入.

對翻譯單元執行部分更新。

參數值:
  • id (int) -- 單元 ID

請求 JSON 物件:
  • state (int) -- unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved (need review workflow enabled, see 專門的審核者)

  • target (array) -- 目標字串

  • explanation (string) -- 字串的解釋,可在源單元獲得,請參見 源字串另外的資訊

  • extra_flags (string) -- 另外的字串標記,可在源單元獲得,請參見 使用標誌自定義行為

  • labels (array) -- 標籤,在來源單位上可用

PUT /api/units/(int: id)/

在 4.3 版被加入.

對翻譯單元執行完整更新。

參數值:
  • id (int) -- 單元 ID

請求 JSON 物件:
  • state (int) -- unit state, 0 - untranslated, 10 - needs editing, 20 - translated, 30 - approved (need review workflow enabled, see 專門的審核者)

  • target (array) -- 目標字串

  • explanation (string) -- 字串的解釋,可在源單元獲得,請參見 源字串另外的資訊

  • extra_flags (string) -- 另外的字串標記,可在源單元獲得,請參見 使用標誌自定義行為

  • labels (array) -- 標籤,在來源單位上可用

DELETE /api/units/(int: id)/

在 4.3 版被加入.

刪除一個翻譯單元。

參數值:
  • id (int) -- 單元 ID

更動

GET /api/changes/

在 4.1 版的變更: 更改的篩選在 4.1 版本引入。

返回翻譯更改的列表。

也參考

更改對象的屬性存檔在 GET /api/changes/(int:id)/

查詢參數:
  • user (string) -- 篩選使用者的使用者名稱

  • action (int) -- 篩選的動作,可以多次使用

  • timestamp_after (timestamp) -- ISO 8601 格式的時間標籤,列出此時間之後的更改

  • timestamp_before (timestamp) -- ISO 8601 格式的時間標籤,列出此時間之前的更改

GET /api/changes/(int: id)/

Returns information about the translation change.

參數值:
  • id (int) -- 變更 ID

回應 JSON 物件:
  • unit (string) -- 相關單元物件的網址

  • translation (string) -- 相關翻譯對象的 URL

  • component (string) -- 相關組件物件的網址

  • user (string) -- 相關使用者對象的 URL

  • author (string) -- 相關作者對象的 URL

  • timestamp (timestamp) -- 事件時間戳記

  • action (int) -- 動作的幾種識別

  • action_name (string) -- 動作的文本描述

  • target (string) -- event changed text

  • old (string) -- previous text

  • details (object) -- additional details about the change

  • id (int) -- 更改的識別文字

螢幕擷圖

GET /api/screenshots/

返回螢幕截圖字串資訊的列表。

也參考

螢幕截圖對象的屬性存檔在 GET /api/screenshots/(int:id)/

GET /api/screenshots/(int: id)/

Returns information about the screenshot.

參數值:
  • id (int) -- 螢幕擷圖 ID

回應 JSON 物件:
GET /api/screenshots/(int: id)/file/

下載螢幕截圖的圖片。

參數值:
  • id (int) -- 螢幕擷圖 ID

POST /api/screenshots/(int: id)/file/

替換螢幕截圖。

參數值:
  • id (int) -- 螢幕擷圖 ID

表格參數:
  • file image -- 上傳文件

CURL 示例:

curl -X POST \
    -F image=@image.png \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/screenshots/1/file/
POST /api/screenshots/(int: id)/units/

與螢幕截圖相關的源字串。

參數值:
  • id (int) -- 螢幕擷圖 ID

表格參數:
  • string unit_id -- 單元 ID

回應 JSON 物件:
DELETE /api/screenshots/(int: id)/units/(int: unit_id)

Remove source string association with screenshot.

參數值:
  • id (int) -- 螢幕擷圖 ID

  • unit_id -- 來源字串單元 ID

POST /api/screenshots/

新建新的螢幕截圖。

表格參數:
  • file image -- 上傳文件

  • string name -- 畫面快照名稱

  • string project_slug -- 項目標識串

  • string component_slug -- 組件標識串

  • string language_code -- 語言碼

回應 JSON 物件:
PATCH /api/screenshots/(int: id)/

編輯有關螢幕擷圖的部分資訊。

參數值:
  • id (int) -- 螢幕擷圖 ID

回應 JSON 物件:
PUT /api/screenshots/(int: id)/

編輯有關螢幕擷圖的完整資訊。

參數值:
  • id (int) -- 螢幕擷圖 ID

回應 JSON 物件:
DELETE /api/screenshots/(int: id)/

刪除螢幕擷圖。

參數值:
  • id (int) -- 螢幕擷圖 ID

附加元件

在 4.4.1 版被加入.

GET /api/addons/

返回附加元件列表。

也參考

Add-on object attributes are documented at GET /api/addons/(int:id)/.

GET /api/addons/(int: id)/

傳回有關附加元件的資訊。

參數值:
  • id (int) -- Add-on ID

回應 JSON 物件:
  • name (string) -- 附加元件的名稱

  • component (string) -- 相關組件物件的網址

  • configuration (object) -- 選擇性的附加元件組態

也參考

附加元件

POST /api/components/(string: project)/(string: component)/addons/

建立一個新的附加元件。

參數值:
  • project_slug (string) -- 項目標識串

  • component_slug (string) -- 組件標識串

請求 JSON 物件:
  • name (string) -- 附加元件的名稱

  • configuration (object) -- 選擇性的附加元件組態

PATCH /api/addons/(int: id)/

編輯有關附加元件的部分資訊。

參數值:
  • id (int) -- Add-on ID

回應 JSON 物件:
  • configuration (object) -- 選擇性的附加元件組態

PUT /api/addons/(int: id)/

編輯有關附加元件的完整資訊。

參數值:
  • id (int) -- Add-on ID

回應 JSON 物件:
  • configuration (object) -- 選擇性的附加元件組態

DELETE /api/addons/(int: id)/

刪除附加元件。

參數值:
  • id (int) -- Add-on ID

組件列表

在 4.0 版被加入.

GET /api/component-lists/

返回組件列表的列表。

也參考

組件列表對象屬性存檔在 GET /api/component-lists/(str:slug)/

GET /api/component-lists/(str: slug)/

返回組件列表的資訊。

參數值:
  • slug (string) -- 組件列表的標識串

回應 JSON 物件:
  • name (string) -- 組件列表的名稱

  • slug (string) -- 組件列表的表示串

  • show_dashboard (boolean) -- 是否在儀錶板上顯示

  • components (array) -- 相關聯組件的連接;請參見 GET /api/components/(string:project)/(string:component)/

  • auto_assign (array) -- 自動分配規則

PUT /api/component-lists/(str: slug)/

更改組件列表參數。

參數值:
  • slug (string) -- 組件列表的標識串

請求 JSON 物件:
  • name (string) -- 組件列表的名稱

  • slug (string) -- 組件列表的表示串

  • show_dashboard (boolean) -- 是否在儀錶板上顯示

PATCH /api/component-lists/(str: slug)/

更改組件列表參數。

參數值:
  • slug (string) -- 組件列表的標識串

請求 JSON 物件:
  • name (string) -- 組件列表的名稱

  • slug (string) -- 組件列表的表示串

  • show_dashboard (boolean) -- 是否在儀錶板上顯示

DELETE /api/component-lists/(str: slug)/

刪除組件列表。

參數值:
  • slug (string) -- 組件列表的標識串

GET /api/component-lists/(str: slug)/components/

在 5.0.1 版被加入: 列出組件列表中的組件。

param slug:

組件列表的標識串

type slug:

字串

form string component_id:

組件 ID

>json array results:

組件對象的矩陣;請參見 GET /api/components/(string:project)/(string:component)/

POST /api/component-lists/(str: slug)/components/

使組件與組件列表相關。

參數值:
  • slug (string) -- 組件列表的標識串

表格參數:
  • string component_id -- 組件 ID

DELETE /api/component-lists/(str: slug)/components/(str: component_slug)

將組件與組件列表接觸相關性。

參數值:
  • slug (string) -- 組件列表的標識串

  • component_slug (string) -- 組件標識串

詞彙表

在 4.5 版的變更: 表格現在儲存為常規元件,翻譯和字串,請使用相應的API。

任務

在 4.4 版被加入.

GET /api/tasks/

Listing of the tasks is currently not available.

GET /api/tasks/(str: uuid)/

傳回有關任務的資訊。

參數值:
  • uuid (string) -- 任務 UUID

回應 JSON 物件:
  • completed (boolean) -- Whether the task has completed

  • progress (int) -- 任務進度百分比

  • result (object) -- 任務結果或過程細節

  • log (string) -- 任務日誌

統計數據

GET /api/(str: object)/statistics/

There are several statistics endpoints for objects and all of them contain same structure.

參數值:
  • object (string) -- 網址路徑

回應 JSON 物件:
  • total (int) -- 字串的總數

  • total_words (int) -- 詞的總數

  • total_chars (int) -- total number of characters

  • last_change (timestamp) -- 上次更改的日期

  • translated (int) -- 已翻譯的字串數量

  • translated_percent (float) -- 已翻譯字串的百分比

  • translated_words (int) -- 已翻譯詞的數量

  • translated_words_percent (float) -- 已翻譯詞的百分比

  • translated_chars (int) -- 已翻譯字元的數量

  • translated_chars_percent (float) -- 已翻譯字元的百分比

  • 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) -- 模糊字串 (標記為需要編輯)的百分比

  • fuzzy_words_percent (float) -- percentage of fuzzy (marked for edit) words

  • fuzzy_chars_percent (float) -- percentage of fuzzy (marked for edit) characters

  • failing (int) -- 檢查失敗的數量

  • failing_percent (float) -- 檢查失敗的百分比

  • approved (int) -- 已核可的字串數量

  • approved_words (int) -- 已核可的字數

  • approved_chars (int) -- 已核可的字元數

  • approved_percent (float) -- 已核可字串的百分比

  • approved_words_percent (float) -- percentage of approved words

  • approved_chars_percent (float) -- percentage of approved characters

  • readonly (int) -- 唯讀字串的數量

  • readonly_words (int) -- number of read-only words

  • readonly -- 唯讀字元的數量

  • 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) -- 物件名稱

  • 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.

回應 JSON 物件:
  • units (int) -- Number of units

  • units_translated (int) -- Number of translated units

  • users (int) -- Number of users

  • changes (int) -- 變更數

  • projects (int) -- Number of projects

  • components (int) -- 元件數目

  • 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) -- Celery 排程序列的長度。參閱 使用 Celery 的後台任務

  • name (string) -- Configured server name

類別

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) -- 類別 ID

回應 JSON 物件:
  • name (str) -- Name of category.

  • slug (str) -- Slug of category.

  • project (str) -- 連結至一個專案。

  • category (str) -- Link to a parent category.

PATCH /api/categories/(int: id)/

在 5.0 版被加入: 編輯有關類別的部分資訊。

參數 id:

類別 ID

類型 id:

int

>json object configuration:

Optional category configuration

PUT /api/categories/(int: id)/

在 5.0 版被加入: 編輯有關類別的完整資訊。

參數 id:

類別 ID

類型 id:

int

>json object configuration:

Optional category configuration

DELETE /api/categories/(int: id)/

在 5.0 版被加入: 刪除類別。

參數 id:

類別 ID

類型 id:

int

GET /api/categories/(int: id)/statistics/

在 5.5 版被加入.

Returns statistics for a category.

參數值:
  • project (int) -- 類別 ID

也參考

Returned attributes are described in 統計數據.

通知掛勾

通知鉤子允許外部應用來通知 Weblate 版本控制系統(VCS)儲存庫已經更新。

可以為專案、組件和翻譯使用儲存庫端點來更新各自的儲存庫;文件請參見 POST /api/projects/(string:project)/repository/

GET /hooks/update/(string: project)/(string: component)/

在 2.6 版之後被棄用: 請使用 POST /api/components/(string:project)/(string:component)/repository/ 來替代,它使用 ACL 限制的身份驗證而工作正常。

觸發組件的更新(從版本控制系統 VCS 拉取並掃描翻譯的更改)。

GET /hooks/update/(string: project)/

在 2.6 版之後被棄用: 請使用 POST /api/projects/(string:project)/repository/ 來替代,它使用 ACL 限制的身份驗證而工作正常。

觸發項目中所有組件的更新(從版本控制系統 VCS 拉取並掃描翻譯的更改)。

POST /hooks/github/

處理 Github 通知與自動更新匹配組件的特殊鉤子。

備註

GitHub 包括了對通知 Weblate 的直接支援:在儲存庫設定中啟動 Weblate 服務掛勾,並將 URL 設定為您的 Weblate 安裝的 URL。

也參考

從 GitHub 自動接收更改

關於設定 Github 整合的指令

https://docs.github.com/en/get-started/customizing-your-github-workflow/exploring-integrations/about-webhooks

GitHub Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitlab/

處理 GitLab 通知並自動更新匹配組件的特殊鉤子。

也參考

從 GitLab 自動接收更改

關於設定 GitLab 整合的指示

https://docs.gitlab.com/ee/user/project/integrations/webhooks.html

關於 GitLab Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/bitbucket/

處理 Bitbucket 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Bitbucket 自動接收更改

關於設定 Bitbucket 整合的指示

https://support.atlassian.com/bitbucket-cloud/docs/manage-webhooks/

關於 Bitbucket Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/pagure/

處理 Pagure 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Pagure 自動接受更改

關於設定 Pagure 整合的指示

https://docs.pagure.org/pagure/usage/using_webhooks.html

關於 Pagure Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/azure/

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 自動接收更改

關於設定 Azure 整合的指示

https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops

Generic information about Azure DevOps Web Hooks

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitea/

處理 Gitea Webhook 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Gitea Repos 自動接收更改

關於設定 Gitea 整合的指示

https://docs.gitea.io/zh-tw/webhooks/

關於 Gitea Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitee/

處理 Gitee Webhook 通知並自動更新匹配的組件的特殊鉤子。

也參考

從 Gitee Repos 自動接收更改

關於設定 Gitee 整合的指示

https://gitee.com/help/categories/40

關於 Gitee Webhooks 的一般資訊

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

RSS 消息來源

翻譯的更改導出到 RSS 頻道。

GET /exports/rss/(string: project)/(string: component)/(string: language)/

用翻譯近期的更改檢索 RSS 頻道。

GET /exports/rss/(string: project)/(string: component)/

用組件的近期更改檢索 RSS 頻道。

GET /exports/rss/(string: project)/

用項目的近期更改檢索 RSS 頻道。

GET /exports/rss/language/(string: language)/

用語言的近期更改檢索 RSS 頻道。

GET /exports/rss/

用 Weblate 事件的近期更改檢索 RSS 頻道。

也參考

RSS on Wikipedia