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
uvx を使用して直接実行することもできます。
uvx wlc --help
ヒント
この wlc を Python モジュールとして使用することもできます、参照: wlc。
Docker の使用¶
Weblate クライアントは Docker イメージでも動作します。
イメージは Docker Hub: https://hub.docker.com/r/weblate/wlc で公開しています
インストール:
docker pull weblate/wlc
The Docker container uses Weblate Client defaults and connects to the API
deployed on localhost. Configure the API URL and API key using the normal
wlc arguments or environment variables, for example --url,
--key, WLC_URL, and WLC_KEY.
API keys are rejected over non-local http:// URLs by default; use HTTPS,
loopback HTTP for local development, or explicitly opt in to insecure HTTP.
コンテナがコマンドで起動する構文:
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. When
your repository contains a project configuration such as .weblate, the
easiest approach is to add your current directory as the
/home/weblate volume:
docker run --volume $PWD:/home/weblate --rm weblate/wlc show
When the mounted repository provides the API URL in project configuration and
you pass an unscoped API key to the container, also pin the URL explicitly:
WLC_KEY requires WLC_URL, and --key requires
--url.
If the configured API URL uses non-local http:// and an API key is
provided, the container refuses to send the key unless insecure HTTP is
explicitly enabled. Prefer HTTPS; for legacy deployments, pass
--allow-insecure-http or set WLC_ALLOW_INSECURE_HTTP.
はじめに¶
The easiest way to get started is to create a personal
wlc configuration in ~/.config/weblate (see
設定ファイル for the full discovery rules and other locations):
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = APIKEY
そのあと、デフォルト サーバーでコマンドを呼び出せます。
wlc ls
wlc commit sandbox/hello-world
参考
レガシー構成¶
バージョン 1.17 で変更: スコープなしの key を使用する従来の設定には対応していません。
レガシー構成の移行:
[weblate]
url = https://hosted.weblate.org/api/
key = YOUR_KEY_HERE
API URL にスコープを設定したキーを持つ構成の移行手順:
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = YOUR_KEY_HERE
概要¶
wlc [arguments] <command> [options]
コマンドは、実際に実行が必要な操作を示しています。
説明¶
Weblate クライアントは Python ライブラリであり、Weblate の REST API を使用して Weblate をリモートで管理するためのコマンドライン ユーティリティです。コマンドライン ユーティリティは、wlc として呼び出すことができ、wlc に組み込まれています。
引数¶
プログラムは、出力形式を定義する以下の引数、または使用する Weblate インスタンスを受け入れます。これらは、コマンドの前に入力が必要です。
- --format {csv,json,text,html}¶
出力形式を指定する。
- --url URL¶
API の URL を指定します。設定ファイル内の値を上書きします。参照: 設定ファイル。URL の末尾は
/api/にします(例:https://hosted.weblate.org/api/。
- --key KEY¶
Specify the API user key to use. Overrides any value found in the configuration file, see 設定ファイル. You can find your key in your profile on Weblate. When the API URL is loaded from automatically discovered project configuration,
--keymust be used together with--url. API keys are rejected over non-localhttp://URLs by default.
- --allow-insecure-http¶
Allow sending API keys over non-local
http://URLs. Prefer HTTPS or loopback HTTP instead; this option is intended only for legacy deployments where HTTPS is not available. This option only enables insecure HTTP for the current run; omitting it does not disableallow_insecure_httpfrom configuration.
コマンド¶
使用できるコマンド:
- version¶
現在のバージョンを表示する。
- list-languages¶
Weblate で使用している言語を一覧表示する。
- list-projects¶
Weblate のプロジェクトを一覧表示する。
- list-components¶
Weblate のコンポーネントを一覧表示する。
- list-translations¶
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¶
翻訳ファイルをダウンロードする。
- --convert¶
ファイル形式を変換する、ファイル形式を指定しない場合はサーバー上で変換は行われず、ファイルはそのままリポジトリにダウンロードされる。
- --output¶
出力を保存するファイルを指定する。指定しない場合は、標準出力に出力される。
- upload¶
翻訳ファイルをアップロードする。
- --overwrite¶
アップロード時に既存の翻訳を上書きする。
- --input¶
内容を読み込むファイル。指定しない場合は、stdin から読み込む。
- --fuzzy¶
あいまい(要修正付き)文字列処理(空文字列、
process、approve)
- --author-name¶
翻訳者名、現在認証されているユーザーを上書き
- --author-email¶
翻訳者名のメールアドレス、現在認証されているユーザーを上書き
ヒント
--help を付加すると、個々のコマンドの呼び出しに関するより詳細な情報を取得できます。例: wlc ls --help。
設定ファイル¶
When --config is provided, wlc loads only that file.
Without --config, wlc first loads the discovered global
configuration file from the standard platform-specific locations:
C:\Users\NAME\AppData\Roaming\weblate.iniGlobal configuration file on Windows in the roamed profile.
C:\Users\NAME\AppData\Local\weblate.iniGlobal configuration file on Windows in the local profile.
~/.config/weblateGlobal configuration file on Unix-like systems.
/etc/xdg/weblateSystem-wide fallback configuration file.
このプログラムは XDG の仕様に準拠しているので、環境変数 XDG_CONFIG_HOME や XDG_CONFIG_DIRS を使用して設定ファイルの配置を変更できます。
Windows では、設定ファイルの設置場所として、APPDATA および LOCALAPPDATA ディレクトリを推奨します。
After loading the global configuration, wlc loads the nearest project configuration file from the current directory or its parents:
.weblate、.weblate.ini、weblate.iniProject configuration file placed in the repository.
Only the closest project configuration file is loaded. Configuration files in farther parent directories are ignored.
[weblate] セクションで設定可能な設定( --config-section でカスタマイズできる):
- key
Removed in version 1.17:
[keys]セクションを使用して、個々の API URL のスコープを設定したキーを指定します。参照: レガシー構成。
- url
API サーバーの URL、デフォルトは
http://127.0.0.1:8000/api/。
- translation
デフォルトの翻訳へのパス - コンポーネントまたはプロジェクト。
- allow_insecure_http
Allow API keys over non-local
http://URLs, defaults tofalse. Loopback HTTP URLs, such ashttp://127.0.0.1:8000/api/, remain allowed for local development without this option. Prefer HTTPS instead of enabling this setting. Automatically discovered project configuration files cannot enable this option; set it in user configuration, an explicit--configfile,WLC_ALLOW_INSECURE_HTTP, or--allow-insecure-http. The setting is cumulative: any trusted source that enables insecure HTTP is enough, and false or unset values from command-line or environment sources do not disable it.
- retries, timeout, allowed_methods, backoff_factor, status_forcelist
Optional HTTP retry and timeout settings passed to
urllib3. Useallowed_methodsto list the request methods that may be retried. Current wlc releases use this setting name in place of the oldermethod_whitelistoption.
設定ファイルは、次のような INI ファイル:
[weblate]
url = https://hosted.weblate.org/api/
translation = weblate/application
retries = 3
allowed_methods = PUT,POST,GET
backoff_factor = 0.2
status_forcelist = 429,500,502,503,504
timeout = 30
allow_insecure_http = false
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. The [keys] lookup is scoped to the
exact API URL.
In CI, unscoped keys must pin the API URL explicitly: set both
WLC_URL and WLC_KEY, or use --url together with
--key.
Environment variables¶
Added in version 1.18.0.
バージョン 2.0.1 で変更: Unscoped API keys require an explicit API URL when project configuration is
discovered automatically. API keys are rejected over non-local http://
URLs unless insecure HTTP is explicitly enabled.
The API URL and key can also be configured using environment variables. This is
especially useful for CI workflows where WLC_URL pins the destination
and WLC_KEY is injected as a secret:
- WLC_URL¶
API URL
- WLC_KEY¶
API key. When the API URL would otherwise come from automatically discovered project configuration,
WLC_KEYis accepted only together withWLC_URL. API keys are rejected over non-localhttp://URLs by default.
- WLC_ALLOW_INSECURE_HTTP¶
Set to
1,true,yes, oronto allow API keys over non-localhttp://URLs. Prefer HTTPS or loopback HTTP instead. Other values, such as0orfalse, are treated as unset and do not disableallow_insecure_httpfrom configuration.
The same protection applies to command-line arguments: --key is
accepted with automatically discovered project configuration only when
--url is provided.
The API URL and key configuration precedence (highest to lowest) is:
Configuration loaded from
--config, or from the discovered global configuration plus the nearest project configuration when--configis not used.
The insecure HTTP opt-in is enable-only rather than a normal precedence
setting. It is enabled when --allow-insecure-http is passed, when
WLC_ALLOW_INSECURE_HTTP has a true value, or when
allow_insecure_http is enabled in trusted configuration. Automatically
discovered project configuration cannot enable it; set it in user
configuration or pass an explicit --config file instead.
コマンド実行例:¶
現在のプログラムのバージョンの表示方法:
$ 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