常見問題¶
配置¶
如何建立自動化工作流程?¶
Weblate 可以為您半自動處理所有翻譯工作。如果授予它對儲存庫的推送存取權限,則翻譯可以在沒有互動的情況下進行,除非發生某些合併衝突。
如何通過 SSH 存取儲存庫?¶
設定 SSH 金鑰的資訊請參閱 存取儲存庫。
如何修復翻譯中的合併衝突?¶
Merge conflicts happen from time to time when the translation file is changed in both Weblate and the upstream repository concurrently. You can usually avoid this by merging Weblate translations prior to making changes in the translation files (e.g. before running msgmerge). Just tell Weblate to commit all pending translations (you can do it in Repository maintenance in the Operations menu) and merge the repository (if automatic push is not on).
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 uses shallow clones by default to reduce cloning time and disk
usage. Because of this, the workflow below works best when you start from an
up-to-date checkout of the upstream repository. If you clone directly from
the exported Weblate repository, or if your upstream checkout is missing
recent commits, git remote update weblate can fail with errors such as
warning: no common commits, bad revision, or missing objects. This
does not necessarily mean that Weblate and the upstream repository have
conflicting changes. Administrators who want to make this workflow more
reliable can adjust VCS_CLONE_DEPTH.
備註
取決於您的設定, 存取 Weblate 儲存庫可能需要身分驗證。當使用 Weblate 中內建的 Git 匯出器 時,使用您的使用者名稱與 API 金鑰進行身分驗證。
備註
Weblate serves the Git repository itself, but it does not serve Git LFS
objects. For repositories using Git LFS, clone from the upstream repository
and add Weblate as another remote. If you only need Git-tracked files, you
can clone from Weblate with GIT_LFS_SKIP_SMUDGE=1 to skip downloading
Git LFS objects.
The workflow usually looks like this when you start from an up-to-date checkout of the upstream repository:
# Open an existing up-to-date checkout of the upstream repository or perform
# a fresh one:
git clone UPSTREAM_REPOSITORY_URL
cd REPO
# 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
# Rebase changes (if Weblate is configured to do rebases)
git rebase origin/main
# 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 支援大範圍的檔案格式(請參閱 在地化檔案格式),而最容易的方式時對每個平臺使用本地格式。
一旦在一個專案中將所有平臺的翻譯檔案作為組件新增(請參閱 新增翻譯專案和組件),就可以立刻使用翻譯傳播功能(預設開啟,並且可以在 組件配置 中關閉),來翻譯所有平臺的字串了。
也參考
如何匯出 Weblate 使用的 Git 儲存庫?¶
儲存庫沒有什麼特殊的,它存在於 DATA_DIR 目錄下面,並被命名為 vcs/<project>/<component>/。如果有 SSH 範文這臺機器,那麼可以直接使儲存庫儲。
對於匿名存取,您會想要執行 Git 伺服器,並讓它為外部世界提供儲存庫服務。
此外,可以在 Weblate 內替代使用 Git 匯出器 而使其自動化。
將變更推送回上游的選項是什麼?¶
這嚴重依賴於您的設定,Weblate 在這個領域是非常靈活的。這裡是使用 Weblate 的一些工作流程範例:
Weblate 自動推送並合併變更(請參閱 如何建立自動化工作流程?)。
您需要手動告訴 Weblate 去推送(需要上游儲存庫的推送存取)。
一些人將 Weblate git 儲存庫的變更手動合併到上游儲存庫中。
一些人重寫由 Weblate 產生的歷史(例如通過刪除合併提交),合併變更,並告訴 Weblate 重設上游儲存庫中的內容。
當然您可以按您的意願自由混用所有這些方法。
如何限制 Weblate 只存取翻譯,而不向它揭露來源嗎?¶
可以使用 git submodule 將翻譯從原始碼中分離出來,而仍將它們至於版本控制之下。
以您的翻譯檔案建立儲存庫。
將其作為子模組加入到您的程式碼中:
git submodule add git@example.com:project-translations.git path/to/translations
將 Weblate 連結到這個儲存庫上,它不再需要存取包含您原始碼的儲存庫。
可以從 Weblate 更新帶有翻譯的主儲存庫,通過:
git submodule update --remote path/to/translations
更多細節請諮詢 git submodule 文件。
如何檢查 Weblate 是否被正確地設定?¶
Weblate 包括一組配置檢查,可以在管理面板中看到,只需按照管理面板中的 Performance report 連接,或直接開啟 /manage/performance/ URL 即可。
為什麼所有提交是由 Weblate <noreply@weblate.org> 來執行?¶
Weblate uses Weblate <noreply@weblate.org> as the default committer for all
commits, which is configured by DEFAULT_COMMITER_EMAIL and
DEFAULT_COMMITER_NAME. This is a technical identifier showing that
the commit was processed through Weblate.
However, the author of each commit is correctly recorded as the individual user who made the translation (when using Git). This means you can see who actually translated each string by examining the commit author field. The same applies to Mercurial; only Subversion does not have this capability.
備註
In Git, there is a distinction between the committer (who created the commit object) and the author (who made the changes). Weblate acts as the committer while preserving individual translator attribution as authors.
For commits where authorship cannot be determined (such as automated changes
from anonymous suggestions or machine translation results), the author is set
to the anonymous user. You can configure the anonymous user's name and e-mail
in ANONYMOUS_USER_NAME.
也參考
如何在不遺失 Weblate 的歷史紀錄將檔案移至 Git 儲存庫?¶
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:
Lock the affected component in Weblate.
將未決的變更提交並合併到上游儲存庫。
Disable receiving webhooks the 專案配置; this prevents Weblate from immediately seeing changes in the repository.
Do any needed changes in the repo (for example using git mv), push them to the upstream repository.
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.
解鎖組件並重新啟用專案配置中的掛鉤。
提示
專案層級備份 might be useful to perform prior to such disrupting changes.
使用¶
如何檢閱其他人的翻譯?¶
在 Weblate 中,基於工作流程有幾種複查方式,請參閱 翻譯工作流程。
You can subscribe to any changes made in 通知 and then check others contributions as they come in by e-mail.
在翻譯檢視底部有個複查工具,可以在那裡選擇瀏覽給定時間以來其他人進行的翻譯。
也參考
如何提供來源字串的回饋?¶
在翻譯下面的文本標籤上,可以使用 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 嘗試將翻譯檔案中的變更限制為最小。對於有些檔案格式,很不幸會導致將檔案重新格式化。如果想要將檔案保持為自己的格式化方式,請為其使用預提交掛勾。
也參考
How do I merge updated POT file with PO translations?¶
See 更新目標語言檔案 for information on updating PO files when the POT template changes.
語言定義來自何處以及如何新增自己的語言定義?¶
The basic set of language definitions is included within Weblate and Translate-toolkit. This covers more than 150 languages and includes info about plural forms or text direction.
您可以在管理介面自由定義自己的語言,只需要提供與之相關的資訊。
也參考
Weblate 能將模糊字串中的變更高亮嗎?¶
Weblate 支援這個功能,然而它需要資料來顯示差異。
對於 Gettext PO 檔案,更新 PO 檔案時,必須將參數 --previous 傳遞給 msgmerge,例如:
msgmerge --previous -U po/cs.po po/phpmyadmin.pot
對於單語言翻譯,Weblate 可以通過 ID 找到之前的字串,因此可以自動顯示差異。
當已經更新了範本時,為什麼 Weblate 仍然顯示舊的字串?¶
Weblate 除了允許翻譯者翻譯之外,不會嘗試以任何方式操作翻譯檔案。因此當範本或原始碼變更時,它也同樣不會更新翻譯檔案。您必須簡單地手動去做,並將變更推送到儲存庫,然後 Weblate 會自動拾取變更。
備註
在更新翻譯檔案之前在 Weblate 中完成變更合併,這通常是個好主意,因為否則的話通常會以一些合併衝突來結束。
如何處理重新命名的翻譯檔案?¶
When renaming files in the repository, it can happen that Weblate sees this as removal and adding of the files. This can lead to losing strings history, comments and suggestions.
To avoid that, perform renaming in following steps:
在 Managing the local VCS repository 中鎖定翻譯組件。
Commit pending changes in Managing the local VCS repository.
Merge Weblate changes to the upstream repository.
Disable receiving updates via hooks using 啟用掛勾.
Perform the renaming of the files in the repository.
Update the component configuration to match new file names.
啟用更新掛勾並解鎖組件。
提示
專案層級備份 might be useful to perform prior to such disrupting changes.
疑難排解¶
請求有時失敗,錯誤資訊為“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
也參考
當存取網站時,“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. You might want to use English (Developer) as a source language, or utilize 來源字串的品質閘道.
如果是不需要用到來源語言的翻譯檔案,請從儲存庫中將它移除。
In case the translation file for the source language is needed, but should be ignored by Weblate, please adjust the 語言篩選 to exclude it.
提示
對於其它語言可能也會得到相似的錯誤資訊。在這種情況下最可能的原因是在 Weblate 中幾個文件映射到單語言上。
This can be caused by using obsolete language codes together with new one
(ja and jp for Japanese) or including both country specific and
generic codes (fr and fr_FR). See 解析語言代碼 for
more details.
功能¶
Weblate 支援 Git 和 Mercurial 之外的 VCS 嗎?¶
Weblate currently does not have native support for anything other than Git (with extended support for GitHub 拉取請求, Gerrit review requests, and Subversion) and Mercurial, but it is possible to write backends for other VCSes.
Weblate 還支援無 VCS 的操作,請參閱 本地檔案。
備註
為了本地支援其它 VCS,Weblate 需要使用分佈式 VCS,並可能能夠調整來與 Git 和 Mercurial 以外的其它任何 VCS 工作,但必須有人應用這項支援。
也參考
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 still understands legacy language codes and will map them to
current one - for example sr@latin will be handled as sr_Latn or
zh@CN as zh_Hans.
備註
Weblate defaults to POSIX style language codes with underscore, see 語言定義 for more details.