Weblate-klient¶
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
You can also execute it directly using uvx:
uvx wlc --help
Råd
Du kan också använda detta wlc som en Python-modul, se wlc.
Användning av Docker¶
Weblate Client finns även tillgänglig som Docker-bild.
Images are published on Docker Hub and the GitHub Container Registry. The examples below use the Docker Hub image name.
Installerar:
docker pull weblate/wlc
The following tags are available:
latestLatest stable release.
- Full version, for example
2.2.0 A specific stable release.
- Major version, for example
2 Latest stable release in that major series.
edgeCurrent development version from the main branch.
edge-YYYY-MM-DD-COMMITA specific development snapshot.
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.
Kommandot för att starta containern använder följande syntax:
docker run --rm weblate/wlc [WLC_ARGS]
Exempel:
docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects
You might want to pass your Konfigurationsfiler 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.
Kom igång¶
The easiest way to get started is to create a personal
wlc configuration in ~/.config/weblate (see
Konfigurationsfiler for the full discovery rules and other locations):
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = APIKEY
Du kan sedan anropa kommandon på standardservern:
wlc ls
wlc commit sandbox/hello-world
Se även
Äldre konfiguration¶
Förändrat i version 1.17: Den äldre konfigurationen med ospecificerad key stöds inte längre.
Förändrat i version 2.2.0: Global allow_insecure_http configuration is no longer supported.
Configure an origin in the [insecure_http] section instead.
Migrera äldre konfiguration:
[weblate]
url = https://hosted.weblate.org/api/
key = YOUR_KEY_HERE
Till en konfiguration med nyckel som omfattar en API-URL:
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = YOUR_KEY_HERE
Sammanfattning¶
wlc [arguments] <command> [options]
Kommandon anger faktiskt vilken åtgärd som ska utföras.
Beskrivning¶
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.
Argument¶
Programmet accepterar följande argument som definierar utdataformat eller vilken Weblate-instans som ska användas. Dessa måste anges före alla kommandon.
- --format {csv,json,text,html}¶
Specify the output format. The default is
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
versioncommand 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¶
Ange API-URL. Åsidosätter alla värden som finns i konfigurationsfilen, se Konfigurationsfiler. URL:en ska sluta med
/api/, till exempelhttps://hosted.weblate.org/api/.
- --key KEY¶
Specify the API user key to use. Overrides any value found in the configuration file, see Konfigurationsfiler. You can find your key in your profile on Weblate. When the API URL is loaded from 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. 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 project configuration, this option requires
--url.
- --config PATH¶
Load configuration only from
PATHinstead of the discovered global and project configuration files, see Konfigurationsfiler.
- --project-config PATH¶
Load personal configuration followed by this project file, without automatic project discovery or location checks. Project credential and transport restrictions still apply. This preserves shared configuration outside a repository while retaining personal URL-scoped API keys.
- --no-config¶
Do not load any configuration files. Built-in defaults, environment variables, and command-line options still apply. This option,
--config, and--project-configare mutually exclusive.
- --config-section SECTION¶
Selects the configuration file section to use instead of
[weblate], see Konfigurationsfiler.
Object paths¶
Commands that operate on an object accept one of these paths:
PROJECTProject slug.
PROJECT/COMPONENTComponent slug, including its project.
PROJECT/COMPONENT/LANGUAGETranslation language, including its project and component.
UNIT_IDNumeric translation unit ID. Only commands that explicitly support units accept this form.
Commands that require an object use the translation setting from
Konfigurationsfiler 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.
Kommandon¶
Följande kommandon är tillgängliga:
- list-languages¶
Lists all languages in Weblate.
- list-projects¶
Lists all projects in Weblate.
- 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¶
Lists units in the specified translation.
- --query QUERY¶
Filters units using the search query syntax.
- show¶
Shows a project, component, translation, or unit.
- delete¶
Deletes a project, component, translation, or unit without a confirmation prompt.
- ls¶
Lists all projects when no object is specified, components in a project, or translations in a component.
- commit¶
Bekräftar ändringar som gjorts i ett Weblate-objekt (översättning, komponent eller projekt).
- pull¶
Hämtar ändringar från fjärrarkivet till Weblate-objekt (översättning, komponent eller projekt).
- push¶
Skickar Weblate-objektändringar till fjärrförvaret (översättning, komponent eller projekt).
- reset¶
Återställer ändringar i Weblate-objekt så att de matchar det fjärranslutna arkivet (översättning, komponent eller projekt).
- cleanup¶
Tar bort alla ospårade ändringar i ett Weblate-objekt så att det matchar det fjärranslutna arkivet (översättning, komponent eller projekt).
- repo¶
Visar arkivstatus för ett visst Weblate-objekt (översättning, komponent eller projekt).
- stats¶
Visar detaljerad statistik för ett visst Weblate-objekt (översättning, komponent eller projekt).
- lock-status¶
Displays the lock status of a component.
- lock¶
Låser komponenten från vidare översättning i Weblate.
- unlock¶
Låser upp översättning av Weblate-komponenten.
- changes¶
Displays changes for a project, component, or translation.
- download¶
Downloads translation files. For a translation, wlc writes the file to
--outputor to redirected standard output. It refuses to write raw file content to an interactive terminal.For a component or project,
--outputis 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
FORMATon 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¶
Laddar upp en översättningsfil.
- --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}¶
Upload method to use, see Importmetoder. The default is
translate.
- --fuzzy {process,approve}¶
Selects processing of fuzzy strings (marked for edit).
- --author-name NAME¶
Författarens namn, för att åsidosätta den för närvarande autentiserade användaren
- --author-email EMAIL¶
Författarens e-postadress, för att åsidosätta den för närvarande autentiserade användaren
- edit-unit¶
Updates a translation unit. At least one update option is required.
- --target TARGET [TARGET ...]¶
Sets one or more translated strings.
- --state STATE¶
Sets the unit state:
0for empty,10for fuzzy,20for translated, or30for approved.
- --explanation EXPLANATION¶
Sets the string explanation.
- --extra-flags FLAGS¶
Sets additional string flags.
Råd
Du kan få mer detaljerad information om hur du använder enskilda kommandon genom att ange --help, till exempel: wlc ls --help.
Konfigurationsfiler¶
When --config is provided, wlc loads only that file.
With --no-config, it loads no configuration files. With
--project-config, it loads personal configuration followed by the
named project file and does not discover another project configuration.
Personal configuration is discovered 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.
~/.config/weblate.iniAlternative global configuration filename on Unix-like systems.
/etc/xdg/weblateSystem-wide fallback configuration file.
/etc/xdg/weblate.iniAlternative system-wide fallback filename.
Programmet följer XDG-specifikationen, så du kan justera placeringen av konfigurationsfiler med miljövariablerna XDG_CONFIG_HOME eller XDG_CONFIG_DIRS.
I Windows är katalogerna APPDATA och LOCALAPPDATA de föredragna platserna för konfigurationsfilen.
Unless --project-config selects a file explicitly, loading personal
configuration is followed by discovery of the nearest project configuration
file from the current directory or its parents:
.weblate,.weblate.ini,weblate.iniProject configuration file placed in the repository.
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.
Only the closest eligible project configuration file is loaded. Discovery
includes the nearest repository root and stops there. Repository roots are
identified by a .git directory or worktree file, or a .hg or
.svn directory. Without a repository marker, discovery continues until
a filesystem or permission boundary.
On POSIX systems, discovery stops at directories owned by someone other than
the current effective user or root, or writable by everyone. World-writable
sticky directories such as /tmp are also boundaries. Discovered
configuration files must meet the same ownership and write-permission checks. Group-writable locations
remain supported and require trusting the writable group. A safe nearer
configuration below a boundary is still used.
On Windows, repository boundaries apply, but POSIX ownership and write-mode checks are not performed. Access remains governed by Windows ACLs. Additional ACL grants and concurrent filesystem replacement are outside the POSIX checks.
Symlinked configuration is supported when the resolved file and its containing directories meet these checks and stay within the discovery boundaries. An unsafe candidate produces an error instead of silently using another server. Filesystem inspection failures are also reported as configuration errors.
To intentionally use a shared file above a repository or outside these boundaries while keeping personal API keys, select it explicitly:
wlc --project-config /shared/weblate.ini list-projects
This bypasses discovery location checks but retains project credential and
transport restrictions. Use --config instead when the selected file
should replace personal configuration and supply trusted transport settings.
Följande inställningar kan konfigureras i avsnittet [weblate] (du kan anpassa detta med --config-section):
- key
Removed in version 1.17: Använd avsnittet
[keys]för att ange nycklar som gäller för enskilda API-URL:er, se Äldre konfiguration.
- url
API-serverns URL, standardvärdet är
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.
retriesdefaults to0andbackoff_factorto0.status_forcelistis a comma-separated list of HTTP status codes that trigger retries and is empty by default.allowed_methodslists methods that may be retried, separated by commas or whitespace. It defaults toHEAD,DELETE,OPTIONS,PUT, andGET. These retry settings are passed tourllib3.util.Retry.timeoutis the request timeout in seconds and defaults to300. Current wlc releases useallowed_methodsin place of the oldermethod_whitelistoption.
Konfigurationsfilen är en INI-fil, till exempel:
[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
API-nycklarna lagras i avsnittet [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
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.
Förändrat i version 2.2.0: TLS certificates are verified for all hosts by default. Insecure HTTP and
TLS configuration is scoped to origins. 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.
Environment variables¶
Added in version 1.18.0.
Förändrat i 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.
Förändrat i version 2.2.0: Insecure HTTP and TLS environment overrides require WLC_URL when
the API URL would otherwise come from 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¶
URL för API
- WLC_KEY¶
API key. When the API URL would otherwise come from 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. When the API URL would otherwise come from project configuration, this variable is accepted only together withWLC_URL.
- WLC_ALLOW_INSECURE_SSL¶
Set to
1,true,yes, oronto disable TLS certificate verification. Other values, such as0orfalse, are treated as unset. When the API URL would otherwise come from project configuration, this variable is accepted only together withWLC_URL.
The same protection applies to command-line arguments: --key,
--allow-insecure-http, and --allow-insecure-ssl are accepted
with project configuration only when --url is provided.
The API URL and key configuration precedence (highest to lowest) is:
Configuration loaded from
--config, or personal configuration followed by the explicitly selected or nearest eligible project configuration. With--no-config, no configuration files contribute settings.
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. Project configuration cannot add trusted origins.
Security model¶
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 or --no-config when this is
not desired. Discovery boundaries limit where configuration is found; they do
not make the contents of a repository trustworthy.
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.
Exempel¶
Skriv ut aktuell programversion:
$ wlc version
Lista alla projekt:
$ 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/
Ladda upp översättningsfil:
$ wlc upload project/component/language --input /tmp/hello.po
Du kan också ange vilket projekt wlc ska arbeta med:
$ 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/
Med denna inställning är det enkelt att bekräfta väntande ändringar i det aktuella projektet:
$ wlc commit