Weblate 客户端
2.7 新版功能: 自从 Weblate 2.7 以来,已经有完整的 wlc 实用程序支持。如果您使用的是旧版本,则可能会与 API 发生某些不兼容。
安装
Weblate 客户端是单独提供的,包括 Python 模块。要使用下面的命令,您需要安装 wlc
:
pip3 install wlc
Docker 用法
The Weblate Client is also available as a Docker image.
The image is published on Docker Hub: https://hub.docker.com/r/weblate/wlc
正在安装:
docker pull weblate/wlc
The Docker container uses Weblate’s default settings and connects to the API deployed in localhost. The API URL and API_KEY can be configured through the arguments accepted by Weblate.
The command to launch the container uses the following syntax:
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
入门
wlc 配置存储在 ~/.config/weblate
中(其他位置请参见 配置文件),请根据你的环境创建它:
[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
列出 Weblate 中的部件。
- list-translations
列出 Weblate 中的翻译。
- show
显示 Weblate 对象(翻译,部件或项目)。
- ls
列出 Weblate 对象(翻译,部件或项目)。
- commit
提交在 Weblate 对象(翻译,部件或项目)中所做的更改。
- pull
拉取远程仓库的更改到 Weblate 对象中(翻译,部件或项目)。
- push
将 Weblate 对象更改推送到远程仓库(翻译,部件或项目)。
- reset
0.7 新版功能: 自 wlc 0.7 起受支持。
重置 Weblate 对象中的更改以匹配远程存储库(翻译,部件或项目)。
- cleanup
0.9 新版功能: 从 wlc 0.9 开始受支持。
删除 Weblate 对象中所有未跟踪的更改以匹配远程仓库(翻译,部件或项目)。
- repo
显示给定 Weblate 对象(翻译,部件或项目)的仓库状态。
- statistics
显示给定 Weblate 对象(翻译,部件或项目)的详细统计数据。
- lock-status
0.5 新版功能: 自 wlc 0.5 起受支持。
显示锁定状态。
- lock
0.5 新版功能: 自 wlc 0.5 起受支持。
锁定部件以防止在 Weblate 中进一步翻译。
- unlock
0.5 新版功能: 自 wlc 0.5 起受支持。
解锁 Weblate 部件的翻译。
- changes
0.7 新版功能: 从 wlc 0.7 和 Weblate 2.10 开始受支持。
显示给定对象的更改。
- download
0.7 新版功能: 自 wlc 0.7 起受支持。
下载翻译文件。
- --convert
转换文件格式,如果未指定,则在服务器上不进行任何转换,并且将文件原样下载到仓库中。
- --output
指定要保存输出的文件,如果未指定,则将其打印到 stdout。
- upload
0.9 新版功能: 从 wlc 0.9 开始受支持。
上传翻译文件。
- --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.ini
在 1.6 版更改: 同时支持扩展名为`.ini`的文件。
每个项目的配置文件
C:\Users\NAME\AppData\weblate.ini
1.6 新版功能.
在 Windows 上使用配置文件。
~/.config/weblate
用户配置文件
/etc/xdg/weblate
系统范围的配置文件
该程序遵循 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 知道它应该与哪个服务器通信。
例子
打印当前程序版本:
$ 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