Klien Weblate

Pemasangan

Klien Weblate dikirim secara terpisah dan termasuk modul Python. Untuk menggunakan perintah di bawah ini, Anda perlu memasang wlc menggunakan Pip:

pip install wlc

Anda juga dapat menjalankannya secara langsung menggunakan uvx:

uvx wlc --help

Petunjuk

Anda juga dapat menggunakan ini wlc sebagai modul python, lihat wlc.

Penggunaan Docker

Klien Weblate juga tersedia sebagai gambar Docker.

Gambar ini dipublikasikan di Docker Hub: https://hub.docker.com/r/weblate/wlc

Memasang:

docker pull weblate/wlc

Kontainer Docker menggunakan pengaturan bawaan Weblate dan terhubung ke API yang disebarkan di localhost. URL API dan API_Key dapat dikonfigurasi melalui argumen yang diterima oleh Weblate.

Perintah untuk meluncurkan kontainer menggunakan sintaksis berikut:

docker run --rm weblate/wlc [WLC_ARGS]

Contoh:

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

You might want to pass your Berkas konfigurasi 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

Memulai

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

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

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

Anda kemudian dapat menjalankan perintah pada server bawaan:

wlc ls
wlc commit sandbox/hello-world

Lihat juga

Berkas konfigurasi

Konfigurasi lawas

Berubah pada versi 1.17: Konfigurasi lawas yang menggunakan key tanpa cakupan tidak lagi didukung.

Migrasikan konfigurasi lawas:

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

Ke konfigurasi dengan kunci yang tercakup pada URL API:

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

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

Sinopsis

wlc [arguments] <command> [options]

Perintah sebenarnya menunjukkan operasi mana yang harus dilakukan.

Deskripsi

Klien Weblate adalah pustaka Python dan utilitas baris perintah untuk mengelola Weblate dari jarak jauh menggunakan API REST Weblate. Utilitas baris perintah ini dapat dipanggil sebagai wlc dan terintegrasi dengan wlc.

Argumen

Program menerima argumen berikut yang menentukan format keluaran atau instansi Weblate mana yang akan digunakan. Argumen ini harus dimasukkan sebelum perintah apa pun.

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

Spesifikasikan format keluaran.

--url URL

Tentukan URL API. Menimpakan nilai apa pun yang ditemukan dalam berkas konfigurasi, lihat Berkas konfigurasi. URL harus diakhiri dengan /api/, misalnya https://hosted.weblate.org/api/.

--key KEY

Tentukan kunci pengguna API yang akan digunakan. Menimpakan nilai apa pun yang ditemukan dalam berkas konfigurasi, lihat Berkas konfigurasi. Anda dapat menemukan kunci Anda di profil Anda di Weblate.

--config PATH

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

--config-section SECTION

Menimpakan bagian berkas konfigurasi yang digunakan, lihat Berkas konfigurasi.

Perintah

Perintah berikut tersedia:

version

Mencetak versi terkini.

list-languages

Mencantumkan bahasa yang digunakan di Weblate.

list-projects

Mencantumkan proyek di Weblate.

list-components

Mencantumkan komponen dalam Weblate.

list-translations

Mencantumkan terjemahan di Weblate.

show

Menampilkan objek Weblate (terjemahan, komponen atau proyek).

ls

Mencantumkan objek Weblate (terjemahan, komponen atau proyek).

commit

Mengkomit perubahan yang dibuat pada objek Weblate (terjemahan, komponen atau proyek).

pull

Menarik perubahan repositori jarak jauh ke objek Weblate (terjemahan, komponen atau proyek).

push

Mendorong perubahan objek Weblate ke repositori jarak jauh (terjemahan, komponen atau proyek).

reset

Mengatur ulang perubahan pada objek Weblate agar sesuai dengan repositori jarak jauh (terjemahan, komponen atau proyek).

cleanup

Menghapus segala perubahan yang tidak terlacak pada objek Weblate agar cocok dengan repositori jarak jauh (terjemahan, komponen, atau proyek).

repo

