版本控制整合

Weblate 目前支援 Git ( 並擴充至 GitHub 拉取請求GitLab 合併請求Gitea 拉取請求Gerrit review requestsSubversionBitbucket Cloud 拉取請求Bitbucket Data Center pull requestsAzure DevOps 拉取請求) 與 Mercurial 作為版本控制後端。

For provider-specific setup steps that combine repository access, incoming notifications, and pushing translations back, see Code hosting integrations.

存取儲存庫

Weblate 必須存取您要使用的 VCS 儲存庫。使用公開的儲存庫,您只需輸入正確的 URL(例如 https://github.com/WeblateOrg/weblate.git ),但對於私人儲存庫或推送 URL,設定更複雜並且需要驗證。

從 Hosted Weblate 存取儲存庫

備註

This section applies only to Hosted Weblate (hosted.weblate.org). If you are running your own self-hosted Weblate instance, please see the next section instead.

For Hosted Weblate, there is a dedicated push user registered on GitHub, Bitbucket, Codeberg, and GitLab (with the username weblate, e-mail hosted@weblate.org, and a name or profile description Weblate push user).

提示

There can be more Weblate users on the platforms, designated for other Weblate instances. Searching by e-mail hosted@weblate.org is recommended to find the correct user for Hosted Weblate.

You need to add this user as a collaborator and give it appropriate permissions to your repository (read-only is okay for cloning, write is required for pushing). Depending on the service and your organization’s settings, this happens immediately, or requires confirmation on the Weblate side.

On GitHub, you need to add or invite the Hosted Weblate weblate user with write access even when you use the Hosted Weblate GitHub app. The app handles incoming notifications from GitHub, but pushing changes back still uses the Hosted Weblate weblate user.

The weblate user on GitHub accepts invitations automatically within five minutes. Manual processing might be needed on the other services, so please be patient.

Once the weblate user is added to your repository, you can configure 原始碼儲存庫 and 儲存庫推送 URL using the SSH protocol (for example git@github.com:WeblateOrg/weblate.git).

在程式碼託管網站上存取儲存庫 (GitHub、GitLab、Bitbucket、Azure DevOps 等)

備註

This section applies to self-hosted Weblate instances. If you are using Hosted Weblate (hosted.weblate.org), see 從 Hosted Weblate 存取儲存庫 instead.

For self-hosted Weblate, accessing repositories on code hosting sites is typically done by creating a dedicated user who is associated with a Weblate SSH key (see Weblate SSH 金鑰). This way you associate Weblate SSH key with a single user (platforms frequently enforce single use of an SSH key) and grant this user access to the repository. You can then use SSH URL to access the repository (see SSH 儲存庫).

SSH 儲存庫

存取私有儲存庫的最常用方法是基於 SSH。授權公共 Weblate SSH 金鑰(請參閱 Weblate SSH 金鑰)以這種方式存取上游儲存庫。

警告

On GitHub, each key can only be used once, see GitHub repository access and 從 Hosted Weblate 存取儲存庫.

Weblate 還會在首次連接時儲存主機金鑰指紋,並且在以後進行變更時將無法連接到主機(請參閱 驗證 SSH 主機金鑰)。

如需調整,請從 Weblate 管理介面進行:

_images/ssh-keys.webp

Weblate SSH 金鑰

在 4.17 版的變更: Weblate now generates both RSA and Ed25519 SSH keys. Using Ed25519 is recommended for new setups.

Weblate 公鑰對瀏覽 About 頁面的所有使用者可見。

管理員可以在管理介面登入頁面的連接部分(從 SSH keys)產生或顯示 Weblate 目前使用的公共金鑰。

備註

The corresponding private SSH key can not currently have a password, so ensure it is well protected.

提示

對產生的私有 Weblate SSH 金鑰進行備份。

驗證 SSH 主機金鑰

Weblate 在第一次存取時自動儲存SSH主機金鑰,並記住它們以備將來使用。

In case you want to verify the key fingerprint before connecting to the repository, add the SSH host keys of the servers you are going to access in Add host key, from the same section of the admin interface. Enter the hostname you are going to access (e.g. gitlab.com), and press Submit. Verify its fingerprint matches the server you added.

帶指紋的新增鍵顯示在確認消息中:

_images/ssh-keys-added.webp

連線至舊式 SSH 伺服器

Recent OpenSSH releases (for example the one used in Weblate Docker container) disable RSA signatures using the SHA-1 hash algorithm by default. This change has been made as the SHA-1 hash algorithm is cryptographically broken, and it is possible to create chosen-prefix hash collisions for <USD$50K.

For most users, this change should be invisible and there is no need to replace ssh-rsa keys. OpenSSH has supported RFC8332 RSA/SHA-256/512 signatures since release 7.2 and existing ssh-rsa keys will automatically use the stronger algorithm where possible.

Incompatibility is more likely when connecting to older SSH implementations that have not been upgraded or have not closely tracked improvements in the SSH protocol. The SSH connection to such server will fail with:

no matching host key type found. Their offer: ssh-rsa

For these cases, it may be necessary to selectively re-enable RSA/SHA1 to allow connection and/or user authentication via the HostkeyAlgorithms and PubkeyAcceptedAlgorithms options. For example, the following stanza in DATA_DIR/ssh/config will enable RSA/SHA1 for host and user authentication for a single destination host:

Host legacy-host
   HostkeyAlgorithms +ssh-rsa
   PubkeyAcceptedAlgorithms +ssh-rsa

We recommend enabling RSA/SHA1 only as a stopgap measure until legacy implementations can be upgraded or reconfigured with another key type (such as ECDSA or Ed25519).

GitHub 儲存庫

Detailed GitHub repository access is covered in GitHub repository access.

GitLab 儲存庫

Detailed GitLab repository access is covered in GitLab repository access.

Weblate 內部 URL

Share one repository setup between different components by referring to its placement as weblate://project/component in other (linked) components. This way linked components use the VCS repository configuration of the main (referenced) component.

警告

刪除主組件也會刪除連結組件。

如果在建立組件時,Weblate 會自動調整儲存庫網址,如果它找到具有比對的儲存庫設定的組件。您可以在組件配置的最後一步中覆寫這一點。

使用這個的理由:

  • 儲存伺服器上的磁碟空間,儲存庫僅儲存一次。

  • 使更新更快,只更新一個儲存庫。

  • 只有單一匯出的儲存庫,具有 Weblate 翻譯(請參閱 Git 匯出器)。

  • 某些附加元件可以在共享一個儲存庫的多個元件上執行,例如 匯併 Git 提交

HTTPS 儲存庫

要存取受保護的 HTTPS 儲存庫,請在網址中包含使用者名稱和密碼。別擔心,Weblate 會在網址向使用者顯示 URL 時剝離此資訊(如果允許查看儲存庫網址)。

例如,新增了具有身分驗證的GitHub URL可能看起來像:https:// user:your_access_token @ github.com / weblateorg / webbleate.git

In case you don't provide credentials in the URL and the repository requires it, Git will fail with an error:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

在 5.10.2 版的變更: Weblate uses proactive authentication with Git 2.46.0 and newer when HTTP credentials are supplied.

This makes it possible to access Azure DevOps repositories and makes access to authenticated repositories faster.

備註

If your username or password contains special characters, those have to be URL encoded, for example https://user%40example.com:%24password%23@bitbucket.org/….

使用代理

如果您需要使用代理伺服器存取 HTTP/HTTPS VCS 儲存庫,請配置 VCS 以使用它。

這可以透過使用 http_proxyhttps_proxyall_proxy 環境變數來完成 (就像 cURL 說明文件 中描述的那樣) 或在 VCS 配置中執行它,例如:

git config --global http.proxy http://user:password@proxy.example.com:80

備註

代理配置需要在使用者使用 Weblate 下完成設定。(請參閱 檔案系統權限)並設定 HOME=$DATA_DIR/home(請參閱 DATA_DIR),否則 Weblate 將無法透過 Git 執行它。

Git

提示

Weblate 需要 Git 2.28 或更新版本。

也參考

請參閱 存取儲存庫 用於如何存取不同型別的儲存庫的資訊。

Git 強制推送

這表現得比很像 Git 本身,唯一的區別是它總是強制推動。這僅在使用單獨的儲存庫進行翻譯的情況下。

警告

謹慎使用,因為這很容易導致上游儲存庫中的遺失。

自訂 Git 配置

Weblate 用 Home = $ Data_Dir / Home 觸發所有 VCS 指令(請參閱 DATA_DIR),因此需要在 data_dir / home / .git 中編輯使用者配置。

GitHub 拉取請求

Detailed GitHub pull request setup is covered in GitHub 拉取請求.

GitLab 合併請求

Detailed GitLab merge request setup is covered in GitLab 合併請求.

Gitea 拉取請求

Detailed Gitea pull request setup is covered in Gitea 拉取請求.

Bitbucket Data Center pull requests

Detailed Bitbucket Data Center pull request setup is covered in Bitbucket Data Center pull requests.

Bitbucket Cloud 拉取請求

Detailed Bitbucket Cloud pull request setup is covered in Bitbucket Cloud 拉取請求.

Pagure 合併請求

Detailed Pagure merge request setup is covered in Pagure 合併請求.

Gerrit

Detailed Gerrit review request setup is covered in Gerrit review requests.

Azure DevOps 拉取請求

Detailed Azure DevOps pull request setup is covered in Azure DevOps 拉取請求.

Mercurial

Mercurial 是另一個您可以直接在 Weblate 中使用的版本控制系統。

備註

它應該能與任何 Mercurial 版本配合使用,但命令列介面偶爾會出現不相容的變更打破 Weblate 整合。

也參考

請參閱 存取儲存庫 用於如何存取不同型別的儲存庫的資訊。

Subversion

Weblate 使用 git-svnsubversion 儲存庫進行互動。它是一個 Perl 指令稿,它允許 Git 用戶端使用 subversion,使使用者能夠維護內部儲存庫的完整複製並在本機提交。

備註

Weblate 嘗試自動檢測 Subversion 儲存庫配置 - 它支援具有標準配置的分支或儲存庫的直接網址(branches/、tags/ 和 trunk/)。有關此內容的更多資訊將在 git-svn 文件 中找到。如果您的儲存庫沒有標準配置並且您遇到錯誤,請嘗試在儲存庫網址中包含分支名稱並將分支為空。

Subversion 憑證

Weblate 希望您在前面接受憑證(如果需要,您的憑證)。它將查看將它們插入 DATA_DIR 目錄。使用 SVN(使用 $HOME 環境變數設定為 DATA_DIR

# Use DATA_DIR as configured in Weblate settings.py, it is /app/data in the Docker
HOME=${DATA_DIR}/home svn co https://svn.example.com/example

也參考

DATA_DIR

本地檔案

提示

Underneath, this uses Git. It requires Git installed and allows you to switch to using Git natively with full history of your translations.

Weblate 也可以在沒有遠端 VCS 的情況下執行。透過上傳匯入初始翻譯。稍後您可以通過上傳取代個別檔案,或從 Weblate 直接新增翻譯字串 (目前僅對單語言翻譯可用)。

Weblate 在背景為您建立 Git 儲存庫並追蹤所有變更。如果您之後決定使用版本控制系統儲存翻譯,Weblate 內建儲存庫可作為整合基礎。