Weblate 的 REST API

在 2.6 版本新加入: 從 Weblate 2.6 開始可以使用 REST API。

API 可以在 /api/ URL上訪問,並且它基於 Django REST framework。你可以直接使用或參考 Weblate 客戶端

身份驗證和通用參數

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

ANY /

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

查詢參數
  • format – 響應格式(覆蓋了 Accept)。可能的值依賴於 REST 框架設置,默認支持 jsonapi。後者為 API 提供了 web 瀏覽器接口。

  • page – Returns given page of paginated results (use next and previous fields in response to automate the navigation).

請求標頭
  • Accept – 相應內容的類型依賴於 Accept 標頭

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

響應標頭
Response JSON Object
  • 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 his 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/

Passing Parameters Examples

對於 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 request example:

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 example:

curl \
    --data-binary '{"operation":"pull"}' \
    -H "Content-Type: application/json" \
    -H "Authorization: Token TOKEN" \
    http://example.com/api/components/hello/weblate/repository/

API 頻次限制

這個 API 請求限制了速率;對於匿名用戶默認配置限制為每天 100 個請求,對於身份驗證的用戶限制為每小時 5000 個請求。

速率限制可以在:file:settings.py 中調整;如何配置它的更多細節請參見`Throttling in Django REST framework documentation <https://www.django-rest-framework.org/api-guide/ throttling/>`_ 。

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 版本變更: 添加速率限制狀態的標頭。

API Entry Point

GET /api/

API 根入口點。

示例請求:

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

示例響應:

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

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

使用者

在 4.0 版本新加入.

GET /api/users/

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

也參考

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

POST /api/users/

創建新用戶。

Parameters
  • username (string) – 使用者名稱

  • full_name (string) – User full name

  • 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)/

返回用戶的信息。

Parameters
  • username (string) – 用戶的用戶名

Response JSON Object
  • 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) – 創建用戶的日期

  • groups (array) – 連接到關聯的組;請參見 GET /api/groups/(int:id)/

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/"
    ],
    "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)/

更改用戶參數。

Parameters
  • username (string) – 用戶的用戶名

Response JSON Object
  • 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)/

更改用戶參數。

Parameters
  • username (string) – 用戶的用戶名

Response JSON Object
  • 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)/

刪除所有的用戶信息並將用戶標記為不活動用戶。

Parameters
  • username (string) – 用戶的用戶名

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

將群組與用戶關聯。

Parameters
  • username (string) – 用戶的用戶名

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

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

在 4.13.1 版本新加入.

Remove user from a group.

Parameters
  • username (string) – 用戶的用戶名

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

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

用戶的統計數據列表。

Parameters
  • username (string) – 用戶的用戶名

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)/notifications/

用戶的訂閱列表。

Parameters
  • username (string) – 用戶的用戶名

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

將訂閱與用戶關聯。

Parameters
  • username (string) – 用戶的用戶名

Request JSON Object
  • notification (string) – 註冊通知的名稱

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

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

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

獲得與用戶關聯的訂閱。

Parameters
  • username (string) – 用戶的用戶名

  • subscription_id (int) – ID of notification registered

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

編輯與用戶關聯的訂閱。

Parameters
  • username (string) – 用戶的用戶名

  • subscription_id (int) – ID of notification registered

Request JSON Object
  • notification (string) – 註冊通知的名稱

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

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

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

編輯與用戶關聯的訂閱。

Parameters
  • username (string) – 用戶的用戶名

  • subscription_id (int) – ID of notification registered

Request JSON Object
  • notification (string) – 註冊通知的名稱

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

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

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

刪除與用戶關聯的訂閱。

Parameters
  • username (string) – 用戶的用戶名

  • subscription_id – 註冊通知的名稱

  • subscription_id – int

群組

在 4.0 版本新加入.

GET /api/groups/

返回群組列表,如果有權限看到管理群組的話,如果沒有,那麼會只看到用戶所在的群組。

也參考

群組對象屬性歸檔在 GET /api/groups/(int:id)/

POST /api/groups/

創建新的群組。

Parameters
GET /api/groups/(int: id)/

返回群組的信息。

Parameters
  • id (int) – 群組的 ID

Response JSON Object

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/"
    ]
}
PUT /api/groups/(int: id)/