Menampilkan status repositori untuk objek Weblate tertentu (terjemahan, komponen atau proyek).

stats

Menampilkan statistik terperinci untuk objek Weblate tertentu (terjemahan, komponen atau proyek).

lock-status

Menampilkan status kunci.

lock

Mengunci komponen dari terjemahan lebih lanjut di Weblate.

unlock

Membuka kunci terjemahan komponen Weblate.

changes

Menampilkan perubahan untuk objek tertentu.

download

Mengunduh berkas terjemahan.

--convert

Mengonversi format berkas, jika tidak ditentukan, tidak ada konversi yang terjadi di server dan berkas diunduh apa adanya ke repositori.

--output

Menspesifikasikan berkas tempat menyimpan keluaran, jika tidak dispesifikasikan, akan dicetak ke stdout.

upload

Mengunggah berkas terjemahan.

--overwrite

Timpa terjemahan yang ada saat mengunggah.

--input

Berkas dari konten yang dibaca, jika tidak dispesifikasikan maka akan dibaca dari stdin.

--method

Metode unggah yang akan digunakan, lihat Metode impor.

--fuzzy

Pemrosesan string fuzzy (ditandai untuk disunting) (empty, process, approve)

--author-name

Nama penulis, untuk menimpakan pengguna yang saat ini diautentikasi

--author-email

Surel penulis, untuk menimpakan pengguna yang saat ini diautentikasikan

Petunjuk

Anda bisa mendapatkan informasi lebih rinci tentang menjalankan perintah individual dengan meneruskan --help, misalnya: wlc ls --help.

Berkas konfigurasi

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.ini

Global configuration file on Windows in the roamed profile.

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

Global configuration file on Windows in the local profile.

~/.config/weblate

Global configuration file on Unix-like systems.

/etc/xdg/weblate

System-wide fallback configuration file.

Program ini mengikuti spesifikasi XDG, sehingga Anda dapat menyesuaikan penempatan berkas konfigurasi dengan variabel lingkungan XDG_CONFIG_HOME atau XDG_CONFIG_DIRS.

Pada Windows, direktori APPDATA dan LOCALAPPDATA adalah lokasi pilihan untuk berkas konfigurasi.

After loading the global configuration, wlc loads the nearest project configuration file from the current directory or its parents:

.weblate, .weblate.ini, weblate.ini

Project configuration file placed in the repository.

Only the closest project configuration file is loaded. Configuration files in farther parent directories are ignored.

Pengaturan berikut dapat dikonfigurasikan di bagian [weblate] (Anda dapat menyesuaikannya dengan --config-section):

key

Removed in version 1.17: Gunakan bagian [keys] untuk menentukan kunci yang dicakup untuk URL API individual, lihat Konfigurasi lawas.

url

URL server API, bawaannya adalah http://127.0.0.1:8000/api/.

translation

Jalur ke terjemahan bawaan - komponen atau proyek.

retries, timeout, allowed_methods, backoff_factor, status_forcelist

Optional HTTP retry and timeout settings passed to urllib3. Use allowed_methods to list the request methods that may be retried. Current wlc releases use this setting name in place of the older method_whitelist option.

Berkas konfigurasi adalah berkas INI, misalnya:

[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

Kunci API disimpan di bagian [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. In CI, keep only the repository configuration in version control and inject the API key using WLC_KEY.

Variabel lingkungan

Added in version 1.18.0.

The API URL and key can also be configured using environment variables. This is especially useful for CI workflows where the repository provides the project configuration and WLC_KEY is injected as a secret:

WLC_URL

URL API

WLC_KEY

Kunci API

Urutan konfigurasi (tertinggi ke terendah) adalah:

  1. Command-line arguments (--url, --key).

  2. Environment variables (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.

Contoh

Cetak versi program saat ini:

$ wlc version
version: 0.1

Daftar semua proyek:

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

Unggah berkas terjemahan:

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

Anda juga dapat menentukan proyek mana wlc yang harus dikerjakan:

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

Dengan pengaturan ini, mudah untuk mengkomit perubahan yang tertunda pada proyek saat ini:

$ wlc commit