管理コマンド

注釈

Web サーバーを実行しているのとは異なるユーザーで管理コマンドを実行すると、ファイルのアクセス権が不正になることがあります。詳しくは ファイル システムのアクセス権 を参照してください。

基本的な管理コマンドがあります(Django ソースでは、./manage.py として、または Weblate にインストール可能な weblate というスクリプトの拡張セットとして使用できます)。

管理コマンドの起動

前述のように、起動方法は Weblate のインストール方法によ方法はなります。

Weblate 用に Python 環境を使用している場合は、weblate へのフルパスを指定するか、あるいは実行前に Python 環境を有効化してください:

# Direct invocation
~/weblate-env/bin/weblate

# Activating Python environment adds it to search path
. ~/weblate-env/bin/activate
weblate

ソースコードを直接(tarball または Git チェックアウトから)使用している場合、Weblate から管理スクリプト ./manage.py を実行します。実行例:

python ./manage.py list_versions

pip インストーラを使用して Weblate をインストールした場合、または ./setup.py スクリプトを使用してインストールした場合、weblate がパス(または Python 環境パス)にインストールされます。パスから Weblate を管理する方法:

weblate list_versions

Docker イメージの場合、スクリプトは上記のようにインストールします。docker exec を使用した実行例:

docker exec --user weblate <container> weblate list_versions

docker-compose-plugin の場合、作業は似ていますが、docker compose exec を使用します。実行例:

docker compose exec --user weblate weblate weblate list_versions

ファイルを渡すことが必要な場合に、一時的にボリュームを追加する方法:

docker compose exec --user weblate /tmp:/tmp weblate weblate importusers /tmp/users.json

add_suggestions

weblate add_suggestions <project> <component> <language> <file>

指定された翻訳の候補として、使用する翻訳をファイルからインポートします。重複した翻訳は除外し、異なる翻訳のみ追加します。

--author USER@EXAMPLE.COM

E-mail of author for the suggestions. This user has to exist prior to importing (you can create one in the admin interface if needed).

例:

weblate --author michal@cihar.com add_suggestions weblate application cs /tmp/suggestions-cs.po

auto_translate

weblate auto_translate <project> <component> <language>

バージョン 4.6 で変更: 翻訳モードのパラメータを追加しました。

他のコンポーネントの翻訳に基づいて自動翻訳します。

--source PROJECT/COMPONENT

Specifies the component to use as source available for translation. If not specified all components in the project are used.

--user USERNAME

Specify username listed as author of the translations. "Anonymous user" is used if not specified.

--overwrite

Whether to overwrite existing translations.

--inconsistent

Whether to overwrite existing translations that are inconsistent (see 一貫性の欠如).

--add

Automatically add language if a given translation does not exist.

--mt MT

Use machine translation instead of other components as machine translations.

--threshold THRESHOLD

Similarity threshold for machine translation, defaults to 80.

--mode MODE

Specify translation mode, default is translate but fuzzy or suggest can be used.

例:

weblate auto_translate --user nijel --inconsistent --source weblate/application weblate website cs

参考

自動翻訳

backup

weblate backup

Runs configured backups synchronously, without using Celery. It first updates the settings and database backup dumps in DATA_DIR, then runs the selected Borg backup service or services.

--list

Lists configured backup service IDs.

--service ID

Runs one backup service by ID.

--all

Runs all enabled backup services.

Use Django's standard --verbosity 2 option to show backup service output. Failed backup service output is shown even without increased verbosity.

例:

weblate backup --list
weblate backup --service 1 --verbosity 2
weblate backup --all

For Docker Compose deployments, you can stop the regular Weblate container and run the command in a one-off container using docker compose run. The database and configured backup storage still need to be available.

docker compose stop weblate
docker compose run --rm --user weblate weblate weblate backup --list
docker compose run --rm --user weblate weblate weblate backup --service 1 --verbosity 2

benchmark

weblate benchmark

与えられたコンテンツを Weblate にインポートします。ベンチマークに便利です。

パフォーマンス プロファイリングの例
# Run benchmark with a profiling
python -m cProfile -o benchmark.prof ./manage.py benchmark --project benchmark --filemask '*.tbx' --format tbx --zipfile /tmp/MicrosoftTermCollection2.zip

# Convert to SVG for visualization
uvx gprof2dot -f pstats benchmark.prof | dot -Tsvg -o benchmark.svg

