與 Weblate 整合#
Weblate is built to integrate with upstream version control repository, 持續在地化 describes building blocks and how the changes flow between them.
Architecture overview describes how Weblate works internally.
Weblate keeps the translations properly authored by translators in the version control repository by using name and e-mail. Having a real e-mail attached to the commit follows the distributed version control spirits and allows services like GitHub to associate your contributions done in Weblate with your GitHub profile.
This feature also brings in risk of misusing e-mail published in the version control commits. Moreover, once such a commit is published on public hosting (such as GitHub), there is effectively no way to redact it. Weblate allows choosing a private commit e-mail in 帳號 to avoid this.
Therefore, admins should consider this while configuring Weblate:
Importing localization project into Weblate#
Weblate 在開發時一直注意將版本管理系統（VCS）作為核心功能。因此，最簡單的方法是授予 Weblate 存取儲存庫的權限。匯入過程將指導您將翻譯組態進元件。
可以替換使用 Weblate 來設定包含所有翻譯的本地倉儲而不合併。
Fetching updated translations from Weblate#
Weblate stores updated strings in a database and commits them to a local version control repository. You can add Weblate repository (when Git 導出器 is turned on) as additional remote and fetch translations update from it.
或者，您可以使用 doc:/api 來更新翻譯以匹配最新版本。
Fetching remote changes into 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 客戶端.
這可以通過在您的儲存庫中設定一個 webhook 來自動實現，每當有新的送交時，webhook 就會觸發 Webate。更多細節請參見 更新儲存庫。
如果您沒在用一個版本管理系統（VCS）整合，可以使用 UI 或 Weblate 的 REST API 來更新翻譯，從而與您的碼基匹配。
Adding new strings#
If your translation files are stored in a remote 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 translation files are separated from the code, the following ways can introduce new strings into Weblate.
Manually, using Add new translation string from Tools menu in the source language.
Programmatically, using the API
通過上傳源文件為:guilabel:Replace existing translation file`（這覆蓋了現有的字串，因此請確定文件包括舊的和新的字串）或:guilabel:`Add new strings，請參見: ref:upload-method。
The ability to add strings in Weblate requires 管理字串.
Updating target language files#
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 清理翻譯檔 add-on 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
更新 PO 檔以符合 POT (msgmerge) add-on.
Introducing new strings#
You can add new strings in Weblate with 管理字串 turned on, but it is usually better to introduce new strings together with the code changes that introduced them.
Monolingual formats need addition of the new string to 單語的基底語言檔. This is typically done by the developers during developing the code. You might want to introduce review of those strings using 來源字串的品質閘道.
Bilingual formats typically extract strings from the source code using some tooling (like xgettext or intltool-update). Follow your localization framework documentation for instructions how to do that. Once the strings are extracted, there might be an additional step needed to update existing translations, see Updating target language files.
Automating string extraction is presently out of scope for Weblate. It typically involves executing untrusted code what makes it more suitable for a generic continuous integration than localization-specific platform.
You might want to integrate this into your continuous integration pipelines to make new strings automatically appear for translation. Such pipeline should also cover 避免發生合併衝突.
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.