更改群組參數。

Parameters
  • id (int) – 群組的 ID

Response JSON Object
  • name (string) – 群組的名稱

  • project_selection (int) – 相應於對象群組的整數

  • language_selection (int) – 相應於語言群組的整數

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

更改群組參數。

Parameters
  • id (int) – 群組的 ID

Response JSON Object
  • name (string) – 群組的名稱

  • project_selection (int) – 相應於對象群組的整數

  • language_selection (int) – 相應於語言群組的整數

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

Deletes the group.

Parameters
  • id (int) – 群組的 ID

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

將角色與群組關聯。

Parameters
  • id (int) – 群組的 ID

表格參數
  • string role_id – 唯一的角色 ID

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

將組件與群組關聯。

Parameters
  • id (int) – 群組的 ID

表格參數
  • string component_id – 唯一的組件 ID

DELETE /api/groups/(int: id)/components/(int: component_id)

從群組刪除組件。

Parameters
  • id (int) – 群組的 ID

  • component_id (int) – 唯一的組件 ID

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

將項目與群組關聯。

Parameters
  • id (int) – 群組的 ID

表格參數
  • string project_id – 唯一的項目 ID

DELETE /api/groups/(int: id)/projects/(int: project_id)

從群組刪除項目。

Parameters
  • id (int) – 群組的 ID

  • project_id (int) – 唯一的項目 ID

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

將語言與群組關聯。

Parameters
  • id (int) – 群組的 ID

表格參數
  • string language_code – 唯一的語言代碼

DELETE /api/groups/(int: id)/languages/(string: language_code)

從群組刪除語言。

Parameters
  • id (int) – 群組的 ID

  • language_code (string) – 唯一的語言代碼

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

將組件列表與群組關聯。

Parameters
  • id (int) – 群組的 ID

表格參數
  • string component_list_id – 唯一的組件列表 ID

DELETE /api/groups/(int: id)/componentlists/(int: component_list_id)

從群組刪除組件列表。

Parameters
  • id (int) – 群組的 ID

  • component_list_id (int) – 唯一的組件列表 ID

角色

GET /api/roles/

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

也參考

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

POST /api/roles/

創建新角色。

Parameters
  • name (string) – 角色名稱

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

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

返回角色的信息。

Parameters
  • id (int) – 角色 ID

Response JSON Object
  • name (string) – 角色名稱

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

Example JSON data:

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

更改角色參數。

Parameters
  • id (int) – 角色的ID

Response JSON Object
  • name (string) – 角色名稱

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

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

更改角色參數。

Parameters
  • id (int) – 角色的ID

Response JSON Object
  • name (string) – 角色名稱

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

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

Deletes the role.

Parameters
  • id (int) – 角色的ID

語言

GET /api/languages/

返回所有語言的列表。

也參考

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

POST /api/languages/

創建新的語言。

Parameters
  • code (string) – 語言名稱

  • name (string) – 語言名稱

  • direction (string) – 文字方向

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

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

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

返回語言的信息。

Parameters
  • language (string) – 語言碼

Response JSON Object
  • code (string) – 語言碼

  • direction (string) – 文字方向

  • plural (object) – 語言複數信息的對象

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

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)/

更改語言參數。

Parameters
  • language (string) – 語言的編碼

Request JSON Object
  • name (string) – 語言名稱

  • direction (string) – 文字方向

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

  • plural (object) – Language plural details

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

更改語言參數。

Parameters
  • language (string) – 語言的編碼

Request JSON Object
  • name (string) – 語言名稱

  • direction (string) – 文字方向

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

  • plural (object) – Language plural details

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

Deletes the language.

Parameters
  • language (string) – 語言的編碼

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

返回語言的統計數據。

Parameters
  • language (string) – 語言碼

Response JSON Object
  • total (int) – 字符串的總數

  • total_words (int) – 詞的總數

  • last_change (timestamp) – 語言的上一次更改

  • recent_changes (int) – 更改的總數

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

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

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

  • translated_words_percent (int) – 已翻譯詞的百分比

  • translated_chars (int) – 已翻譯字符的數量

  • translated_chars_percent (int) – 已翻譯字符的百分比

  • total_chars (int) – 總字符的數量

  • fuzzy (int) – number of fuzzy (marked for edit) strings

  • fuzzy_percent (int) – 模糊字符串 (標記為需要編輯)的百分比

  • failing (int) – 失敗字符串的數量

  • failing – 失敗字符串的百分比

