Weblate Client

Installation

The Weblate Client is shipped separately and includes the Python module. The source code is maintained in the WeblateOrg/wlc repository. To use the commands below, you need to install wlc using pip:

pip install wlc

Sie können ihn auch direkt mit uvx ausführen:

uvx wlc --help

Hinweis

Sie können auch dieses wlc als ein Python-Modul verwenden, siehe wlc.

Docker-Nutzung

Weblate Client ist auch als Docker-Image verfügbar.

Images are published on Docker Hub and the GitHub Container Registry. The examples below use the Docker Hub image name.

Installieren:

docker pull weblate/wlc

Die folgenden Tags sind verfügbar:

latest

Neueste stabile Version.

Vollversion, zum Beispiel 2.2.0

Eine bestimmte stabile Version.

Hauptversion, zum Beispiel 2

Neueste stabile Version dieser Hauptreihe.

edge

Aktuelle Entwicklungsversion aus dem Haupt-Branch.

edge-YYYY-MM-DD-COMMIT

Ein bestimmter Entwicklungssnapshot.

To build an image from the source checkout:

docker build -t 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.

Der Befehl zum Starten des Containers hat die folgende Syntax:

docker run --rm weblate/wlc [WLC_ARGS]

Beispiel:

docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects

You might want to pass your Konfigurationsdateien 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. The same pairing is required for the --allow-insecure-http and --allow-insecure-ssl overrides.

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. TLS certificates are always verified by default, including for loopback URLs. Use --allow-insecure-ssl or WLC_ALLOW_INSECURE_SSL only when certificate verification can not be enabled.

Erste Schritte

The easiest way to get started is to create a personal wlc configuration in ~/.config/weblate (see Konfigurationsdateien for the full discovery rules and other locations):

[weblate]
url = https://hosted.weblate.org/api/

[keys]
https://hosted.weblate.org/api/ = APIKEY

Sie können dann Befehle auf dem Standardserver aufrufen:

wlc ls
wlc commit sandbox/hello-world

Ältere Konfiguration

Geändert in Version 1.17: Die alte Konfiguration mit uneingeschränktem key wird nicht mehr unterstützt.

Geändert in Version 2.2.0: Global allow_insecure_http configuration is no longer supported. Configure an origin in the [insecure_http] section instead.

Migrieren Sie Ihre alte Konfiguration:

[weblate]
url = https://hosted.weblate.org/api/
key = YOUR_KEY_HERE

Zu einer Konfiguration mit Schlüssel, die auf eine API-URL beschränkt ist:

[weblate]
url = https://hosted.weblate.org/api/

[keys]
https://hosted.weblate.org/api/ = YOUR_KEY_HERE

Kurzfassung

wlc [arguments] <command> [options]

Die Befehle geben an, welcher Vorgang ausgeführt werden soll.

Beschreibung

Weblate Client is a Python library and command-line utility to manage Weblate remotely using Weblates REST-API. Invoke the command-line utility as wlc; see wlc for the Python API.

Argumente

Das Programm akzeptiert die folgenden Argumente, die das Ausgabeformat oder die zu verwendende Weblate-Instanz definieren. Diese müssen vor jedem Befehl eingegeben werden.

--format {csv,json,text,html}

Gibt das Ausgabeformat an. Der Standard ist text.

Listing commands write results incrementally in all formats as API pages are fetched, reducing memory use for large listings. Normal output buffering still applies. Empty listings produce no output, including in JSON format.

If a later request fails, already written results remain on standard output, and the command reports the error on standard error and exits with a nonzero status. JSON and HTML output can be incomplete in this case. Check the exit status before treating an export as complete.

--version

Print the program version and exit. The version command supports output formatting and can print only the version number.

--debug

Print verbose HTTP communication. Authorization header values are redacted and request bodies are not logged, but query parameters are; do not put secrets in query parameters.

--url URL

Gibt die API-URL an. Überschreibt jeden Wert, der in der Konfigurationsdatei gefunden wird, siehe Konfigurationsdateien. Die URL sollte mit /api/ enden, zum Beispiel https://hosted.weblate.org/api/.

--key KEY

