Внутреннее устройство Weblate¶
Примечание
Эта глава даст вам базовое представление о внутреннем устройстве Weblate.
Большую часть структуры своего кода Weblate наследует от Django, так как основывается на оном.
Структура каталогов¶
Быстрый обзор структуры каталогов главного репозитория Weblate:
docsИсходный код данной документации, который можно собрать с помощью Sphinx.
dev-dockerКод Docker для запуска сервера разработки, смотреть раздел Запуск Weblate локально внутри Doсker.
weblateИсходный код Weblate (точнее самого Django-приложения), смотреть раздел Внутреннее устройство Weblate.
weblate/staticКлиентские файлы (CSS, Javascript, изображения), смотреть Фронтэнд Weblate.
Модули¶
Weblate состоит из нескольких Django-приложений (некоторые из них необязательны, смотреть раздел Дополнительные модули Weblate):
accounts
Учётные записи пользователей, профили и уведомления.
addons
Надстройки для изменения поведения Weblate, смотреть раздел Надстройки.
api
API на основе Django REST framework.
auth
Авторизация и разрешения.
billing
Дополнительный модуль Выставление счетов.
checks
Модуль Проверки качества строки перевода.
fonts
Модуль проверки отрисовки шрифтов.
formats
Слой абстракции от форматов файлов на основе translate-toolkit.
gitexport
Дополнительный модуль Экспортер Git.
lang
Модуль определения языка и моделей множественного числа.
legal
Дополнительный модуль Legal module.
machinery
Интеграция сервисов машинного перевода.
memory
Встроенная память переводов, смотрите раздел Память переводов.
screenshots
Модуль управления снимками экрана и распознаванием текста.
trans
Основной модуль обработки переводов.
utils
Различные вспомогательные утилиты.
vcs
Абстракция системы контроля версий.
wladmin
Настройка интерфейса администра Django.
Background tasks internals¶
Подсказка
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:
celeryThe default queue where background tasks are processed.
notifyDelivers 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.
memoryUpdates 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.
backupThe backup tasks cannot be executed in parallel, and a single dedicated worker makes this easier.
translateAutomatic translation tasks are known to take long because they hit external services.