# Display SVG
firefox ./benchmark.svg
メモリ プロファイリングの例
# Run benchmark under memray
uvx memray run ./manage.py benchmark --project benchmark --filemask '*.tbx' --format tbx --zipfile /tmp/MicrosoftTermCollection2.zip

# Render the profile
uvx memray flamegraph ./memray-manage.py.2554179.bin

# Display it
fixefox memray-flamegraph-manage.py.2554179.html

billing_demo

weblate billing_demo

Added in version 5.15.

デモ用の課金プロジェクトを作成します。追加の請求書や課金イベントを追加するために、複数回実行できます。

これは Weblate の開発時に便利です。使用するには 課金 のインストールが必要です。

celery_queues

weblate celery_queues

Celery タスク キューの長さを表示します。

checkgit

weblate checkgit <project|project/component>

バックエンド Git リポジトリの現在の状態を出力します。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

commitgit

weblate commitgit <project|project/component>

保留中の可能性がある変更を、バックエンド Git リポジトリにコミットします。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新するか、--file-format を使用してファイル形式に基づいてフィルタリングできます。

commit_pending

weblate commit_pending <project|project/component>

指定された経過時間より古い保留中の変更をコミットします。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

--age HOURS

Age in hours for committing. If not specified the value configured in コンポーネント構成 is used.

注釈

これは、Weblate が自動でバックグラウンドで実行しています。そのため、コンポーネント構成 で指定した時間よりも早い段階でコミットを強制する以外は、これを手動で実行する必要はありません。

cleanuptrans

weblate cleanuptrans

個別の検査結果と翻訳の提案をクリーンアップします。クリーンアップはバックグラウンドで自動的に行われるため、通常はこれを手動で実行する必要はありません。

cleanup_memory

weblate cleanup_memory

Added in version 5.13.

翻訳メモリから、保留状態の古い(不要な)エントリをすべて削除します。

cleanup_ssh_keys

weblate cleanup_ssh_keys

Added in version 4.9.1.

保存している SSH ホスト鍵をクリーンアップします。

  • GitHub への接続で問題が発生することがある GitHub の非推奨の RSA 鍵を削除します。

  • ホスト鍵内の重複するエントリーを削除します。

createadmin

weblate createadmin

指定がなければ、ランダムなパスワードで admin アカウントを作成します。

--password PASSWORD

Provides a password on the command-line, to not generate a random one.

--no-password

Do not set password, this can be useful with --update.

--username USERNAME

Use the given name instead of admin.

--email USER@EXAMPLE.COM

Specify the admin e-mail address.

--name

Specify the admin name (visible).

--update

Update the existing user (you can use this to change passwords).

dump_memory

weblate dump_memory

Weblate 翻訳メモリのコンテンツを含む JSON ファイルをエクスポートします。

dumpuserdata

weblate dumpuserdata <file.json>

importuserdata を後で使用するために userdata をファイルにダンプします。

ヒント

これは、Weblate インスタンスを移行またはマージするときに便利です。

import_demo

weblate import_demo

Added in version 4.1.

<https://github.com/WeblateOrg/demo> に基づくコンポーネントを含んだデモプロジェクトを作成します。このコマンドを実行する前に、celery のタスクが実行されていることを確認してください。

これは Weblate の開発時に便利です。

--delete

Removes existing demo project.

import_json

weblate import_json <json-file>

JSON データに基づくコンポーネントの一括インポート。

インポートした JSON ファイル構造は、コンポーネント オブジェクトにほぼ対応しています (参照: GET /api/components/(string:project)/(string:component)/)。name フィールドと filemask フィールドを必ず含めてください。

--project PROJECT

Specifies where the components will be imported from.

--main-component COMPONENT

Use the given VCS repository from this component for all of them.

--ignore

Skip (already) imported components.

--update

Update (already) imported components.

JSON ファイルの例:

[
  {
    "slug": "po",
    "name": "Gettext PO",
    "file_format": "po",
    "filemask": "po/*.po",
    "new_lang": "none"
  },
  {
    "name": "Android",
    "filemask": "android/values-*/strings.xml",
    "template": "android/values/strings.xml",
    "repo": "weblate://test/test",
    "file_format": "aresource"
  }
]

参考

import_memory

import_memory

weblate import_memory <file>