專案

GET /api/projects/

返回所有項目的列表。

也參考

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

POST /api/projects/

在 3.9 版本新加入.

創建新項目。

Parameters
  • name (string) – 專案名稱

  • slug (string) – 項目標識串

  • web (string) – 專案網站

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

返回項目的信息。

Parameters
  • project (string) – 專案 URL slug

Response JSON Object

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 版本新加入.

通過 PATCH 請求來編輯一個項目。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

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

在 4.3 版本新加入.

通過 PUT 請求來編輯一個項目。

Parameters
  • project (string) – 專案 URL slug

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

在 3.9 版本新加入.

Deletes a project.

Parameters
  • project (string) – 專案 URL slug

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

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

Parameters
  • project (string) – 專案 URL slug

Response JSON Object
GET /api/projects/(string: project)/repository/

返回版本控制系統(VCS)倉庫狀態的信息。這個端點只包含項目所有倉庫的整體概況。為了得到更多細節,請使用 GET /api/components/(string:project)/(string:component)/repository/

Parameters
  • project (string) – 專案 URL slug

Response JSON Object
  • needs_commit (boolean) – 是否有待定的更改要提交

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

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

Example JSON data:

{
    "needs_commit": true,
    "needs_merge": false,
    "needs_push": true
}
POST /api/projects/(string: project)/repository/

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

Parameters
  • project (string) – 專案 URL slug

Request JSON Object
  • operation (string) – 要執行的操作: one of push, pull, commit, reset, cleanup, file-sync

Response JSON Object
  • result (boolean) – 操作的結果

CURL 示例:

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

JSON request example:

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/

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

Parameters
  • project (string) – 專案 URL slug

Response JSON Object
POST /api/projects/(string: project)/components/

在 3.9 版本新加入.

在 4.3 版本變更: zipfiledocfile 參數現在可被無 VCS 的組件所接受,見 Local files.

在 4.6 版本變更: 克隆的存儲庫現在使用:REF:“內部URL”,現在自動在項目中自動共享。使用``isable_autoshare``關閉。

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

提示

使用:REF:從單個VCS存儲庫創建多個組件時的“內部URL”。

備註

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

Parameters
  • project (string) – 專案 URL slug

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

  • file docfile – 要翻譯的文件

  • boolean disable_autoshare – 禁用自動存儲庫共享:參考:“內部URL”。

Request JSON Object
Response JSON Object

使用“ZipFile``和````````````````````````)無法使用JSON。數據必須上傳為:MimeType: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 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",
    "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/

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

在 3.8 版本新加入.

Parameters
  • project (string) – 專案 URL slug

Response JSON Object
  • 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/

返回項目的統計數據。

在 3.8 版本新加入.

Parameters
  • project (string) – 專案 URL slug

Response JSON Object
  • total (int) – 字符串的總數

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

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

  • total_words (int) – 詞的總數

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

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

組件

提示

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)/

返回翻譯組件的信息。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object

Example JSON data:

