管理命令¶
備註
不同使用者下執行管理命令而不是一人執行您的 web 伺服器,可以導致文件得到錯誤的權限,更多細節請查看 檔案系統權限。
您會找到基本的管理命令(作為Django 源中的:file:./manage.py 來獲得它,或者作為可安裝在Weblate 頂層的腳本呼叫:command:weblate 中的擴展組來獲得它)。
Invoking management commands¶
如上面所提到的,以用相依於您如何安裝 Weblate。
如果使用 Virtualenv 來執行 Weblate,那麼您可以或者為 weblate 指定全路徑,或者在呼叫前啟動 virtualenv :
# Direct invocation
~/weblate-env/bin/weblate
# Activating virtualenv adds it to search path
. ~/weblate-env/bin/activate
weblate
如果您直接使用來源碼(來源於 tarball 或 Git checkout ),管理指令稿可以在 Weblate 來源檔的 ./manage.py
中獲得。要執行它:
python ./manage.py list_versions
If you’ve installed Weblate using the pip installer, or by using the ./setup.py
script, the weblate is installed to your path (or virtualenv path),
from where you can use it to control Weblate:
weblate list_versions
對於 Docker 映像,腳本向上面一樣安裝,您可以使用 docker exec 來運行:
docker exec --user weblate <container> weblate list_versions
For docker-compose-plugin the process is similar, you just have to use docker compose exec:
docker compose exec --user weblate weblate weblate list_versions
在您需要向它傳遞文件的情況下,您可以臨時新增卷:
docker compose exec --user weblate /tmp:/tmp weblate weblate importusers /tmp/users.json
也參考
安裝/ docker,:doc:westal / Venv-debian`,:doc:westall / Venv-suse`
add_suggestions¶
- weblate add_suggestions <project> <component> <language> <file>¶
從文件導入翻譯,來作為給定翻譯的建議來使用。它跳過了複製翻譯的步驟;只會新增不同的內容。
- --author USER@EXAMPLE.COM¶
建議的作者電子郵箱地址。這個使用者必須在導入前存在(您可以根據需要在管理界面建立一個)。
範例:
weblate --author michal@cihar.com add_suggestions weblate application cs /tmp/suggestions-cs.po
auto_translate¶
- weblate auto_translate <project> <component> <language>¶
在 4.6 版的變更: Added parameter for translation mode.
根據其他組件翻譯進行自動翻譯。
- --source PROJECT/COMPONENT¶
指定組件,用作可獲得翻譯的來源。如果不指定,將使用項目中的所有組件。
- --user USERNAME¶
指定列出的使用者名,作為翻譯的作者。如果不指定那麼使用“匿名使用者”。
- --overwrite¶
是否去覆蓋現有的翻譯。
- --add¶
如果給定的翻譯不存在,自動新增語言。
- --mt MT¶
實用機器翻譯而不是其他組件作為機器翻譯。
- --threshold THRESHOLD¶
用於機器翻譯的相似性閾值,預設為 80。
- --mode MODE¶
Specify translation mode, default is
translate
butfuzzy
orsuggest
can be used.
範例:
weblate auto_translate --user nijel --inconsistent --source weblate/application weblate website cs
也參考
celery_queues¶
- weblate celery_queues¶
顯示 Celery 任務隊列的長度。
checkgit¶
- weblate checkgit <project|project/component>¶
打印後端 Git 倉儲的目前狀態。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
commitgit¶
- weblate commitgit <project|project/component>¶
將任何可能待定的更改送交給後端 Git 倉儲。
You can either define which project or component to update (for example
weblate/application
), or use --all
to update all existing components,
or use --file-format
to filter based on the file format.
commit_pending¶
- weblate commit_pending <project|project/component>¶
送交早於給定時間段的待定更改。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
備註
這由 Weblate 在後台自動執行,所以實際不需要手動呼叫,除了要強制早於 組件組態 指定的執行。
cleanuptrans¶
- weblate cleanuptrans¶
清理無主的檢查和翻譯建議。這通常不需要手動執行,因為清理在後台自動啟動。
也參考
cleanup_ssh_keys¶
- weblate cleanup_ssh_keys¶
在 4.9.1 版被加入.
Performs cleanup of stored SSH host keys:
Removes deprecated RSA keys for GitHub which might cause issues connecting to GitHub.
Removes duplicate entries in host keys.
也參考
createadmin¶
- weblate createadmin¶
除非指定,否則用隨機密碼建立 admin
帳戶。
- --password PASSWORD¶
在命令行提供密碼,而不要產生隨機的。
- --no-password¶
不要設定密碼,這對`–update`可能有用。
- --username USERNAME¶
使用給定的姓名而不是
admin
。
- --email USER@EXAMPLE.COM¶
指定 admin 的電子郵箱地址。
- --name¶
指定 admin 的姓名(可見的)。
- --update¶
更新現有的使用者(您可以用這個來更改密碼)。
dump_memory¶
- weblate dump_memory¶
將包含 Weblate 翻譯記憶庫內容的 JSON 文件導出。
也參考
dumpuserdata¶
- weblate dumpuserdata <file.json>¶
Dumps userdata to a file for later use by importuserdata
.
提示
這在遷移或合併 Weblate 事例是會很方便。
import_demo¶
- weblate import_demo¶
在 4.1 版被加入.
依據 <https://github.com/WeblateOrg/demo> 建立一個 Demo 專案與元件。請確認 Celery 已先啟用在執行此命令前。
這在開發 Weblate 時會有用。
- --delete¶
Removes existing demo project.
import_json¶
- weblate import_json <json-file>¶
根據 JSON 資料批量導入組件。
匯入的 JSON 檔案結構非常符合組件物件(請參見 GET /api/components/(string:project)/(string:component)/
)。您必須包括 name
和 filemask
欄位。
- --project PROJECT¶
指定從哪裡導入組件。
- --main-component COMPONENT¶
對所有的使用來自這個組件的給定版本控制系統(VCS )倉儲。
- --ignore¶
跳過(已經)導入的組件。
- --update¶
更新(已經)導入的組件。
JSON 文件的例子:
[
{
"slug": "po",
"name": "Gettext PO",
"file_format": "po",
"filemask": "po/*.po",
"new_lang": "none"
},
{
"name": "Android",
"filemask": "android/values-*/strings.xml",
"template": "android/values/strings.xml",
"repo": "weblate://test/test",
"file_format": "aresource"
}
]
也參考
import_memory¶
- weblate import_memory <file>¶
將 TMX 或 JSON 文件導入 Weblate 翻譯記憶庫。
- --language-map LANGMAP¶
允許將 TMX 的語言映射到 Weblate 翻譯記憶庫。語言代碼通常在 Weblate 進行規範化之後映射。
例如
--language-map en_US:en
將所有en_US
字串作為en
字串來導入。在您的 TMX 文件地區恰好與您在Weblate使用地區不同的情況下,這會有用。
也參考
import_project¶
- weblate import_project <project> <gitrepo> <branch> <filemask>¶
Batch imports components into project based on the file mask. It is based on the 組件探索 add-on, so you might want to use that instead.
<project> 將已存在的項目命名,組件將導入其中。
<gitrepo> 確定了要使用的 Git 儲存庫的 URL,而 <branch> 說明了 Git 分支。為了從現有的 Weblate 組件導入另外的翻譯組件,使用 <gitrepo> 的 weblate://<project>/<component> URL。
<filemask> 為倉儲定義了文件發現。或者可以使用通配符來使它簡單,或者可以使用正則表達式的全部功能。
簡單的匹配對組件名稱使用 **
,對語言使用 *
,例如: **/*.po
正則表達式必須包含組命名的 component 和 language。例如: (?P<language>[^/]*)/(?P<component>[^-/]*)\.po
根據文件,導入與現有的組件匹配,並且新增不存在的那些。它不更改已經存在的那些。
- --name-template TEMPLATE¶
使用 Django 模板語法來客製組件的名稱。
例如:
Documentation: {{ component }}
- --base-file-template TEMPLATE¶
為單語言翻譯客製譯文模板文件。
例如:
{{ component }}/res/values/string.xml
- --new-base-template TEMPLATE¶
為另外新的翻譯客製譯文模板文件。
例如:
{{ component }}/ts/en.ts
- --main-component¶
您可以指定選擇哪個組件作為主要的一個——即真正包含版本控制系統(VCS )倉儲的那個。
- --license NAME¶
指定整體、項目或組件翻譯的許可。
- --license-url URL¶
指定翻譯許可所在的 URL。
- --vcs NAME¶
在需要指定使用哪個版本的輕質系統的情況下,您可以在這裡進行。預設版本控制是 Git。
為了給出一些例子,讓我們導入兩個項目。
第一個是 Debian 手冊翻譯,那裡的每種語言都有各自的文件夾,裡面有 每個章節的翻譯:
weblate import_project \
debian-handbook \
git://anonscm.debian.org/debian-handbook/debian-handbook.git \
squeeze/master \
'*/**.po'
然後 Tangaguru 工具,那裡需要指定文件格式和譯文模板文件,並且指定所有組件和翻譯如何位於單一一個文件夾中:
weblate import_project \
--file-format=properties \
--base-file-template=web-app/tgol-web-app/src/main/resources/i18n/%s-I18N.properties \
tanaguru \
https://github.com/Tanaguru/Tanaguru \
master \
web-app/tgol-web-app/src/main/resources/i18n/**-I18N_*.properties
更複雜的例子是關於解析文件名而從文件名中得到正確的組件和語言,像 src/security/Numerous_security_holes_in_0.10.1.de.po
:
weblate import_project \
tails \
git://git.tails.boum.org/tails master \
'wiki/src/security/(?P<component>.*)\.(?P<language>[^.]*)\.po$'
篩選出指定的語言的翻譯:
./manage import_project \
--language-regex '^(cs|sk)$' \
weblate \
https://github.com/WeblateOrg/weblate.git \
'weblate/locale/*/LC_MESSAGES/**.po'
導入 Sphinx 文件,分成多個文件:
$ weblate import_project --name-template 'Documentation: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/**.po'
導入 Sphinx 文件,分成多個文件和文件夾:
$ weblate import_project --name-template 'Directory 1: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/dir1/**.po'
$ weblate import_project --name-template 'Directory 2: %s' \
--file-format po \
project https://github.com/project/docs.git master \
'docs/locale/*/LC_MESSAGES/dir2/**.po'
也參考
More detailed examples can be found in the 通過國際化來開始 chapter,
alternatively you might want to use import_json
.
importuserdata¶
- weblate importuserdata <file.json>¶
Imports user data from a file created by dumpuserdata
.
importusers¶
- weblate importusers --check <file.json>¶
從 Django auth_users 資料庫的 JSON 轉儲中導入使用者。
- --check¶
使用這個選項可以檢查給定文件是否可以被導入,並且報告使用者名或電子郵箱地址可能導致的衝突。
可以從現有的 Django 安裝中導出使用者,這需要使用:
weblate dumpdata auth.User > users.json
install_addon¶
- weblate install_addon --addon ADDON <project|project/component>¶
將附加元件安裝到一組元件中。
- --addon ADDON¶
要安裝的附加元件名稱。例如
weblate.gettext.customize
。
- --configuration CONFIG¶
JSON encoded configuration of an add-on.
- --update¶
Update the existing add-on configuration.
可以或者定義將附加元件安裝到哪個項目或元件中(例如 weblate/application
),或者使用 --all
來包括所有現有的元件。
為所有的組件安裝 自訂 gettext 輸出 :
weblate install_addon --addon weblate.gettext.customize --configuration '{"width": -1}' --update --all
也參考
install_machinery¶
在 4.18 版被加入.
- weblate install_machinery --service SERVICE¶
Installs an site-wide automatic suggestion service.
- --service SERVICE¶
Name of the service to install. For example
deepl
.
- --configuration CONFIG¶
JSON encoded configuration of a service.
- --update¶
Update the existing service configuration.
To install DeepL:
weblate install_service --service deepl --configuration '{"key": "x", "url": "https://api.deepl.com/v2/"}' --update
也參考
list_languages¶
- weblate list_languages <locale>¶
列出 MediaWiki 標註中支援的語言——語言碼、英語名稱和在地化名稱。
這用來產生 <https://wiki.l10n.cz/Slovn%C3%ADk_s_n%C3%A1zvy_jazyk%C5%AF>.
list_translators¶
- weblate list_translators <project|project/component>¶
對給定的項目列出為這種語言做出貢獻的譯者:
[French]
Jean Dupont <jean.dupont@example.com>
[English]
John Doe <jd@example.com>
- --language-code¶
用語言代碼而不是語言來列出名稱。
可以或者定義使用哪個項目或組件(例如 weblate/application
),或者使用 --all
從所有現存的組件中列出翻譯者。
list_versions¶
- weblate list_versions¶
列出所有 Weblate 相依及其版本。
loadpo¶
- weblate loadpo <project|project/component>¶
從磁碟重新載入翻譯(例如您在版本控制系統(VCS )儲存庫完成一些更新的情況下)。
- --force¶
強制更新,即使文件應該是更新的。
- --lang LANGUAGE¶
將處理限制為單一語言。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
備註
極少呼叫這個,Weblate 將對每一次版本控制系統(VCS )更新自動載入更改的文件。在您手動更改下層 Weblate 版本控制系統(VCS )倉儲的情況下,或在更新後的一些特殊情況下才需要這個。
lock_translation¶
- weblate lock_translation <project|project/component>¶
防止進一步翻譯組件。
提示
在您想要對下層倉儲進行一些維護時有用。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
migrate¶
- weblate migrate¶
Migrates database to current Weblate schema. The command line options are
described at Django migrate
.
提示
In case you want to run an installation non interactively, you can use
weblate migrate --noinput
, and then create an admin user using
createadmin
command.
move_language¶
- weblate move_language source target¶
允許您合併語言內容。當更新到新版本,這個新版本對使用 (generated) 前綴建立的之前未知的語言包含別名時,這會有用。它將所有內容從 source 語言移動到 target 語言。
範例:
weblate move_language cze cs
移動內容後,您應該檢查是否有什麼落下了(這是因為有人在同時更新倉儲而導致的競爭情況),並且要刪除 (generated) 語言。
pushgit¶
- weblate pushgit <project|project/component>¶
將執行的更改推送到上游版本控制系統(VCS )倉儲。
- --force-commit¶
在推送前,強制執行任何待定的更改。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
備註
如果開啟了 組件組態 中的:ref:component-push_on_commit,Weblate 會自動推送更改,這是預設的。
unlock_translation¶
- weblate unlock_translation <project|project/component>¶
將給定的組件解鎖,使它能夠被翻譯。
提示
在您想要對下層倉儲進行一些維護時有用。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
也參考
setupgroups¶
- weblate setupgroups¶
組態預設的組,並可選地將所有使用者指定到那個預設群組中。
- --no-privs-update¶
關閉對現有組的自動更新(只新增新的)。
也參考
setuplang¶
- weblate setuplang¶
將 Weblate 中的確定語言的列表更新。
- --no-update¶
關閉現有語言的自動更新(只新增新的)。
updatechecks¶
- weblate updatechecks <project|project/component>¶
對所有字串更新所有檢查。
提示
對檢查進行主要更改的更新是有用的。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。
備註
Checks are recalculated regularly by Weblate in the background, the frequency
can be configured via BACKGROUND_TASKS
.
updategit¶
- weblate updategit <project|project/component>¶
取回遠端版本控制系統(VCS )倉儲並更新內部快取。
您可以確定或者哪個項目或組件要更新(例如 weblate/application
),或者使用 --all
來更新所有現有組件。