Specify the API user key to use. Overrides any value found in the configuration file, see Konfigurationsdateien. You can find your key in your profile on Weblate. When the API URL is loaded from automatically discovered project configuration, --key must be used together with --url. API keys are rejected over non-local http:// 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. When the API URL comes from automatically discovered project configuration, this option requires --url.

--allow-insecure-ssl

Disable TLS certificate verification for the current run. Certificates are verified by default for every HTTPS URL, including loopback URLs. When the API URL comes from automatically discovered project configuration, this option requires --url.

--config PATH

Load configuration only from PATH instead of the discovered global and project configuration files, see Konfigurationsdateien.

--config-section SECTION

Selects the configuration file section to use instead of [weblate], see Konfigurationsdateien.

Objektpfade

Commands that operate on an object accept one of these paths:

PROJECT

Projekt-Slug.

PROJECT/COMPONENT

Komponenten-Slug, einschließlich seines Projekts.

PROJECT/COMPONENT/LANGUAGE

Translation language, including its project and component.

UNIT_ID

Numeric translation unit ID. Only commands that explicitly support units accept this form.

Commands that require an object use the translation setting from Konfigurationsdateien when the path is omitted. The ls and download commands also use this setting before falling back to their no-object behavior. For list-components and list-translations, an omitted object always requests an instance-wide list.

Befehle

Die folgenden Befehle sind verfügbar:

version

Gibt die aktuelle Version aus.

--bare

Gibt nur die Versionsnummer aus.

list-languages

Listet alle Sprachen in Weblate auf.

list-projects

Listet alle Projekte in Weblate auf.

list-components

Lists all components in Weblate, or components in the specified project.

list-translations

Lists all translations in Weblate, or translations in the specified component.

list-units

Listet die Einheiten in der angegebenen Übersetzung auf.

--query QUERY

Filters units using the search query syntax.

show

Zeigt ein Projekt, eine Komponente, eine Übersetzung oder eine Einheit an.

delete

Löscht ein Projekt, eine Komponente, eine Übersetzung oder eine Einheit ohne Sicherheitsabfrage.

ls

Lists all projects when no object is specified, components in a project, or translations in a component.

commit

Committet Änderungen am Weblate-Objekt (Übersetzung, Komponente oder Projekt).

pull

Zieht Änderungen aus einem Remote-Repository in ein Weblate-Objekt (Übersetzung, Komponente oder Projekt).

push

Pusht Änderungen an Weblate-Objekten in ein Remote-Repository (Übersetzung, Komponente oder Projekt).

reset

Setzt Änderungen im Weblate-Objekt zurück, damit es mit dem Remote-Repository übereinstimmt (Übersetzung, Komponente oder Projekt).

cleanup

Entfernt alle nicht nachverfolgten Änderungen im Weblate-Objekt, um es an das Remote-Repository anzupassen (Übersetzung, Komponente oder Projekt).

repo

Zeigt den Repository-Status für ein bestimmtes Weblate-Objekt an (Übersetzung, Komponente oder Projekt).

stats

Zeigt detaillierte Statistiken für ein bestimmtes Weblate-Objekt an (Übersetzung, Komponente oder Projekt).

lock-status

Zeigt den Sperrstatus einer Komponente an.

lock

Sperrt die Komponente vor weiterer Übersetzung in Weblate.

unlock

Entsperrt die Übersetzung der Weblate-Komponente.

changes

Displays changes for a project, component, or translation.

download

Downloads translation files. For a translation, wlc writes the file to --output or to redirected standard output. It refuses to write raw file content to an interactive terminal.

For a component or project, --output is required and is treated as a directory. wlc writes one ZIP archive per component. With no object, it downloads every component in the Weblate instance in the same way.

--convert FORMAT

Requests conversion to FORMAT on the server. If unspecified, no conversion happens.

--output PATH

Specifies the output file for a translation or output directory for a component, project, or instance-wide download. Use - to write a translation to standard output.

--no-glossary

Excludes glossary components from component, project, and instance-wide downloads.

upload

Lädt eine Übersetzungsdatei hoch.

--overwrite

Overwrites existing translated strings. This is equivalent to --conflicts replace-translated.

--conflicts {ignore,replace-translated,replace-approved}

Selects how conflicts with existing translations are handled.

--input PATH