{
    "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 請求編輯一個組件。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

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

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 request example:

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",
    "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 請求編輯一個組件。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object
  • branch (string) – VCS repository branch

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

  • filemask (string) – 倉庫中翻譯的文件掩碼

  • name (string) – name of component

  • slug (string) – slug of component

  • repo (string) – VCS repository URL

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

  • new_base (string) – 用於添加新翻譯的譯文模板文件

  • vcs (string) – version control system

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

在 3.9 版本新加入.

Deletes a component.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

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

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object
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.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

查詢參數
  • format (string) – The archive format to use; If not specified, defaults to zip; Supported formats: zip

  • q (string) – Filter downloaded strings, see 搜尋頁面.

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

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object
GET /api/components/(string: project)/(string: component)/lock/

返回組件鎖定狀態。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object
  • locked (boolean) – 組件是否因更新而鎖定

Example JSON data:

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

設置組件鎖定狀態。

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object
  • lock – 是否鎖定的布爾值。

CURL 示例:

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

JSON request example:

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/

返回版本控制系統(VCS)倉庫狀態的信息。

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object
  • 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/

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object
  • operation (string) – 執行的操作: push, pull, commit, reset, ``cleanup``之一

Response JSON Object
  • result (boolean) – 操作的結果

CURL 示例:

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

JSON request example:

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/

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

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

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

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

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object
POST /api/components/(string: project)/(string: component)/translations/

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Request JSON Object
Response JSON Object
  • result (object) – 新建的新翻譯對象

CURL 示例:

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

JSON request example:

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

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

在 2.7 版本新加入.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object

Returns projects linked with a component.

在 4.5 版本新加入.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

Response JSON Object
POST /api/components/(string: project)/(string: component)/links/

Associate project with a component.

在 4.5 版本新加入.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

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

Remove association of a project with a component.

在 4.5 版本新加入.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • project_slug (string) – Slug of the project to remove

翻譯

GET /api/translations/

返回翻譯的列表。

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

返回翻譯的信息。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Response JSON Object

Example JSON data:

{
    "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)/

在 3.9 版本新加入.

Deletes a translation.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

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

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Response JSON Object
GET /api/translations/(string: project)/(string: component)/(string: language)/units/

返回翻譯單元的列表。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

  • q (string) – 搜索查詢字符串 :ref:`Searching`(可選)

Response JSON Object
POST /api/translations/(string: project)/(string: component)/(string: language)/units/

Add new unit.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Request JSON Object
  • key (string) – Name of translation unit (used as key or context)

  • value (array) – Source strings (use single string if not creating plural)

Response JSON Object
POST /api/translations/(string: project)/(string: component)/(string: language)/autotranslate/

觸發自動翻譯。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Request JSON Object
  • 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``參數)或將其轉換為另一格式(見 Downloading translations)。

備註

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

查詢參數
  • format – 使用的文件格式;如果不指定,則不會進行格式轉換;支持的文件格式有:po, mo, xliff, xliff11, tbx` `, ``csv, xlsx, json, aresource, strings

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

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

上傳帶有翻譯的新文件。

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

表格參數
  • string conflict – 如何處理衝突(ignore, replace-translated or replace-approved

  • file file – 上傳文件

  • string email – 作者電子郵件

  • string author – 作者姓名

  • string method – 上傳方法(translate, approve, suggest, fuzzy, replace, source, add),見:ref: upload-method

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

返回版本控制系統(VCS)倉庫狀態的信息。

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

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

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

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

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Request JSON Object
  • operation (string) – 執行的操作: push, pull, commit, reset, ``cleanup``之一

Response JSON Object
  • result (boolean) – 操作的結果

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

返回具體的翻譯統計數據。

在 2.7 版本新加入.

Parameters
  • project (string) – 專案 URL slug

  • component (string) – 組件 URL slug

  • language (string) – Translation language code

Response JSON Object
  • code (string) – 語言代碼

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

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

  • fuzzy (int) – number of fuzzy (marked for edit) strings

  • fuzzy_percent (float) – 模糊字符串 (標記為需要編輯)的百分比

  • total_words (int) – 詞的總數

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

  • last_author (string) – 最後一位作者的姓名

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

  • name (string) – 語言名稱

  • total (int) – 字符串的總數

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

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

  • url (string) – 訪問翻譯的 URL (約定的 URL)

  • url_translate (string) – 訪問翻譯的 URL (真實翻譯的 URL)

Units

“單位”是一個翻譯的單曲,它對具有相應翻譯的字符串對的源字符串,也包含一些相關元數據。該術語來自“翻譯工具包”<http://docs.translatehouse.org/projects/translate-toolkit/en/latest/api/storage.html#translate.storage.base.translationUnit>`_和xliff。

在 2.10 版本新加入.

GET /api/units/

返回翻譯單元的列表。

也參考

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

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

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

返回翻譯單元的信息。

Parameters
  • id (int) – 單元 ID

Response JSON Object
  • translation (string) – 相關翻譯對象的 URL

  • source (array) – 來源字串

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

  • target (array) – 目標字符串

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

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

  • location (string) – 源代碼中單元的位置

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

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

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

  • 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) – 翻譯文件中的單元位置

  • 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) – 另外的字符串標記,可在源單元獲得,請參見 Customizing behavior using flags

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

  • source_unit (string) – 源單元鏈接;請參見 GET /api/units/(int:id)/

  • pending (boolean) – whether the unit is pending for write

  • timestamp (timestamp) – string age

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

