Weblate kliens¶
Telepítés¶
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 execute it directly using uvx:
uvx wlc --help
Tipp
A wlc Python modulként is használható, lásd: wlc.
Docker használat¶
A Weblate kliens Docker-képként is elérhető.
Az kép elérhető a Docker Hub-on: https://hub.docker.com/r/weblate/wlc
Telepítés:
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.
A konténer indításához használt parancs az alábbi szintaxist követi:
docker run --rm weblate/wlc [WLC_ARGS]
Példa:
docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects
You might want to pass your Konfigurációs fájlok 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.
Kezdeti lépések¶
The easiest way to get started is to create a personal
wlc configuration in ~/.config/weblate (see
Konfigurációs fájlok for the full discovery rules and other locations):
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = APIKEY
Ezután a parancsokat már a beállított kiszolgálón hajthatja végre:
wlc ls
wlc commit sandbox/hello-world
Lásd még
Legacy configuration¶
A 1.17 verzióban változott: The legacy configuration using unscoped key is no longer supported.
Migrate legacy configuration:
[weblate]
url = https://hosted.weblate.org/api/
key = YOUR_KEY_HERE
To a configuration with key scoped to an API URL:
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = YOUR_KEY_HERE
Áttekintés¶
wlc [arguments] <command> [options]
A parancsok azt jelölik, milyen műveletet kíván végrehajtani.
Leírás¶
A Weblate kliens egy Python-könyvtár és parancssori segédprogram, amellyel a Weblate távolról kezelhető a REST API segítségével. A parancssori eszköz a wlc paranccsal hívható meg, és a wlc modul része.
Argumentumok¶
A program az alábbi argumentumokat fogadja el, amelyek a kimeneti formátumot vagy a használt Weblate-példányt határozzák meg. Ezeket a parancs előtt kell megadni.
- --format {csv,json,text,html}¶
A kimeneti formátum megadása.
- --url URL¶
Az API URL megadása. Felülír minden, a konfigurációs fájlban szereplő értéket, lásd: Konfigurációs fájlok. Az URL végződjön
/api/karakterlánccal, például:https://hosted.weblate.org/api/.
- --key KEY¶
Specify the API user key to use. Overrides any value found in the configuration file, see Konfigurációs fájlok. 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.
- --config PATH¶
Load configuration only from
PATHinstead of the discovered global and project configuration files, see Konfigurációs fájlok.
- --config-section SECTION¶
A konfigurációs fájl használatban lévő szakaszának felülírása, lásd: Konfigurációs fájlok.
Parancsok¶
Az alábbi parancsok érhetők el:
- version¶
Az aktuális verzió kiírása.
- list-languages¶
A Weblate-ben használt nyelvek listázása.
- list-projects¶
A Weblate-projektek listázása.
- list-components¶
A Weblate-összetevők listázása.
- list-translations¶
A Weblate-fordítások listázása.
- show¶
Weblate-objektum (fordítás, összetevő vagy projekt) megjelenítése.
- ls¶
Weblate-objektum (fordítás, összetevő vagy projekt) listázása.
- commit¶
Módosítások véglegesítése egy Weblate-objektumban (fordítás, összetevő vagy projekt).
- pull¶
A távoli tárolóból származó változások letöltése a Weblate-objektumba (fordítás, összetevő vagy projekt).
- push¶
A Weblate-objektumban történt változások feltöltése a távoli tárolóba (fordítás, összetevő vagy projekt).
- reset¶
A Weblate-objektumban végzett módosítások visszaállítása a távoli tároló állapotának megfelelően (fordítás, összetevő vagy projekt).
- cleanup¶
Minden nem követett módosítás eltávolítása a Weblate-objektumból a távoli tároló állapotának megfelelően (fordítás, összetevő vagy projekt).
- repo¶
A megadott Weblate-objektumhoz tartozó tároló állapotának megjelenítése (fordítás, összetevő vagy projekt).
- stats¶
Részletes statisztikák megjelenítése egy megadott Weblate-objektumhoz (fordítás, összetevő vagy projekt).
- lock-status¶
Zárolási állapot megjelenítése.
- lock¶
Összetevő zárolása a Weblate-ben történő további fordítás elől.
- unlock¶
A Weblate-összetevő fordításának feloldása (zárolás megszüntetése).
- changes¶
Egy megadott objektumhoz tartozó módosítások megjelenítése.
- download¶
Fordítási fájl letöltése.
- --convert¶
Fájlformátum konvertálása – ha nincs megadva, nem történik konverzió, és a fájl az eredeti formátumban kerül letöltésre a tárolóból.
- --output¶
A kimeneti fájl mentési helyének megadása – ha nincs megadva, az adatok a standard kimenetre kerülnek.
- upload¶
Fordítási fájl feltöltése.
- --overwrite¶
A feltöltés során a meglévő fordítások felülírása.
- --input¶
A fájl, amelyből a tartalom beolvasásra kerül – ha nincs megadva, a tartalom a standard bemenetről olvassa be.
- --method¶
A használandó feltöltési módszer, lásd: Importálási módok.
- --fuzzy¶
Szerkesztést igénylő (zavaros) szövegek feldolgozása (üres,
process,approve)
- --author-name¶
Szerző neve, az aktuálisan hitelesített felhasználó felülírásához.
- --author-email¶
Szerző e-mail címe, az aktuálisan hitelesített felhasználó felülírásához.
Tipp
Részletesebb információt kaphat az egyes parancsok használatáról a --help kapcsolóval, például: wlc ls --help.
Konfigurációs fájlok¶
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.
A program követi az XDG specifikációt, így a konfigurációs fájlok helye a XDG_CONFIG_HOME vagy XDG_CONFIG_DIRS környezeti változókkal módosítható.
Windows rendszeren az APPDATA és LOCALAPPDATA könyvtárak az ajánlott helyek a konfigurációs fájl számára.
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.
A [weblate] szekcióban az alábbi beállítások adhatók meg (ez testreszabható a --config-section segítségével):
- key
Removed in version 1.17: Use the
[keys]section to specify keys scoped for individual API URLs, see Legacy configuration.
- url
API szerver URL, alapértelmezés szerint:
http://127.0.0.1:8000/api/.
- translation
Az alapértelmezett fordítás elérési útja – összetevő vagy projekt.
- 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.
A konfigurációs fájl INI formátumú, például:
[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
The API keys are stored in the [keys] section:
[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.
A 2.0.1 verzióban változott: 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-cím
- 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.
Példák¶
A jelenlegi programverzió kiírása:
$ wlc version
version: 0.1
Projektek listázása:
$ 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/
Fordítási fájl feltöltése:
$ wlc upload project/component/language --input /tmp/hello.po
Azt is megadhatja, hogy a wlc melyik projekttel dolgozzon:
$ 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/
Ezzel a beállítással egyszerűen véglegesíthetők a jelenlegi projekt függőben lévő módosításai:
$ wlc commit