Weblate 客戶端¶
安裝¶
Weblate 客戶端是分開上市的,包括 Python 模塊。要使用下面的命令,您需要安裝 wlc
:
pip install wlc
Docker usage¶
Web2客戶端也可作為Docker Image提供。
該圖像在Docker Hub上發佈:https://hub.docker.com/r/weblate/wlc
安裝中:
docker pull weblate/wlc
Docker 容器使用 Weblate 的預設設定並連線到位於 localhost 中部署的 API。API URL 和 API_KEY 可以通過 Weblate 接受的參數組態。
啟動容器的命令使用以下語法:
docker run --rm weblate/wlc [WLC_ARGS]
範例:
docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects
您可能希望傳送您的 wlc-config`給 Docker 容器,最簡單的方法是將您目前的目錄新增為 :file:/home/webleate` volume:
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
也參考
概要¶
wlc [arguments] <command> [options]
命令實際上指示應該執行哪個操作。
描述¶
Weblate 客戶端是一個 Python 庫和命令行實用程序,可使用 Weblate 的 REST API 遠端管理 Weblate。命令行實用程序可以作為 wlc 呼叫,並且內建在 wlc
上。
Arguments¶
程序接受以下參數來定義輸出格式或使用哪個Weblate實例。這些參數必須位於任何命令之前。
- --format {csv,json,text,html}¶
指定輸出格式。
指令¶
以下命令可用:
- 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 中讀取。
- --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
Per project configuration file
C:\Users\NAME\AppData\weblate.ini
在 Windows 上使用組態檔。
~/.config/weblate
使用者組態檔
/etc/xdg/weblate
System wide configuration file
該程序遵循 XDG 規範,因此您可以通過環境變數 XDG_CONFIG_HOME
或 XDG_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 知道它應該與哪個伺服器通訊。
例子¶
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/
上傳翻譯檔:
$ 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