在 4.3 版本新加入.

Performs partial update on translation unit.

Parameters
  • id (int) – 單元 ID

Request JSON Object
  • 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) – 另外的字符串標記,可在源單元獲得,請參見 Customizing behavior using flags

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

在 4.3 版本新加入.

Performs full update on translation unit.

Parameters
  • id (int) – 單元 ID

Request JSON Object
  • 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) – 另外的字符串標記,可在源單元獲得,請參見 Customizing behavior using flags

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

在 4.3 版本新加入.

Deletes a translation unit.

Parameters
  • id (int) – 單元 ID

更動

在 2.10 版本新加入.

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)/

返回有關翻譯更改的信息。

Parameters
  • id (int) – 更改的ID

Response JSON Object
  • unit (string) – 相關單元對象的 URL

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

  • component (string) – 相關組件對象的 URL

  • user (string) – 相關用戶對象的 URL

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

  • timestamp (timestamp) – 時間的時間標籤

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

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

  • target (string) – 更改的事件的文本或細節

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

畫面快照

在 2.14 版本新加入.

GET /api/screenshots/

返回屏幕截圖字符串信息的列表。

也參考

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

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

返回與屏幕截圖信息有關的信息。

Parameters
  • id (int) – 屏幕截圖的 ID

Response JSON Object
GET /api/screenshots/(int: id)/file/

下載屏幕截圖的圖片。

Parameters
  • id (int) – 屏幕截圖的 ID

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

替換屏幕截圖。

Parameters
  • 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/

與屏幕截圖相關的源字符串。

Parameters
  • id (int) – 屏幕截圖的 ID

表格參數
  • string unit_id – 單元 ID

Response JSON Object
DELETE /api/screenshots/(int: id)/units/(int: unit_id)

Remove source string association with screenshot.

Parameters
  • id (int) – 屏幕截圖的 ID

  • unit_id – Source string unit ID

POST /api/screenshots/

新建新的屏幕截圖。

表格參數
  • file image – 上傳文件

  • string name – 畫面快照名稱

  • string project_slug – 項目標識串

  • string component_slug – 組件標識串

  • string language_code – 語言碼

Response JSON Object
PATCH /api/screenshots/(int: id)/

Edit partial information about screenshot.

Parameters
  • id (int) – 屏幕截圖的 ID

Response JSON Object
PUT /api/screenshots/(int: id)/

Edit full information about screenshot.

Parameters
  • id (int) – 屏幕截圖的 ID

Response JSON Object
DELETE /api/screenshots/(int: id)/

Delete screenshot.

Parameters
  • id (int) – 屏幕截圖的 ID

附加元件

在 4.4.1 版本新加入.

GET /api/addons/

Returns a list of add-ons.

也參考

附加組件對象屬性記錄在 GET /api/units/(int:id)/

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

Returns information about add-on information.

Parameters
  • id (int) – Add-on ID

Response JSON Object
  • name (string) – name of an add-on

  • component (string) – 相關組件對象的 URL

  • configuration (object) – Optional add-on configuration

也參考

附加元件

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

Creates a new add-on.

Parameters
  • project_slug (string) – 項目標識串

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

Parameters
  • id (int) – Add-on ID

Response JSON Object
  • configuration (object) – Optional add-on configuration

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

Edit full information about add-on.

Parameters
  • id (int) – Add-on ID

Response JSON Object
  • configuration (object) – Optional add-on configuration

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

Delete add-on.

Parameters
  • id (int) – Add-on ID

組件列表

在 4.0 版本新加入.

GET /api/component-lists/

返回組件列表的列表。

也參考

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

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

返回組件列表的信息。

Parameters
  • slug (string) – 組件列表的標識串

Response JSON Object
  • 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)/

更改組件列表參數。

Parameters
  • slug (string) – 組件列表的標識串

Request JSON Object
  • name (string) – 組件列表的名稱

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

  • show_dashboard (boolean) – 是否在控制台上顯示

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

更改組件列表參數。

Parameters
  • slug (string) – 組件列表的標識串

Request JSON Object
  • name (string) – 組件列表的名稱

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

  • show_dashboard (boolean) – 是否在控制台上顯示

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

