版本控制整合#

Weblate currently supports Git (with extended support for GitHub pull requests, GitLab 合併請求, Gitea pull requests, Gerrit, Subversion, Bitbucket Server pull requests, and Azure DevOps pull requests) and Mercurial as version control back-ends.

存取儲存庫#

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

從託管的 Weblate 存取儲存庫#

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.

:圭冊:Github上的“Webleate”使用者在五分鐘內自動接受邀請函。在其他服務可能需要手動處理,所以請耐心等待。

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).

SSH 倉儲#

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

警告

在 Github 上,每個金鑰只能用一次,見 GitHub repositories從託管的 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 目前使用的公共金鑰。

備註

相應的私有 SSH 金鑰目前無法使用密碼,因此請確保已受到良好的保護。

提示

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

驗證 SSH 主機金鑰#

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

如果要在連接到倉儲之前對金鑰指紋進行驗證,請從管理界面的同一部分 :guilabel: 『 add host key 『 新增您要存取的伺服器的 SSH 主機金鑰。輸入您要訪問的主機名(例如 gitlab.com),然後按 Submit。驗證其指紋與您新增的服務器匹配。

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

_images/ssh-keys-added.webp

Connecting to legacy SSH servers#

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 old-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 repositories#

可以通過 SSH 存取(請參見 SSH 倉儲),但在需要存取多個儲存庫的情況下,您將在允許的 SSH 金鑰使用情況下擊中 GitHub 限制(因為每個鍵只能使用一次)。

如果 :ref:`component-push_branch`未設定,則項目被叉,並通過叉子推出的變化。如果設定,則將更改推送到上游儲存庫和所選分支。

對於較小的部署,請使用HTTPS身份驗證使用個人存取令牌和GitHub帳戶,參見“建立用於命令行使用”的存取令牌。

對於更大的設定,通常更好地為 Weblate 建立專用使用者,將其分配它在Webleate中產生的公共SSH金鑰(請參閱 Weblate SSH 金鑰)並授予您存取要轉換的所有儲存庫的訪問權限。這種方法也用於託管的 Weblate,有專門的 weblate 使用者為此。

Weblate internal URLs#

通過引用其放置在不同元件之間共享一個儲存庫設定,作為其他(連結)元件的“Web2:// Project / Component``”這種方式連結元件使用 Main(參考)元件的 VCS 儲存庫組態。

警告

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

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

Reasons to use this:

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

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

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

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

HTTPS repositories#

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

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

備註

如果您的使用者名或密碼包含特殊字元,那麼必須是URL編碼的,例如``https://user%40example.com:%24password%23 @ bitbucket.org / …``。

Using proxy#

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

這可以使用“http_proxy``”,“https_proxy``和```````````````````````````````或者通過在VCS組態中執行它,例如:

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

備註

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

Git#

提示

Weblate needs Git 2.12 or newer.

也參考

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

Git 使用強制推送#

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

警告

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

Customizing Git configuration#

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

Git remote helpers#

您還可以使用Git`Reary Helpers`_另外支援其他版本控制系統,但準備好調試問題,這可能會導致。

此時,在Github上的單獨儲存庫中提供了 Bazaar 和 Mercurial 的助手:Git-remote-Hggit-remote-bzr 。手動下載並將其放在搜尋路徑中(例如 〜/ bin)。確保安裝了相應的版本控制系統。

安裝這些已安裝後,此類遙控器可用於在 Weblate 中指定儲存庫。

使用 Bazaar 來複製在 Launchpad 上的 gnuhello 專案

bzr::lp:gnuhello

hello 倉儲在 selenic.com 上使用 Mercurial

hg::http://selenic.com/repo/hello

警告

使用Git遠端幫助程序的不便例如使用Mercurial,遠端幫助器有時會在推送更改時建立新的提示。

GitHub pull requests#

這在 GCS-Git 中新增了一個薄層:使用 GitHub API 以允許將翻譯變更推送為拉取請求,而不是直接推送到儲存庫。

Git 將變更直接推送到儲存庫,而 GitHub pull requests 建立拉取請求。僅存取 Git 儲存庫不需要後者。

You need to configure API credentials (GITHUB_CREDENTIALS) in the Weblate settings to make this work. Once configured, you will see a GitHub option when selecting 版本控制系統.

GitLab 合併請求#

這只需在 Git 上使用 GITLAB API 使用 GITLAB API 允許將翻譯變更為合併請求,而不是直接推送到儲存庫。

不需要將此用於存取 Git 儲存庫,普通 Git 執行相同,唯一的區別是如何處理推送儲存庫。使用 Git 變更直接推送到儲存庫,而 :ref:`vcs-gitlab`建立合併請求。

You need to configure API credentials (GITLAB_CREDENTIALS) in the Weblate settings to make this work. Once configured, you will see a GitLab option when selecting 版本控制系統.

Gitea pull requests#

在 4.12 版新加入.

This just adds a thin layer atop Git using the Gitea API to allow pushing translation changes as pull requests instead of pushing directly to the repository.

不需要將此用於存取 Git 儲存庫,普通 Git 執行相同,唯一的區別是如何處理推送儲存庫。使用 Git 變更直接推送到儲存庫,而 :ref:`vcs-gitea`建立拉取請求。

You need to configure API credentials (GITEA_CREDENTIALS) in the Weblate settings to make this work. Once configured, you will see a Gitea option when selecting 版本控制系統.

Bitbucket Server pull requests#

在 4.16 版新加入.

這在 GCS-Git 中新增了一個薄層:使用 github api 以允許將翻譯變更推送為拉取請求,而不是直接推送到儲存庫。

警告

This does not support Bitbucket Cloud API.

不需要將此用於存取 Git 儲存庫,普通 Git 執行相同,唯一的區別是如何處理推送儲存庫。使用 Git 變更直接推送到儲存庫,而 :ref:`vcs-bitbucket-server`建立拉取請求。

You need to configure API credentials (BITBUCKETSERVER_CREDENTIALS) in the Weblate settings to make this work. Once configured, you will see a Bitbucket Server option when selecting 版本控制系統.

Pagure 合併請求#

在 4.3.2 版新加入.

這只是新增了一個薄層 Git 使用 Pagure API 允許將翻譯更改為合併請求,而不是直接推送到儲存庫。

不需要將此用於存取 Git 儲存庫,普通:ref:“VCS-GIT”執行相同,唯一的區別是如何處理推送儲存庫。使用:ref:“VCS-Git”更改直接推向儲存庫,而參考:ref:“VCS-PAGURE”:“VCS-PAGURE”建立合併請求。

You need to configure API credentials (PAGURE_CREDENTIALS) in the Weblate settings to make this work. Once configured, you will see a Pagure option when selecting 版本控制系統.

Gerrit#

使用 git-review 工具加入一層審查層 Git,如透過 Gerrit 審查所有推送來的翻譯變更,而不是將翻譯變更直接推送到專案倉儲。

Gerrit 文件有關於設定此類儲存庫所需的組態的詳細資訊。

Azure DevOps pull requests#

This adds a thin layer atop Git using the Azure DevOps API to allow pushing translation changes as pull requests, instead of pushing directly to the repository.

Git pushes changes directly to a repository, while Azure DevOps pull requests creates pull requests. The latter is not needed for merely accessing Git repositories.

You need to configure API credentials (AZURE_DEVOPS_CREDENTIALS) in the Weblate settings to make this work. Once configured, you will see a Azure DevOps option when selecting 版本控制系統.

Mercurial#

Mercurial是另一個您可以直接在Webleate中使用的VC。

備註

它應該與任何Mercurial版本合作,但有時對命令行界面有時不相容,可打破WebBlate集成。

也參考

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

Subversion#

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

備註

Weblate 嘗試自動檢測 Subversion 儲存庫組態 - 它支援具有標準組態的分支或儲存庫的直接網址(branches/、tags/ 和 trunk/)。有關此內容的更多資訊將在 `git-svn 文件 <https://git-scm.com/docs/git-svn#documentation/git-svn.txt—tdlayout>`_中找到。如果您的儲存庫沒有標準組態並且您遇到錯誤,請嘗試在儲存庫網址中包含分支名稱並將分支為空。

Subversion credentials#

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

Local files#

提示

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

Webleate也可以在沒有遠端VCS的情況下執行。通過上傳它們導入初始翻譯。稍後您可以通過文件上載替換單個文件,或直接從Weberate新增轉換字串(目前僅適用於單語翻譯)。

在後台,Weblate 為您建立一個 Git 儲存庫,並追蹤所有變更。如果您稍後決定使用 VCS 儲存翻譯,則您已經在 Weblate 中擁有儲存庫可以基於您的整合。