Integrating with Weblate

Weblate の基本

プロジェクトとコンポーネントの構造

Weblate では、翻訳はプロジェクトとコンポーネントで構成されています。各プロジェクトには複数のコンポーネントを含めることができ、コンポーネントには個々の言語への翻訳を含めることができます。コンポーネントは、翻訳可能な 1 つのファイル(例: GNU gettextAndroid string resources)に対応します。プロジェクトは、コンポーネントを論理的なまとまりに分類(例えば、1 つのアプリケーション内で使用するすべての翻訳をグループ化)するのに便利です。

内部ではデフォルトで、各プロジェクトごとに、共通する文字列の翻訳はプロジェクト内の他のコンポーネントに自動反映させます。これにより、反復や複数バージョンの翻訳の負担を軽減します。コンポーネント独自の翻訳が望ましい場合は、翻訳の反映を Component configuration ごとに無効にできます。

現地語化プロジェクトを Weblate にインポート

Weblate has been developed with VCS integration in mind as it’s core feature, so the easiest way is to grant Weblate the access to your repository. The import process will guide you through configuring your translations into components.

Alternatively, you can use Weblate to set up a local repository containing all the translations without integration.

更新された翻訳を Weblate から取得

To fetch updated strings from Weblate, you can simply fetch the underlying Git repository (either from filesystem, or it can be made available through Git exporter). Prior to this, you might want to commit any pending changes (see Lazy commits). You can do so in the user interface (in the Repository maintenance) or from the command-line using Weblate クライアント.

This can be automated if you grant Weblate push access to your repository and configure リポジトリの送信先 URL in the Component configuration, see Pushing changes from Weblate.

Alternatively, you can use Weblate の REST API to update translations to match their latest version.

リモート変更を Weblate にフェッチ

To fetch the strings newly updated in your repository into Weblate, just let it pull from the upstream repository. This can be achieved in the user interface (in the Repository maintenance), or from the command-line using Weblate クライアント.

This can be automated by setting a webhook in your repository to trigger Weblate whenever there is a new commit, see Updating repositories for more details.

If you’re not using a VCS integration, you can use UI or Weblate の REST API to update translations to match your code base.

新しい文字列の追加

In case your translation files are stored in a VCS together with the code, you most likely have an existing workflow for developers to introduce new strings. Any way of adding strings will be picked up, but consider using 原文の品質ゲートウェイ to avoid introducing errors.

When the translation files are separate from the code, there are following ways to introduce new strings into Weblate.

注釈

Availability of adding strings in Weblate depends on 文字列の管理.

翻訳対象の言語ファイルの更新

For monolingual files (see 対応するファイル形式) Weblate might add new translation strings not present in the 単一言語のベース言語ファイル, and not in actual translations. It does not however perform any automatic cleanup of stale strings as that might have unexpected outcomes. If you want to do this, please install 翻訳ファイルのクリーンアップ addon which will handle the cleanup according to your requirements.

Weblate also will not try to update bilingual files in any way, so if you need po files being updated from pot, you need to do it yourself using Update source strings インポート方法 or using POT に合わせて PO ファイルを更新 (msgmerge) addon.

バージョン コントロール リポジトリの管理

Weblate stores all translation the version control repository. It can be either connected to upstream one, or it can be only internal. The Repository maintenance lets you manipulate with the repository.

ヒント

With 継続的な現地語化 the repository is automatically pushed whenever there are changes and there is usually no need to manually manipulate with it.

../_images/component-repository.png

Following operations are available:

Commit

Commits any pending changes present in Weblate database and not in the repository, see Lazy commits.

Push

Pushes changes to the upstream repository, if configured by リポジトリの送信先 URL.

Update, Pull, Rebase

Updates Weblate repository with upstream changes. It uses マージ スタイル when choosing Update or you can choose different one from the dropdown menu.

Lock

ロックすると、翻訳者は変更できなくなります

Reset from Maintenance

Resets any changes done in Weblate to match upstream repository. This will discard all translations done in Weblate and not present in the upstream repository.

Cleanup from Maintenance

Removes untracked files from the repository. These could be result of misbehaving add-ons or bugs.

Force synchronization from Maintenance

Forces writing all strings to the translation files. Use this when repository files became out of sync with Weblate for some reason.