刪除組件列表。

Parameters
  • slug (string) – 組件列表的標識串

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

使組件與組件列表相關。

Parameters
  • slug (string) – 組件列表的標識串

表格參數
  • string component_id – 組件 ID

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

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

Parameters
  • slug (string) – 組件列表的標識串

  • component_slug (string) – 組件標識串

詞彙表

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

Tasks

在 4.4 版本新加入.

GET /api/tasks/

Listing of the tasks is currently not available.

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

Returns information about a task

Parameters
  • uuid (string) – 任務 UUID

Response JSON Object
  • completed (boolean) – Whether the task has completed

  • progress (int) – Task progress in percent

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

  • log (string) – Task log

Metrics

GET /api/metrics/

Returns server metrics.

Response JSON Object
  • 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

通知掛勾

通知鉤子允許外部應用來通知 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/

在 3.3 版本新加入.

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

也參考

從 Pagure 自動接受更改

關於設置 Pagure 集成的指示

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

關於 Pagure Webhooks 的一般信息

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/azure/

在 3.8 版本新加入.

Special hook for handling Azure DevOps notifications and automatically updating matching components.

備註

Please make sure that Resource details to send is set to All, otherwise Weblate will not be able to match your Azure repository.

也參考

從 Azure Repos 自動接收更改

關於設置 Azure 集成的指示

https://docs.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/

在 3.9 版本新加入.

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

也參考

從 Gitea Repos 自動接收更改

關於設置 Gitea 集成的指示

https://docs.gitea.io/en-us/webhooks/

關於 Gitea Webhooks 的一般信息

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

POST /hooks/gitee/

在 3.9 版本新加入.

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

也參考

從 Gitee Repos 自動接收更改

關於設置 Gitee 集成的指示

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

關於 Gitee Webhooks 的一般信息

ENABLE_HOOKS

關於對整個 Weblate 啟動鉤子

Exports

Weblate 提供各種導出,允許進一步處理數據。

GET /exports/stats/(string: project)/(string: component)/
查詢參數
  • format (string) – 輸出格式: jsoncsv

在 2.6 版本開始棄用: 請替代使用:http:get:/api/components/(string:project)/(string:component)/statistics/ 和:http:get:/api/translations/(string:project)/(string: component)/(string:language)/statistics/;它也允許訪問ACL 控制的項目。

為給定的組件以給定的格式檢索統計數據。

示例請求:

GET /exports/stats/weblate/main/ HTTP/1.1
Host: example.com
Accept: application/json, text/javascript

示例響應:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
    {
        "code": "cs",
        "failing": 0,
        "failing_percent": 0.0,
        "fuzzy": 0,
        "fuzzy_percent": 0.0,
        "last_author": "Michal Čihař",
        "last_change": "2012-03-28T15:07:38+00:00",
        "name": "Czech",
        "total": 436,
        "total_words": 15271,
        "translated": 436,
        "translated_percent": 100.0,
        "translated_words": 3201,
        "url": "http://hosted.weblate.org/engage/weblate/cs/",
        "url_translate": "http://hosted.weblate.org/projects/weblate/main/cs/"
    },
    {
        "code": "nl",
        "failing": 21,
        "failing_percent": 4.8,
        "fuzzy": 11,
        "fuzzy_percent": 2.5,
        "last_author": null,
        "last_change": null,
        "name": "Dutch",
        "total": 436,
        "total_words": 15271,
        "translated": 319,
        "translated_percent": 73.2,
        "translated_words": 3201,
        "url": "http://hosted.weblate.org/engage/weblate/nl/",
        "url_translate": "http://hosted.weblate.org/projects/weblate/main/nl/"
    },
    {
        "code": "el",
        "failing": 11,
        "failing_percent": 2.5,
        "fuzzy": 21,
        "fuzzy_percent": 4.8,
        "last_author": null,
        "last_change": null,
        "name": "Greek",
        "total": 436,
        "total_words": 15271,
        "translated": 312,
        "translated_percent": 71.6,
        "translated_words": 3201,
        "url": "http://hosted.weblate.org/engage/weblate/el/",
        "url_translate": "http://hosted.weblate.org/projects/weblate/main/el/"
    }
]

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