Weblate 客戶端

在 2.7 版本新加入: 自從 Weblate 2.7 以來,已經有完整的 wlc 實用程序支持。如果您使用的是舊版本,則可能會與 API 發生某些不兼容。

安裝

Weblate 客戶端是分開上市的,包括 Python 模塊。要使用下面的命令,您需要安裝 wlc

pip install wlc

Docker usage

Web2客戶端也可作為Docker Image提供。

該圖像在Docker Hub上發布:https://hub.docker.com/r/weblate/wlc

Installing:

docker pull weblate/wlc

Docker Container使用WebLate的默認設置並連接到位於localhost中部署的API。API URL和API_KEY可以通過Weberate接受的參數配置。

啟動容器的命令使用以下語法:

docker run --rm weblate/wlc [WLC_ARGS]

例:

docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects

您可能希望通過您的:REF:“WLC-CONFIG”(WLC-CONFIG`給Docker容器,最簡單的方法是將您當前的目錄添加為:file:`/ home / webleate`卷:

docker run --volume $PWD:/home/weblate --rm weblate/wlc show

入門

wlc 配置存儲在 ~/.config/weblate 中(其他位置參見 ref:wlc-config),請創建它以匹配您的環境:

[weblate]
url = https://hosted.weblate.org/api/

[keys]
https://hosted.weblate.org/api/ = APIKEY

然後,您可以在默認服務器上調用命令:

wlc ls
wlc commit sandbox/hello-world

也參考

配置文件

Synopsis

wlc [arguments] <command> [options]

命令實際上指示應該執行哪個操作。

描述

Weblate 客戶端是一個 Python 庫和命令行實用程序,可使用 Weblate 的 REST API 遠程管理 Weblate。命令行實用程序可以作為 wlc 調用,並且內置在 wlc 上。

Arguments

程序接受以下參數來定義輸出格式或使用哪個Weblate實例。這些參數必須位於任何命令之前。

--format {csv,json,text,html}

指定輸出格式。

--url URL

指定 API URL。覆蓋在配置文件中找到的任何值,請參閱 配置文件。該網址應以 /api/ 結尾,例如 https://hosted.weblate.org/api/

--key KEY

指定要使用的 API 用戶密鑰。覆蓋在配置文件中找到的任何值,請參閱 配置文件。您可以在 Weblate 的個人資料中找到密鑰。

--config PATH

覆蓋配置文件路徑,請參閱 配置文件

--config-section SECTION

覆蓋正在使用的配置文件部分,請參閱 配置文件

Commands

以下命令可用:

version

打印當前版本。

list-languages

列出 Weblate 中使用的語言。

list-projects

列出 Weblate 中的項目。

list-components

Lists components in Weblate.

list-translations

Lists translations in Weblate.

show

顯示 Weblate 對象(翻譯,組件或項目)。

ls

列出 Weblate 對象(翻譯,組件或項目)。

commit

提交在 Weblate 對象(翻譯,組件或項目)中所做的更改。

pull

拉取遠程倉庫的更改到 Weblate 對像中(翻譯,組件或項目)。

push

將 Weblate 對象更改推送到遠程倉庫(翻譯,組件或項目)。

reset

在 0.7 版本新加入: Supported since wlc 0.7.

重置 Weblate 對像中的更改以匹配遠程存儲庫(翻譯,組件或項目)。

cleanup

在 0.9 版本新加入: Supported since wlc 0.9.

刪除 Weblate 對像中所有未跟踪的更改以匹配遠程倉庫(翻譯,組件或項目)。

repo

顯示給定 Weblate 對象(翻譯,組件或項目)的倉庫狀態。

stats

顯示給定 Weblate 對象(翻譯,組件或項目)的詳細統計數據。

lock-status

在 0.5 版本新加入: Supported since wlc 0.5.

顯示鎖定狀態。

lock

在 0.5 版本新加入: Supported since wlc 0.5.

鎖定組件以防止在 Weblate 中進一步翻譯。

unlock

在 0.5 版本新加入: Supported since wlc 0.5.

解鎖 Weblate 組件的翻譯。

changes

在 0.7 版本新加入: 從 wlc 0.7 和 Weblate 2.10 開始受支持。

顯示給定對象的更改。

download

在 0.7 版本新加入: Supported since wlc 0.7.

Downloads a translation file.

--convert

轉換文件格式,如果未指定,則在服務器上不進行任何轉換,並且將文件原樣下載到倉庫中。

--output

指定要保存輸出的文件,如果未指定,則將其打印到 stdout。

upload

在 0.9 版本新加入: Supported since wlc 0.9.

Uploads a translation file.

--overwrite

上傳時覆蓋現有翻譯。

--input

從中讀取內容的文件,如果未指定,則從 stdin 中讀取。

--method

Upload method to use, see 導入方法.

--fuzzy

模糊 (標記為需要編輯)的字符串處理(empty, process, approve

--author-name

Author name, to override currently authenticated user

--author-email

Author e-mail, to override currently authenticated user

提示

您可以通過傳遞``–help``獲取更多有關調用單個命令的更詳細信息:wlc ls - help

配置文件

.weblate, .weblate.ini, weblate.ini

在 1.6 版本變更: 也接受了具有`.ini`擴展的文件。

Per project configuration file

C:\Users\NAME\AppData\weblate.ini

在 1.6 版本新加入.

在 Windows 上使用配置文件。

~/.config/weblate

用戶配置文件

/etc/xdg/weblate

System wide configuration file

該程序遵循 XDG 規範,因此您可以通過環境變量 XDG_CONFIG_HOMEXDG_CONFIG_DIRS 來調整配置文件的位置。在 Windows 系統上 `APPDATA``目錄是配置文件的首選位置。

可以在 [weblate] 部分中配置以下設置(您可以通過 --config-section 進行自定義):

key

用於訪問 Weblate 的 API KEY。

url

API 服務器網址,默認為 http://127.0.0.1:8000/api/

translation

默認翻譯的路徑 —— 組件或項目。

配置文件是一個 INI 文件,例如:

[weblate]
url = https://hosted.weblate.org/api/
key = APIKEY
translation = weblate/application

另外,API 密鑰可以存儲在 [keys] 部分中:

[keys]
https://hosted.weblate.org/api/ = APIKEY

這樣,您就可以在版本控制系統(VCS )倉庫中使用 .weblate 配置時,將密鑰存儲在個人設置中,以便 wlc 知道它應該與哪個服務器通信。

Examples

Print current program version:

$ wlc version
version: 0.1

列出所有項目:

$ wlc list-projects
name: Hello
slug: hello
url: http://example.com/api/projects/hello/
web: https://weblate.org/
web_url: http://example.com/projects/hello/

Upload translation file:

$ wlc upload project/component/language --input /tmp/hello.po

您還可以指定 wlc 應該從事的項目:

$ cat .weblate
[weblate]
url = https://hosted.weblate.org/api/
translation = weblate/application

$ wlc show
branch: main
file_format: po
source_language: en
filemask: weblate/locale/*/LC_MESSAGES/django.po
git_export: https://hosted.weblate.org/git/weblate/application/
license: GPL-3.0+
license_url: https://spdx.org/licenses/GPL-3.0+
name: Application
new_base: weblate/locale/django.pot
project: weblate
repo: git://github.com/WeblateOrg/weblate.git
slug: application
template:
url: https://hosted.weblate.org/api/components/weblate/application/
vcs: git
web_url: https://hosted.weblate.org/projects/weblate/application/

通過此設置,可以輕鬆地提交當前項目中待定的更改:

$ wlc commit