Weblate 客戶端¶
安裝¶
The Weblate Client is shipped separately and includes the Python module. To use the commands below, you need to install wlc using pip:
pip install wlc
提示
You can also use this wlc as a Python module, see 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
You might want to pass your 組態檔 to the Docker container, the
easiest approach is to add your current directory as /home/weblate
volume:
docker run --volume $PWD:/home/weblate --rm weblate/wlc show
開始使用¶
The wlc configuration is stored in ~/.config/weblate (see 組態檔
for other locations), please create it to match your environment:
[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 上。
參數¶
程序接受以下參數來定義輸出格式或使用哪個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¶
重設 Weblate 物件中的變更以比對遠端儲存庫(翻譯、組件或專案)。
- cleanup¶
刪除 Weblate 對像中所有未追蹤的更改以匹配遠端倉儲(翻譯,組件或專案)。
- repo¶
顯示給定 Weblate 對象(翻譯,組件或專案)的倉儲狀態。
- stats¶
顯示給定 Weblate 對象(翻譯,組件或專案)的詳細統計資料。
- lock-status¶
顯示鎖定狀態。
- lock¶
鎖定組件以防止在 Weblate 中進一步翻譯。
- unlock¶
解鎖 Weblate 組件的翻譯。
- changes¶
顯示給定對象的更改。
- download¶
Downloads a translation file.
- --convert¶
轉換文件格式,如果未指定,則在伺服器上不進行任何轉換,並且將文件原樣下載到倉儲中。
- --output¶
指定要保存輸出的文件,如果未指定,則將其打印到 stdout。
- upload¶
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
提示
You can get more detailed information on invoking individual commands by
passing --help, for example: wlc ls --help.
組態檔¶
.weblate,.weblate.ini,weblate.iniConfiguration file placed in the project directory.
C:\Users\NAME\AppData\Roaming\weblate.iniUser configuration file on Windows in the roamed profile.
C:\Users\NAME\AppData\Local\weblate.iniUser configuration file on Windows in the local profile.
~/.config/weblateUser configuration file.
/etc/xdg/weblateSystem wide configuration file.
The program follows the XDG specification, so you can adjust the placement of
config files by environment variables XDG_CONFIG_HOME or
XDG_CONFIG_DIRS.
On Windows APPDATA and LOCALAPPDATA directories are the preferred
locations for the configuration file.
可以在 [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
This allows you to store keys in your personal settings, while using the
.weblate configuration in the VCS repository so that wlc knows which
server it should talk to.
例子¶
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
You can also designate what project wlc should work on:
$ 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