ファイルを Weblate の翻訳メモリにインポートします。

サポートされているファイル形式は、TMX、JSON、XLIFF、PO、CSV です。

JSON および TMX 以外のフォーマットでは、原文言語と訳文言語の指定が必要になる場合があります。

--language-map LANGMAP

Allows mapping languages in the TMX to the Weblate translation memory. The language codes are mapped after normalization usually done by Weblate.

--language-map en_US:en will for example import all en_US strings as en ones.

This can be useful in case your TMX file locales happen not to match what you use in Weblate.

--source-language SOURCE_LANG

Specifies the source language for imported translations. Typically needed for formats where the languages cannot be determined from the file itself.

--target-language TARGET_LANG

Specifies the target language for imported translations. Typically needed for formats where the languages cannot be determined from the file itself.

import_project

weblate import_project <project> <gitrepo> <branch> <filemask>

ファイルマスクに基づいてコンポーネントをプロジェクトに一括でインポートします。この機能は、コンポーネントの検出 アドオンに基づいているので、代わりにそちらを使うといいかもしれません。

<project> に、コンポーネントをインポートする既存のプロジェクトを指定します。

<gitrepo> に、使用する Git リポジトリの URL を設定し、<branch> に Git ブランチを指定します。既存の Weblate コンポーネントから追加の翻訳コンポーネントをインポートするには、<gitrepo>weblate://<project>/<component> URL を設定します。

<filemask> はリポジトリのファイル検出を設定します。ワイルドカードを使用して単純にすることも、正規表現を全面的に使用することもできます。

単純な一致では、コンポーネント名に ** を使用し、言語に * を使用します。例: **/*.po

正規表現には、componentlanguage という名前のグループを両方とも含めてください。例: (?P<language>[^/]*)/(?P<component>[^-/]*)\.po

インポートは、ファイルに基づいて既存のコンポーネントを照合し、存在しないコンポーネントを追加します。既存のものは変更されません。

--name-template TEMPLATE

Customize the name of a component using Django template syntax.

For example: Documentation: {{ component }}

--base-file-template TEMPLATE

Customize the base file for monolingual translations.

For example: {{ component }}/res/values/string.xml

--new-base-template TEMPLATE

Customize the base file for addition of new translations.

For example: {{ component }}/ts/en.ts

--file-format FORMAT

You can also specify the file format to use (see 現地語化ファイル フォーマット), the default is auto-detection.

--language-regex REGEX

You can specify language filtering (see コンポーネント構成) with this parameter. It has to be a valid regular expression.

--main-component

You can specify which component will be chosen as the main one—the one actually containing the VCS repository.

--license NAME

Specify the overall, project or component translation license.

--license-url URL

Specify the URL where the translation license is to be found.

--vcs NAME

In case you need to specify which version control system to use, you can do it here. The default version control is Git.

例として、2 つのプロジェクトをインポートします。

はじめは、Debian ハンドブックの翻訳です。言語ごとにフォルダが別れていて、各章の翻訳が入っています。

weblate import_project \
    debian-handbook \
    https://salsa.debian.org/hertzog/debian-handbook.git \
    bullseye/main \
    '*/**.po'

次は、Tanaguru ツールです。このツールでは、ファイル形式と基礎となる翻訳ファイルのテンプレートを指定する必要があり、すべてのコンポーネントの翻訳が1つのフォルダに配置されています。

