Weblate 內部

備註

這一章將給出 Weblate 內部的基本概覽。

Weblate 從 Django 得到其多數代碼架構,並基於它。

目錄結構

Weblate 主儲存庫目錄結構的快速概覽:

docs

本文件的原始碼,可使用 Sphinx 來建置。

dev-docker

執行開發伺服器的 Docker 代碼,請參閱 在 Docker 中本地執行 Weblate

weblate

Weblate 的原始碼作為 Django 應用程式,請參閱 Weblate 內部

weblate/static

用戶端文件(CSS、Javascript 和圖片),請參閱 Weblate 前端

模組

Weblate 包括幾個 Django 應用(一些是可選的,請參閱 可選 Weblate 模組):

accounts

使用者帳號、簡介和通知。

addons

微調 Weblate 行為的附加元件,請參閱 附加元件

api

基於 Django REST framework 的 API。

auth

認證和權限。

billing

可選的 帳單 模組。

checks

翻譯字串 品質檢查 模組。

fonts

字型提供檢查模組。

formats

基於 translate-toolkit 的檔案格式抽象層。

gitexport

可選的 Git 匯出器 模組。

lang

定義語言和複數模型的模組。

legal

可選的 法律模組 模組。

machinery

機器翻譯服務的整合。

memory

內建翻譯記憶,請參閱 翻譯記憶

screenshots

螢幕擷圖管理與 OCR 模組。

trans

處理翻譯的主模組。

utils

各種幫助功能。

vcs

版本控制系統抽象概念。

wladmin

Django 管理介面客製化。

背景工作內部

提示

This section describes Celery task internals. 使用 Celery 的背景工作 describes how to configure Celery to run the tasks.

Weblate uses Celery to execute tasks in the background. Some tasks are event-triggered, and some tasks are schedule-triggered.

The Celery Beat is used for scheduling tasks, and django-celery-beat is used to store the periodic task schedule in the database. The tasks schedule is configured in tasks.py in each of the Django apps.

The tasks are consumed using several queues; the routing is configured in settings.py. The queues were designed to separate different types of workload:

celery

The default queue where background tasks are processed.

notify

Delivers notification e-mails, both for events within Weblate and for authentication or registration. This is a separate queue to make e-mail delivery smooth even if there is a backlog of other tasks.

memory

Updates translation memory entries. The updating queue can be long when importing new strings, and long processing does not matter much here, so having a separate queue avoids blocking other tasks.

backup

The backup tasks cannot be executed in parallel, and a single dedicated worker makes this easier.

translate

Automatic translation tasks are known to take long because they hit external services.