Reads content from PATH. If unspecified or -, content is read from standard input.

--method {translate,approve,suggest,fuzzy,replace,source,add}

Zu verwendende Upload-Methode, siehe Importmethoden. Der Standard ist translate.

--fuzzy {process,approve}

Selects processing of fuzzy strings (marked for edit).

--author-name NAME

Autor-Name, um den aktuell authentifizierten Benutzer zu überschreiben

--author-email EMAIL

Autor-E-Mail, um den aktuell authentifizierten Benutzer zu überschreiben

edit-unit

Aktualisiert eine Übersetzungseinheit. Mindestens eine Aktualisierungsoption ist erforderlich.

--target TARGET [TARGET ...]

Setzt eine oder mehrere übersetzte Zeichenketten.

--state STATE

Setzt den Einheitenstatus: 0 für leer, 10 für ungenau, 20 für übersetzt oder 30 für genehmigt.

--explanation EXPLANATION

Setzt die Zeichenkettenerklärung.

--extra-flags FLAGS

Setzt zusätzliche Zeichenkettenmarkierungen.

Hinweis

Genauere Informationen zum Aufruf einzelner Befehle erhalten Sie, wenn Sie --help übergeben, zum Beispiel: wlc ls --help.

Konfigurationsdateien

Wenn --config angegeben wird, lädt wlc nur diese Datei.

Ohne --config, lädt wlc zunächst die erkannte globale Konfigurationsdatei aus den standardmäßigen plattformspezifischen Orten:

C:\Users\NAME\AppData\Roaming\weblate.ini

Globale Konfigurationsdatei unter Windows im Roaming-Profil.

C:\Users\NAME\AppData\Local\weblate.ini

Globale Konfigurationsdatei unter Windows im lokalen Profil.

~/.config/weblate

Globale Konfigurationsdatei auf Unix-ähnlichen Systemen.

~/.config/weblate.ini

Alternative global configuration filename on Unix-like systems.

/etc/xdg/weblate

Systemweite Fallback-Konfigurationsdatei.

/etc/xdg/weblate.ini

Alternative system-wide fallback filename.

Das Programm folgt der XDG-Spezifikation, so dass Sie die Platzierung der Konfigurationsdateien durch die Umgebungsvariablen XDG_CONFIG_HOME oder XDG_CONFIG_DIRS anpassen können.

Unter Windows sind die Verzeichnisse APPDATA und LOCALAPPDATA die bevorzugten Orte für die Konfigurationsdatei.

Nach dem Laden der globalen Konfiguration lädt wlc die nächstgelegene Projekt-Konfigurationsdatei aus dem aktuellen Verzeichnis oder dessen übergeordneten Verzeichnissen:

.weblate, .weblate.ini, weblate.ini

Projekt-Konfigurationsdatei, die im Repository abgelegt wird.

Project configuration is loaded after global configuration and overrides matching settings. It can select the API URL, default object, request settings, and a matching URL-scoped API key, allowing a cloned repository to automatically select its Weblate server and translation.

Es wird nur die nächstgelegene Projekt-Konfigurationsdatei geladen. Konfigurationsdateien in weiter entfernten übergeordneten Verzeichnissen werden ignoriert.

Die folgenden Einstellungen können im Abschnitt [weblate] konfiguriert werden (Sie können dies mit --config-section anpassen):

key

Removed in version 1.17: Verwenden Sie den Abschnitt [keys] zur Angabe von Schlüsseln, die für einzelne API-URLs gelten, siehe Ältere Konfiguration.

url

API-Server-URL, standardmäßig http://127.0.0.1:8000/api/.

translation

Default object path for commands that accept one: a project, component, translation, or numeric unit ID.

retries, timeout, allowed_methods, backoff_factor, status_forcelist

HTTP request retry and timeout settings. retries defaults to 0 and backoff_factor to 0. status_forcelist is a comma-separated list of HTTP status codes that trigger retries and is empty by default.

allowed_methods lists methods that may be retried, separated by commas or whitespace. It defaults to HEAD, DELETE, OPTIONS, PUT, and GET. These retry settings are passed to urllib3.util.Retry.

timeout is the request timeout in seconds and defaults to 300. Current wlc releases use allowed_methods in place of the older method_whitelist option.

