Weblate Client¶
Installation¶
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
També podeu executar-lo directament mitjançant uvx:
uvx wlc --help
Suggeriment
També podeu utilitzar aquest wlc com a mòdul de Python, vegeu wlc.
Docker usage¶
El client Weblate també està disponible com a imatge de Docker.
La imatge es publica a Docker Hub: https://hub.docker.com/r/weblate/wlc
Installing:
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.
L’ordre per llançar el contenidor utilitza la sintaxi següent:
docker run --rm weblate/wlc [WLC_ARGS]
Exemple:
docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects
És possible que vulgueu passar el vostre Fitxers de configuració al contenidor de Docker. Quan el vostre dipòsit conté una configuració de projecte com ara .weblate, l’enfocament més fàcil és afegir el vostre directori actual com el volum /home/weblate:
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.
Per començar¶
La manera més senzilla de començar és crear una configuració personal wlc a ~/.config/weblate (vegeu Fitxers de configuració per a les regles completes de descobriment i altres ubicacions):
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = APIKEY
A continuació, podeu invocar ordres al servidor predeterminat:
wlc ls
wlc commit sandbox/hello-world
Vegeu també
Legacy configuration¶
Canviat a la versió 1.17: The legacy configuration using unscoped key is no longer supported.
Migrate legacy configuration:
[weblate]
url = https://hosted.weblate.org/api/
key = YOUR_KEY_HERE
Per a una configuració amb l’àmbit de la clau a l’URL d’una API:
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = YOUR_KEY_HERE
Synopsis¶
wlc [arguments] <command> [options]
Les ordres indiquen realment quina operació s’ha de realitzar.
Descripció¶
Weblate Client és una biblioteca de Python i una utilitat de línia d’ordres per gestionar Weblate de forma remota mitjançant API REST de Weblate. La utilitat de línia d’ordres es pot invocar com a wlc i està integrada a wlc.
Arguments¶
El programa accepta els arguments següents que defineixen el format de sortida o quina instància de Weblate utilitzar. S’han d’introduir abans de qualsevol comanda.
- --format {csv,json,text,html}¶
Especifiqueu el format de sortida.
- --url URL¶
Especifiqueu l’URL de l’API. Substitueix qualsevol valor que es trobi al fitxer de configuració, vegeu Fitxers de configuració. L’URL hauria d’acabar amb
/api/, per exemplehttps://hosted.weblate.org/api/.
- --key KEY¶
Specify the API user key to use. Overrides any value found in the configuration file, see Fitxers de configuració. 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¶
Carregueu la configuració només des de
PATHen comptes dels fitxers de configuració global i del projecte descoberts, vegeu Fitxers de configuració.
- --config-section SECTION¶
Substitueix la secció del fitxer de configuració en ús, vegeu Fitxers de configuració.
Commands¶
Les ordres següents estan disponibles:
- version¶
Imprimeix la versió actual.
- list-languages¶
Llista els idiomes utilitzats a Weblate.
- list-projects¶
Llista els projectes a Weblate.
- list-components¶
Llista els components a Weblate.
- list-translations¶
Llista les traduccions a Weblate.
- show¶
Mostra l’objecte Weblate (traducció, component o projecte).
- ls¶
Llista l’objecte Weblate (traducció, component o projecte).
- commit¶
Admet els canvis fets en un objecte Weblate (traducció, component o projecte).
- pull¶
Introdueix els canvis del repositori remot a l’objecte Weblate (traducció, component o projecte).
- push¶
Envia els canvis d’objecte de Weblate al repositori remot (traducció, component o projecte).
- reset¶
Restableix els canvis a l’objecte Weblate perquè coincideixin amb el dipòsit remot (traducció, component o projecte).
- cleanup¶
Elimina qualsevol canvi sense seguiment en un objecte Weblate perquè coincideixi amb el dipòsit remot (traducció, component o projecte).
- repo¶
Mostra l’estat del repositori d’un objecte Weblate determinat (traducció, component o projecte).
- stats¶
Mostra estadístiques detallades d’un objecte Weblate determinat (traducció, component o projecte).
- lock-status¶
Mostra l’estat del bloqueig.
- lock¶
Bloqueja el component de la traducció posterior a Weblate.
- unlock¶
Desbloqueja la traducció del component Weblate.
- changes¶
Mostra els canvis per a un objecte determinat.
- download¶
Baixa un fitxer de traducció.
- --convert¶
Converteix el format del fitxer, si no s’especifica, no es produeix cap conversió al servidor i el fitxer es baixa tal com està al repositori.
- --output¶
Especifica el fitxer per desar la sortida, si no s’especifica, s’imprimeix a stdout.
- upload¶
Carrega un fitxer de traducció.
- --overwrite¶
Sobreescriu les traduccions existents en penjar-les.
- --input¶
Fitxer des del qual es llegeix el contingut, si no s’especifica, es llegeix des de stdin.
- --method¶
Upload method to use, see Mètodes d’importació.
- --fuzzy¶
Processament de cadenes difuses o marcades per a editar (buit,
process,approve)
- --author-name¶
Nom de l’autor, per substituir l’usuari autenticat actualment
- --author-email¶
Correu electrònic de l’autor, per anul·lar l’usuari autenticat actualment
Suggeriment
Podeu obtenir informació més detallada sobre com invocar ordres individuals passant --help, per exemple: wlc ls --help.
Fitxers de configuració¶
Quan es proporciona --config, wlc només carrega aquest fitxer.
Sense --config, wlc carrega primer el fitxer de configuració global descobert des de les ubicacions estàndard específiques de la plataforma:
C:\Users\NAME\AppData\Roaming\weblate.iniFitxer de configuració global a Windows al perfil itinerant.
C:\Users\NAME\AppData\Local\weblate.iniFitxer de configuració global a Windows al perfil local.
~/.config/weblateFitxer de configuració global en sistemes semblants a Unix.
/etc/xdg/weblateSystem-wide fallback configuration file.
El programa segueix l’especificació XDG, de manera que podeu ajustar la ubicació dels fitxers de configuració per variables d’entorn XDG_CONFIG_HOME o XDG_CONFIG_DIRS.
A Windows, els directoris APPDATA i LOCALAPPDATA són les ubicacions preferides per al fitxer de configuració.
Després de carregar la configuració global, wlc carrega el fitxer de configuració del projecte més proper des del directori actual o dels seus pares:
.weblate,.weblate.ini,weblate.iniProject configuration file placed in the repository.
Només es carrega el fitxer de configuració del projecte més proper. Els fitxers de configuració dels directoris principals més llunyans s’ignoren.
Els paràmetres següents es poden configurar a la secció [weblate] (pot personalitzar-ho mitjançant --config-section):
- key
S’ha eliminat a la versió 1.17: Utilitzeu la secció
[keys]per especificar l’àmbit de les claus per a URL d’API individuals, vegeu Legacy configuration.
- url
URL del servidor de l’API, el valor predeterminat és
http://127.0.0.1:8000/api/.
- translation
Camí a la traducció predeterminada: component o projecte.
- 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
La configuració opcional de reintent i temps d’espera d’HTTP s’ha passat a
urllib3. Utilitzeuallowed_methodsper llistar els mètodes de sol·licitud que es poden tornar a provar. Les versions actuals de wlc utilitzen aquest nom de configuració en lloc de l’opció antigamethod_whitelist.
El fitxer de configuració és un fitxer INI, per exemple:
[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
Les claus de l’API s’emmagatzemen a la secció [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¶
Afegit a la versió 1.18.0.
Canviat a la versió 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¶
URL de l’API
- 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:
Configuració carregada des de
--config, o des de la configuració global descoberta més la configuració del projecte més propera quan no s’utilitza--config.
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.
Examples¶
Imprimeix la versió actual del programa:
$ wlc version
version: 0.1
Llista tots els projectes:
$ 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/
Upload translation file:
$ wlc upload project/component/language --input /tmp/hello.po
També podeu designar en quin projecte wlc hauria de funcionar:
$ 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/
Amb aquesta configuració és fàcil confirmar canvis pendents en el projecte actual:
$ wlc commit