weblate import_project \
    --file-format=properties \
    --base-file-template=web-app/tgol-web-app/src/main/resources/i18n/%s-I18N.properties \
    tanaguru \
    https://github.com/Tanaguru/Tanaguru \
    master \
    web-app/tgol-web-app/src/main/resources/i18n/**-I18N_*.properties

ファイル名を解析して、src/security/Numerous_security_holes_in_0.10.1.de.po のようなファイル名から、正しいコンポーネントと言語を取得する、もっと複雑な例:

weblate import_project \
    tails \
    git://git.tails.boum.org/tails master \
    'wiki/src/security/(?P<component>.*)\.(?P<language>[^.]*)\.po$'

選択した言語の翻訳のみをフィルタする方法:

./manage import_project \
    --language-regex '^(cs|sk)$' \
    weblate \
    https://github.com/WeblateOrg/weblate.git \
    'weblate/locale/*/LC_MESSAGES/**.po'

Sphinx ドキュメントを、複数のファイルに分割してインポートする方法:

$ weblate import_project --name-template 'Documentation: %s' \
    --file-format po \
    project https://github.com/project/docs.git master \
    'docs/locale/*/LC_MESSAGES/**.po'

Sphinx ドキュメントを、複数のファイルおよびディレクトリに分割してインポートする方法:

$ weblate import_project --name-template 'Directory 1: %s' \
    --file-format po \
    project https://github.com/project/docs.git master \
    'docs/locale/*/LC_MESSAGES/dir1/**.po'
$ weblate import_project --name-template 'Directory 2: %s' \
    --file-format po \
    project https://github.com/project/docs.git master \
    'docs/locale/*/LC_MESSAGES/dir2/**.po'

参考

詳細な例については、 国際化に向けた取り組み の章を確認してください。または、import_json を代わりに使用できます。

import_projectbackup

weblate import_projectbackup <project_name> <project_slug> <username> <filename>

Added in version 5.10.

プロジェクト レベルのバックアップ のインポート

ヒント

一般的には、翻訳プロジェクトとコンポーネントの追加 する時に、プロジェクトをインポートする方が便利です。

importuserdata

weblate importuserdata <file.json>

ユーザー データを、dumpuserdata によって作成されたファイルからインポートします。

importusers

weblate importusers --check <file.json>

Django auth_users データベースの JSON ダンプからユーザーをインポートします。

--check

With this option it will just check whether a given file can be imported and report possible conflicts arising from usernames or e-mails.

既存の Django サイトからユーザー情報をコマンドでエクスポートする方法:

./manage.py dumpdata auth.User > users.json

ヒント

他の Weblate サーバーからデータをダンプするには、dumpuserdata を使用してください。それにはユーザー設定も含まれているためです。

install_addon

weblate install_addon --addon ADDON <project|project/component>

アドオンをコンポーネントのセットにインストールします。

--addon ADDON

Name of the add-on to install. For example weblate.gettext.customize.

--configuration CONFIG

JSON encoded configuration of an add-on.

--update

Update the existing add-on configuration.

アドオンをインストールするプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを含めることができます。

すべてのコンポーネントに MO ファイルの生成 をインストールする方法:

weblate install_addon --addon weblate.gettext.mo --configuration '{"fuzzy": true}' --update --all

参考

アドオン

install_machinery

Added in version 4.18.

weblate install_machinery --service SERVICE

サイト全体の自動提案サービスをインストールします。

--service SERVICE

Name of the service to install. For example deepl.

--configuration CONFIG

JSON encoded configuration of a service.

--update

Update the existing service configuration.

DeepL のインストール方法:

weblate install_machinery --service deepl --configuration '{"key": "x", "url": "https://api.deepl.com/v2/"}' --update

参考

自動提案

list_addons

weblate list_addons

アドオン 用のテンプレートとして、アドオンを reStructuredText 形式でリストアップします。

--sections {events,addons,parameters}

Filter the generated output to just the add-on event sections, the built-in add-on sections, or the shared add-on parameter sections. If omitted, all generated sections are shown.

list_permissions

weblate list_permissions

アクセス制御 用のテンプレートとして、権限を reStructuredText 形式でリストアップします。

list_checks

weblate list_checks

検査と修正 および 検査と修正 用のテンプレートとして、品質検査を reStructuredText 形式でリストアップします。

--sections {checks,flags}

Filter the generated output to just the quality check sections or the shared check flag sections. If omitted, all generated sections are shown.

注釈

Using --output requires selecting exactly one value in --sections so each generated snippet is written to its own file. This matches the Weblateドキュメントへの貢献 workflow and the make -C docs update-docs targets.

list_languages

weblate list_languages <locale>

MediaWiki マークアップで対応している言語(言語コード、英語名、現地語化された名前)を一覧表示します。

これは、<https://www.l10n.cz/wiki/Slovn%C3%ADky/Slovn%C3%ADk_s_n%C3%A1zvy_jazyk%C5%AF/> を生成するために使用します。

list_machinery

weblate list_machinery

自動提案 用のテンプレートとして、自動提案サービスを reStructuredText 形式でリストアップします。

list_translators

weblate list_translators <project|project/component>

指定したプロジェクトの提供言語別に、翻訳者を一覧表示します。

[French]
Jean Dupont <jean.dupont@example.com>
[English]
John Doe <jd@example.com>
--language-code

List names by language code instead of language name.

使用するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントから一覧表示できます。

list_versions

weblate list_versions

すべての Weblate の依存関係とそのバージョンを一覧表示します。

list_file_format_params

weblate list_file_format_params

ファイル形式のパラメータを一覧表示します。

list_change_events

weblate list_change_events

使用可能なすべての変更イベントタイプを一覧表示します。

list_format_features

weblate list_format_features

対応している各ファイル形式の機能を説明する RST ドキュメント断片を生成します。

このコマンドは、指定した出力ディレクトリ内に、各ファイル形式ごとに 1 つのファイルを生成します。

--output PATH

Directory where the format feature snippets will be written.

注釈

生成されたドキュメント ファイルは、現地語化ファイル フォーマット などのドキュメントソースに含めて使用することを想定しています。カスタマイズやマージ処理のロジックについては、weblate/formats/management/commands/list_format_features.py も参照してください。

loadpo

weblate loadpo <project|project/component>

ディスクから翻訳を再読み込みします(たとえば、VCS リポジトリで更新を行った場合)。

--force

Force update, even if the files should be up-to-date.

--lang LANGUAGE

Limit processing to a single language.

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

注釈

これを実行する必要性はほとんどありませんが、Weblate は VCS の更新ごとに変更されたファイルを自動的にロードします。これは、基礎となる Weblate VCS リポジトリを手動で変更した場合や、アップグレード後の特別な場合に必要です。

lock_translation

weblate lock_translation <project|project/component>

今後、コンポーネントの翻訳を防ぎます。

ヒント

基礎となるリポジトリをメンテナンスする場合に使用できます。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

migrate

weblate migrate

データベースを現在の Weblate スキーマに移行します。コマンドライン オプションの詳細は Django migrate に解説があります。

ヒント

コマンドでインストールをするには、weblate migrate --noinput を使用してから、createadmin コマンドを使用して admin ユーザーを作成します。

move_language

weblate move_language source target

言語コンテンツを統合するための機能です。(generated) 接頭辞付きで生成された未既知言語に対するエイリアスが新バージョンで追加された場合などに便利です。すべてのコンテンツを 原文 言語から 対象 言語に移動します。

例:

weblate move_language cze cs

コンテンツ移動後、空であることを確認してください(残存データがあると、移動中に誰かがリポジトリを更新したときに競合状態の影響を受けます)。問題がなければ、(generated) 言語を削除します。

pushgit

weblate pushgit <project|project/component>

コミットした変更を上流の VCS リポジトリにプッシュします。

--force-commit

Force commits any pending changes, prior to pushing.

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

注釈

Weblate は、コンポーネント構成コミット時にプッシュする が有効になっている場合(これはデフォルトです)、変更を自動的にプッシュします。

unlock_translation

weblate unlock_translation <project|project/component>

指定したコンポーネントのロックを解除して、翻訳できるようにします。

ヒント

基礎となるリポジトリをメンテナンスする場合に使用できます。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

setupgroups

weblate setupgroups

デフォルトのグループを設定し、必要であればすべてのユーザーをそのデフォルトのグループに割り当てます。

--no-privs-update

Turns off automatic updating of existing groups (only adds new ones).

--no-projects-update

Prevents automatic updates of groups for existing projects. This allows adding newly added groups to existing projects, see プロジェクトのアクセス制御.

参考

権限一覧

setuplang

weblate setuplang

Weblate で定義されている言語リストを更新します。

--no-update

Turns off automatic updates of existing languages (only adds new ones).

updatechecks

weblate updatechecks <project|project/component>

すべての文字列のすべての検査結果を更新します。

ヒント

検査に大きな変更を加えるようなアップグレードに使用すると便利です。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

注釈

Weblate により定期的にバックグラウンドで検査が実行されます。実行頻度は BACKGROUND_TASKS から設定します。

updategit

weblate updategit <project|project/component>

リモート VCS リポジトリを取得し、内部キャッシュを更新します。

更新するプロジェクトまたはコンポーネント(例: weblate/application)を設定するか、--all を使用して既存のすべてのコンポーネントを更新します。

注釈

通常、updategit によって更新を定期的に起動するのではなく、通知フック を起動するようにリポジトリ内のフックを設定してください。