与 Weblate 集成

Weblate 基础知识

项目和组件架构

In Weblate translations are organized into projects and components. Each project can contain number of components and those contain translations into individual languages. The component corresponds to one translatable file (for example GNU gettext or Android string resources). The projects are there to help you organize component into logical sets (for example to group all translations used within one application).

Internally, each project has translations to common strings propagated across other components within it by default. This lightens the burden of repetitive and multi version translation. The translation propagation can be disabled per 组件配置 in case the translations should diverge.

正在将本地化项目导入 Weblate

Weblate was developed with VCS integration in mind. The easiest approach to integrate with it is to grant access to your VCS repository. The import process will guide you through configuring components with your translations.

In case you do not use VCS or do not want to grant access to your VCS at all, you can use Weblate without a remote VCS repository - it will create local repository with all the translations.

Getting translations updates from Weblate

To fetch updated strings from Weblate you can simply fetch the underlying 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 惰性提交). This can be achieved in the user interface (in the Repository maintenance) or from command line using Weblate 客户端.

This can be automated if you grant Weblate push access to your repository and configure 代码库推送 URL in the 组件配置.

Pushing string changes to Weblate

To push newly updated strings to Weblate, just let it pull from the upstream repository. This can be achieved in the user interface (in the Repository maintenance) or from command line using Weblate 客户端.

This can be automated by installing a webhook on your repository to trigger Weblate whenever there is a new commit, see 更新仓库 for more details.

When 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 VCS together with the code, you most likely have existing workflow for developers to introduce new strings. You might extend it by using Quality gateway for the source strings.

When the translation files are separate, there needs to be a way to introduce new strings. Weblate can add new strings on monolingual translations only (see 双语和单语格式). You have three options to do that: