常見問題

配置

如何創建自動化工作流?

Weblate 可以為您半自動處理所有翻譯工作。如果授予它對倉庫的推送訪問權限,則翻譯可以在沒有交互的情況下進行,除非發生某些合併衝突。

  1. 新建您的 Git 倉庫,來告知 Weblate 何時有任何更改,請參閱 通知掛勾 以獲取有關如何執行此操作的信息。

  2. 在 Weblate 中的 組件配置 配置中設置推送 URL,這使 Weblate 可以將更改推送到倉庫。

  3. 在 Weblate 中打開 compoent`上的 :ref:`component-push_on_commit,這將使 Weblate 在 Weblate 發生更改時將更改推送到倉庫。

如何通過 SSH 訪問倉庫?

設置 SSH 密鑰的信息請參閱 Accessing repositories

如何修復翻譯中的合併衝突?

在翻譯文件在 Weblate 和上游倉庫同時更改時,合併衝突不時發生。通常可以通過在對翻譯文件進行更改前(例如在運行 msgmerge 前)合併倉庫來避免發生這個情況。只要告訴 Weblate 執行掛起所有的翻譯(可以在 Manage 菜單中的 Repository maintenance 中去做),並合併倉庫即可(如果自動推送沒有打開的話)。

If you’ve already encountered a merge conflict, the easiest way to solve all conflicts locally on your machine, is to add Weblate as a remote repository, merge it into upstream and fix any conflicts. Once you push changes back, Weblate will be able to use the merged version without any other special actions.

備註

取決於你的設置, 訪問 Weblate 代碼庫可能需要身份驗證。使用 Weblate 中內建的 :ref:`git-exporter`時,你使用用戶名和 API 密鑰進行身份驗證。

# Commit all pending changes in Weblate, you can do this in the UI as well:
wlc commit
# Lock the translation in Weblate, again this can be done in the UI as well:
wlc lock
# Add Weblate as remote:
git remote add weblate https://hosted.weblate.org/git/project/component/
# You might need to include credentials in some cases:
git remote add weblate https://username:APIKEY@hosted.weblate.org/git/project/component/

# Update weblate remote:
git remote update weblate

# Merge Weblate changes:
git merge weblate/main

# Resolve conflicts:
edit …
git add …
…
git commit

# Push changes to upstream repository, Weblate will fetch merge from there:
git push

# Open Weblate for translation:
wlc unlock

如果在 Weblate 中使用多個分支,那麼可以對所有的分支做相同的事:

# Add and update Weblate remotes
git remote add weblate-one https://hosted.weblate.org/git/project/one/
git remote add weblate-second https://hosted.weblate.org/git/project/second/
git remote update weblate-one weblate-second

# Merge QA_4_7 branch:
git checkout QA_4_7
git merge weblate-one/QA_4_7
... # Resolve conflicts
git commit

# Merge main branch:
git checkout main
git merge weblates-second/main
... # Resolve conflicts
git commit

# Push changes to the upstream repository, Weblate will fetch the merge from there:
git push

在 gettext PO 文件的情況下,有一種方式以半自動方式來合併衝突:

取回並保存 Weblate Git 倉庫的本地克隆。還要得到上游 Git 倉庫的第二個新的本地克隆(也就是需要上游 Git 倉庫的兩份複件:完整的複件和工作複件):

# Add remote:
git remote add weblate /path/to/weblate/snapshot/

# Update Weblate remote:
git remote update weblate

# Merge Weblate changes:
git merge weblate/main

# Resolve conflicts in the PO files:
for PO in `find . -name '*.po'` ; do
    msgcat --use-first /path/to/weblate/snapshot/$PO\
               /path/to/upstream/snapshot/$PO -o $PO.merge
    msgmerge --previous --lang=${PO%.po} $PO.merge domain.pot -o $PO
    rm $PO.merge
    git add $PO
done
git commit

# Push changes to the upstream repository, Weblate will fetch merge from there:
git push

如何立刻翻譯幾個分支?

Weblate 支持在一個 項目配置 內推送翻譯更改。對於每個將其打開的 組件配置 (默認行為),所作的更改自動傳遞給其它組件。即使分支本身已經非常多樣化了,也能以這種方式保持同步,並且不能在他們之間簡單地合併翻譯更改。

一旦從 Weblate 合併了更改,就會不得不合併這些分支(依賴於您的開發工作流程),而丟棄差異:

git merge -s ours origin/maintenance

如何翻譯多平台項目?

Weblate 支持大範圍的文件格式(請參見 支持的文件格式),而最容易的方式時對每個平台使用本地格式。

一旦在一個項目中將所有平台的翻譯文件作為組件添加(請參見:ref:adding-projects),就可以立刻使用翻譯傳播特性(默認打開,並且可以在:ref:component 中關閉),來翻譯所有平台的字符串了。

如何導出 Weblate 使用的 Git 倉庫?

倉庫沒有什麼特殊的,它存在於 DATA_DIR 目錄下面,並被命名為 vcs/<project>/<component>/。如果有 SSH 範文這台機器,那麼可以直接使用倉庫。

對於匿名訪問,您會想要運行 Git 服務器,並讓它為外部世界提供倉庫服務。

此外,可以在 Weblate 內替代使用 Git 導出器 而使其自動化。

將更改推送回上游的選項是什麼?

這嚴重依賴於您的設置,Weblate 在這個領域是非常靈活的。這裡是使用 Weblate 的一些工作流程的例子:

  • Weblate 自動推送並合併更改(請參見 如何創建自動化工作流?)。

  • 您需要手動告訴 Weblate 去推送(推送需要訪問上游倉庫)。

  • 一些人將 Weblate git 倉庫的更改手動合併到上游倉庫中。

  • 一些人重寫由 Weblate 生成的歷史(例如通過刪除合併提交),合併更改,並告訴 Weblate 重置上游倉庫中的內容。

當然您可以按您的意願自由混用所有這些方法。

如何限制 Weblate 只訪問翻譯,而不向它暴露源代碼?

可以使用 git submodule 將翻譯從源代碼中分離出來,而仍將它們至於版本控制之下。

  1. 以您的文藝文件創建倉庫。

  2. 將其作為子模塊添加到您的代碼中:

    git submodule add git@example.com:project-translations.git path/to/translations
    
  3. 將 Weblate 連接到這個倉庫上,它不再需要訪問包含您源代碼的倉庫。

  4. 可以從 Weblate 更新帶有翻譯的主倉庫,通過:

    git submodule update --remote path/to/translations
    

更多細節請諮詢 git submodule 文檔。

如何檢查 Weblate 是否被正確地設置?

Weblate 包括一組配置檢查,可以在管理面板中看到,只需按照管理面板中的 Performance report 連接,或直接打開 /manage/performance/ URL 即可。

為什麼所有提價由 Weblate <noreply@weblate.org> 執行?

This is the default committer name, configured by DEFAULT_COMMITER_EMAIL and DEFAULT_COMMITER_NAME.

(如果下層的版本管理系統 VCS 支持它的話),每個提交的作者仍會被正確地記錄為進行翻譯的用戶。

For commits where no authorship is known (for example anonymous suggestions or machine translation results), the authorship is credited to the anonymous user (see ANONYMOUS_USER_NAME). You can change the name and e-mail in the management interface.

也參考

組件配置

How to move files in the repository without losing history in Weblate?

To keep the history, comments, or screenshots linked to strings after changing the files location you need to ensure that these strings are never deleted in Weblate. These removals can happen in case the Weblate repository is updated, but the component configuration still points to the old files. This makes Weblate assume that it should delete all the translations.

The solution to this is to perform the operation in sync with Weblate:

  1. Lock the affected component in Weblate.

  2. Commit any pending changes and merge them into the upstream repository.

  3. Disable receiving webhooks the 項目配置; this prevents Weblate from immediately seeing changes in the repository.

  4. Do any needed changes in the repo (for example using git mv), push them to the upstream repository.

  5. Change the 組件配置 to match the new setup; upon changing configuration, Weblate will fetch the updated repository and notice the changed locations while keeping existing strings.

  6. Unlock the component and re-enable hooks in the project configuration.

Usage

如何復查其他人的翻譯?

  • 在 Weblate 中,基於工作流程有幾種複查方式,請參見 翻譯工作流

  • 可以訂閱 通知 中做出的任何更改,然後檢查當它們通過電子郵件進入時檢查其他人的貢獻。

  • 在翻譯視圖底部有個複查工具,可以在那裡選擇瀏覽給定時間以來其他人進行的翻譯。

也參考

翻譯工作流

如何提供源字符串的反饋?

在翻譯下面的文本標籤上,可以使用 Comments 標籤來提供源字符串的反饋,或者與其他翻譯者討論。

翻譯時如何使用現有的翻譯?

  • All translations within Weblate can be used thanks to shared translation memory.

  • You can import existing translation memory files into Weblate.

  • 使用導入功能將概要導入作為翻譯、建議或需要復查的翻譯。這是使用概要或相似的翻譯數據庫一次性翻譯的最好方法。

  • You can set up tmserver with all databases you have and let Weblate use it. This is good when you want to use it several times during translation.

  • 另一個選項是在單一 Weblate 事件中翻譯所有相關項目,這樣同樣可以從其它項目中自動地拾取翻譯。

Weblate 除了更新翻譯,還更新翻譯文件嗎?

Weblate 嘗試將翻譯文件中的更改限制為最小。對於有些文件格式,很不幸會導致將文件重新格式化。如果想要將文件保持為自己的格式化方式,請為其使用預提交鉤子。

語言定義來自何處以及如何添加自己的語言定義?

語言定義的基本組包括在 Weblate 和 Translate-toolkit 中。這覆蓋了超過 150 種語言,並且包括了複數形式和文本方向的信息。

您可以在管理界面自由定義自己的語言,只需要提供與之相關的信息。

也參考

語言定義

Weblate 能將模糊字符串中的更改高亮嗎?

Weblate 支持這個功能,然而它需要數據來顯示差異。

對於 Gettext PO 文件,更新 PO 文件時,必須將參數 --previous 傳遞給 msgmerge,例如:

msgmerge --previous -U po/cs.po po/phpmyadmin.pot

對於單語言翻譯,Weblate 可以通過 ID 找到之前的字符串,因此可以自動顯示差異。

當已經更新了模板時,為什麼 Weblate 仍然顯示舊的字符串?

Weblate 除了允許翻譯者翻譯之外,不會嘗試以任何方式操作翻譯文件。因此當模板或源代碼更改時,它也同樣不會更新翻譯文件。您必須簡單地手動去做,並將更改推送到倉庫,然後 Weblate 會自動拾取更改。

備註

在更新翻譯文件之前在 Weblate 中完成更改合併,這通常是個好主意,因為否則的話通常會以一些合併衝突來結束。

例如對於 gettext PO 文件,可以使用 msgmerge 工具來更新翻譯文件:

msgmerge -U locale/cs/LC_MESSAGES/django.mo locale/django.pot

In case you want to do the update automatically, you can install add-on 更新 PO 檔以符合 POT (msgmerge).

Troubleshooting

請求有時失敗,錯誤信息為“too many open files”(打開文件過多)

有時當您的 Git 倉庫增長太多並您有太多倉庫時會發生。壓縮 Git 倉庫會改善這種情況。

這樣做的最容易方式是運行:

# Go to DATA_DIR directory
cd data/vcs
# Compress all Git repositories
for d in */* ; do
    pushd $d
    git gc
    popd
done

也參考

DATA_DIR

當訪問網站時,“Bad Request (400)”(錯誤的請求)錯誤信息

這很可能因為 ALLOWED_HOSTS 配置不當而產生。需要包含在 Weblate 上訪問的所有主機名。例如:

ALLOWED_HOSTS = ["weblate.example.com", "weblate", "localhost"]

“There are more files for the single language (en)”(單一語言‘英語’有多個文件)是什麼意思?

當源語言有翻譯時這會典型發生。 Weblate 跟踪源字符串,並為此保留源字符串。相同語言的附加字符串不會被處理。

  • In case the translation to the source language is desired, please change the 來源語言 in the component settings.

  • 如果是不需要用到來源語言的翻譯檔,請從儲存庫中將它移除。

  • In case the translation file for the source language is needed, but should be ignored by Weblate, please adjust the 語言篩選 to exclude it.

提示

對於其它語言可能也會得到相似的錯誤信息。在這種情況下最可能的原因是在 Weblate 中幾個文件映射到單語言上。

這可能是由於將過時的語言編碼與新的一起使用(對於日語是``ja``和``jp``),或者包括了特定國家的和通用的語言編碼(fr``和` `fr_FR)。更多細節請參見 Parsing language codes

功能

Weblate 支持 Git 和 Mercurial 意外的 VCS 嗎?

Weblate 當前不支持:ref:vcs-git (擴展支持:ref:vcs-githubGerrit 和:ref:vcs-git-svn)和:ref:vcs -mercurial 以外的任何VCSes,但能夠對其它VCSes 寫後端。

還可以在 Git 中使用 Git remote helpers 來訪問其它 VCSes。

Weblate 還支持無 VCS 的操作,請參見 Local files

備註

為了本地支持其它 VCSes,Weblate 需要使用分佈式 VCS,並可能能夠調整來與 Git 和 Mercurial 以外的其它任何 VCSes 工作,但必須有人應用這項支持。

也參考

版本控制整合

Weblate 如何記錄翻譯者?

Weblate 中所做的每個更改都將以翻譯者的名稱提交到版本控制系統(VCS )中。這樣,每個更改都具有適當的作者身份,您可以使用用於代碼的標準版本控制系統(VCS )工具來進行跟踪。

此外,如果翻譯文件格式支持,則文件頭會更新為包含翻譯者的名稱。

為什麼 Weblate 強制在單一樹中顯示所有 PO 文件?

Weblate 的設計方式是將每個 PO 文件表示為單個組件。這對翻譯人員來說是有好處的,這樣他們就知道他們實際上在翻譯什麼。

在 4.2 版本變更: Translators can translate all the components of a project into a specific language as a whole.

Weblate 為什麼使用 sr_Latn 或 zh_Hant 這樣的語言編碼?

These are language codes defined by RFC 5646 to better indicate that they are really different languages instead previously wrongly used modifiers (for @latin variants) or country codes (for Chinese).

Weblate 仍然理解傳統的語言編碼並將它們映射到當前的便馬上——例如``sr@latin`` 將被處理為``sr_Latn`` 或者``zh@CN`` 處理為``zh_Hans``。

備註

Weblate defaults to POSIX style language codes with underscore, see 語言定義 for more details.