Die Konfigurationsdatei ist eine INI-Datei, zum Beispiel:

[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

Die API-Schlüssel werden im Abschnitt [keys] gespeichert:

[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 complete configured API URL, not merely its network origin.

Project configuration can also supply or replace a matching entry in [keys]. Do not commit valuable API keys to version control; normally keep keys in personal configuration and only the API URL and default object in project configuration.

Insecure transport exceptions are stored in origin-scoped sections in trusted user configuration:

[insecure_http]
http://legacy.example.com:80 = true

[insecure_ssl]
https://legacy.example.com:443 = true

An origin consists of the scheme, normalized hostname, and effective port. The API path is ignored, while different schemes and ports remain isolated. The [insecure_http] section allows API keys over non-local HTTP for matching origins. The [insecure_ssl] section disables TLS certificate verification for matching origins.

Geändert in Version 2.2.0: TLS certificates are verified for all hosts by default. Insecure HTTP and TLS configuration is scoped to origins. Automatically discovered project configuration can neither add entries to these sections nor enable the removed global settings. User configuration and explicitly selected --config files are trusted.

In CI, unscoped keys must pin the API URL explicitly: set both WLC_URL and WLC_KEY, or use --url together with --key.

Umgebungsvariablen

Added in version 1.18.0.

Geändert in Version 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.

Geändert in Version 2.2.0: Insecure HTTP and TLS environment overrides require WLC_URL when the API URL would otherwise come from automatically discovered project configuration.

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_KEY is accepted only together with WLC_URL. API keys are rejected over non-local http:// URLs by default.

WLC_ALLOW_INSECURE_HTTP

Set to 1, true, yes, or on to allow API keys over non-local http:// URLs. Prefer HTTPS or loopback HTTP instead. Other values, such as 0 or false, are treated as unset. When the API URL would otherwise come from automatically discovered project configuration, this variable is accepted only together with WLC_URL.

WLC_ALLOW_INSECURE_SSL

Set to 1, true, yes, or on to disable TLS certificate verification. Other values, such as 0 or false, are treated as unset. When the API URL would otherwise come from automatically discovered project configuration, this variable is accepted only together with WLC_URL.

The same protection applies to command-line arguments: --key, --allow-insecure-http, and --allow-insecure-ssl are accepted with automatically discovered project configuration only when --url is provided.

Die Priorität der API-URL und Schlüsselkonfiguration (von hoch nach niedrig) ist:

  1. Befehlszeilenargumente (--url, --key).

  2. Umgebungsvariablen (WLC_URL, WLC_KEY).

  3. Configuration loaded from --config, or from the discovered global configuration plus the nearest project configuration when --config is not used.

The insecure transport opt-ins are enable-only rather than normal precedence settings. They are enabled by a command-line or environment override, or by a matching origin in the trusted [insecure_http] or [insecure_ssl] section. Automatically discovered project configuration cannot add trusted origins.

Sicherheitsmodell

Project configuration is part of the repository workflow and is intentionally trusted to select the API endpoint, default object, request settings, and a matching URL-scoped API key. Running wlc inside a repository authorizes its nearest project configuration to select the server that receives commands and uploads and supplies displayed or downloaded content. Use an explicit trusted --config file when this is not desired.

The command-line client accepts API keys from --key, WLC_KEY, or the [keys] section. It does not load HTTP authentication from .netrc or the file named by NETRC. Credentials embedded in API URLs are rejected; use an API key instead. Other Requests environment integration, including proxy and CA-bundle variables, remains enabled.

The wlc threat model documents the complete trust boundaries, security properties, non-goals, and downstream responsibilities. A version-matched copy is included in source and wheel distributions. Report security issues using the Weblate vulnerability reporting process.

Beispiele

Aktuelle Programmversion ausgeben:

$ wlc version

Alle Projekte auflisten:

$ 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/

Übersetzungsdatei hochladen:

$ wlc upload project/component/language --input /tmp/hello.po

Es ist auch möglich anzugeben, an welchem Projekt wlc arbeiten soll:

$ 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/

Mit dieser Einrichtung können ausstehende Änderungen im aktuellen Projekt einfach committet werden:

$ wlc commit