Klient Weblate
Nowe w wersji 2.7: There has been full wlc utility support ever since Weblate 2.7. If you are using an older version some incompatibilities with the API might occur.
Instalacja
The Weblate Client is shipped separately and includes the Python module.
To use the commands below, you need to install wlc
:
pip install wlc
Użycie platformy Docker
The Weblate Client is also available as a Docker image.
The image is published on Docker Hub: https://hub.docker.com/r/weblate/wlc
Instalowanie:
docker pull weblate/wlc
The Docker container uses Weblate’s default settings and connects to the API deployed in localhost. The API URL and API_KEY can be configured through the arguments accepted by Weblate.
The command to launch the container uses the following syntax:
docker run --rm weblate/wlc [WLC_ARGS]
Przykład:
docker run --rm weblate/wlc --url https://hosted.weblate.org/api/ list-projects
You might want to pass your Plik konfiguracyjny to the Docker container, the
easiest approach is to add your current directory as /home/weblate
volume:
docker run --volume $PWD:/home/weblate --rm weblate/wlc show
Pierwsze kroki
The wlc configuration is stored in ~/.config/weblate
(see Plik konfiguracyjny
for other locations), please create it to match your environment:
[weblate]
url = https://hosted.weblate.org/api/
[keys]
https://hosted.weblate.org/api/ = APIKEY
You can then invoke commands on the default server:
wlc ls
wlc commit sandbox/hello-world
Zobacz także
Streszczenie
wlc [arguments] <command> [options]
Commands actually indicate which operation should be performed.
Opis
Weblate Client is a Python library and command-line utility to manage Weblate remotely
using REST API Weblate. The command-line utility can be invoked as wlc and is
built-in on wlc
.
Argumenty
The program accepts the following arguments which define output format or which Weblate instance to use. These must be entered before any command.
- --format {csv,json,text,html}
Określ format danych wyjściowych.
- --url URL
Specify the API URL. Overrides any value found in the configuration file, see Plik konfiguracyjny. The URL should end with
/api/
, for examplehttps://hosted.weblate.org/api/
.
- --key KEY
Specify the API user key to use. Overrides any value found in the configuration file, see Plik konfiguracyjny. You can find your key in your profile on Weblate.
- --config PATH
Overrides the configuration file path, see Plik konfiguracyjny.
- --config-section SECTION
Overrides configuration file section in use, see Plik konfiguracyjny.
Polecenia
Te polecenia są dostępne:
- version
Wydrukuj bieżącą wersję.
- list-languages
Lista języków używanych w Weblate.
- list-projects
Lista projektów w Weblate.
- list-components
Lista komponentów w Weblate.
- list-translations
Lista tłumaczeń w Weblate.
- show
Shows Weblate object (translation, component or project).
- ls
Lists Weblate object (translation, component or project).
- commit
Commits changes made in a Weblate object (translation, component or project).
- pull
Pulls remote repository changes into Weblate object (translation, component or project).
- push
Pushes Weblate object changes into remote repository (translation, component or project).
- reset
Nowe w wersji 0.7: Obsługiwane od wersji wlc 0.7.
Resets changes in Weblate object to match remote repository (translation, component or project).
- cleanup
Nowe w wersji 0.9: Obsługiwane od wersji wlc 0.9.
Removes any untracked changes in a Weblate object to match the remote repository (translation, component or project).
- repo
Displays repository status for a given Weblate object (translation, component or project).
- stats
Displays detailed statistics for a given Weblate object (translation, component or project).
- lock-status
Nowe w wersji 0.5: Obsługiwane od wersji wlc 0.5.
Wyświetla stan blokady.
- lock
Nowe w wersji 0.5: Obsługiwane od wersji wlc 0.5.
Locks component from further translation in Weblate.
- unlock
Nowe w wersji 0.5: Obsługiwane od wersji wlc 0.5.
Unlocks translation of Weblate component.
- changes
Nowe w wersji 0.7: Supported since wlc 0.7 and Weblate 2.10.
Displays changes for a given object.
- download
Nowe w wersji 0.7: Obsługiwane od wersji wlc 0.7.
Pobierz plik z tłumaczeniami.
- --convert
Converts file format, if unspecified no conversion happens on the server and the file is downloaded as is to the repository.
- --output
Specifies file to save output in, if left unspecified it is printed to stdout.
- upload
Nowe w wersji 0.9: Obsługiwane od wersji wlc 0.9.
Przesyła plik tłumaczenia.
- --overwrite
Overwrite existing translations upon uploading.
- --input
File from which content is read, if left unspecified it is read from stdin.
- --method
Upload method to use, see Metody importu.
- --fuzzy
Fuzzy (marked for edit) strings processing (empty,
process
,approve
)
- --author-name
Author name, to override currently authenticated user
- --author-email
Author e-mail, to override currently authenticated user
Podpowiedź
You can get more detailed information on invoking individual commands by
passing --help
, for example: wlc ls --help
.
Plik konfiguracyjny
.weblate
,.weblate.ini
,weblate.ini
Zmienione w wersji 1.6: The files with .ini extension are accepted as well.
Per project configuration file
C:\Users\NAME\AppData\weblate.ini
Nowe w wersji 1.6.
Plik konfiguracyjny użytkownika dla Windows.
~/.config/weblate
Plik konfiguracyjny użytkownika
/etc/xdg/weblate
Plik konfiguracyjny dla całego systemu
The program follows the XDG specification, so you can adjust placement of config files
by environment variables XDG_CONFIG_HOME
or XDG_CONFIG_DIRS
. On Windows
APPDATA
directory is preferred location for the configuration file.
Following settings can be configured in the [weblate]
section (you can
customize this by --config-section
):
- key
API KEY to access Weblate.
- url
API server URL, defaults to
http://127.0.0.1:8000/api/
.
- translation
Path to the default translation - component or project.
The configuration file is an INI file, for example:
[weblate]
url = https://hosted.weblate.org/api/
key = APIKEY
translation = weblate/application
Additionally API keys can be 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.
Przykłady
Wydrukuj aktualną wersję programu:
$ wlc version
version: 0.1
Lista wszystkich projektów:
$ 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/
Prześlij plik tłumaczenia:
$ wlc upload project/component/language --input /tmp/hello.po
You can also designate what project wlc should work on:
$ 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/
With this setup it is easy to commit pending changes in the current project:
$ wlc commit