ພາຍໃນ Weblate (Internals)¶
Note
ບົດນີ້ຈະໃຫ້ພາບລວມພື້ນຖານກ່ຽວກັບໂຄງສ້າງພາຍໃນຂອງ Weblate.
Weblate ໄດ້ຮັບໂຄງສ້າງລະຫັດສ່ວນໃຫຍ່ມາຈາກ, ແລະ ສ້າງຂຶ້ນບົນພື້ນຖານຂອງ Django.
ໂຄງສ້າງໄດເຣັກທໍຣີ¶
ພາບລວມດ່ວນຂອງໂຄງສ້າງໄດເຣັກທໍຣີຂອງ Repository ຫຼັກຂອງ Weblate:
docsSource code ສຳລັບເອກະສານນີ້, ເຊິ່ງສາມາດສ້າງໄດ້ໂດຍໃຊ້ Sphinx.
dev-dockerລະຫັດ Docker ສຳລັບຮັນເຊີບເວີການພັດທະນາ, ເບິ່ງ ການຮັນ Weblate ໃນເຄື່ອງຂອງທ່ານໂດຍໃຊ້ Docker.
weblateSource code ຂອງ Weblate ໃນຖານະແອັບພລິເຄຊັນ Django, ເບິ່ງ ພາຍໃນ Weblate (Internals).
weblate/staticໄຟລ໌ Client (CSS, Javascript ແລະ ຮູບພາບ), ເບິ່ງ Weblate frontend.
ໂມດູນ¶
Weblate ປະກອບດ້ວຍແອັບພລິເຄຊັນ Django ຫຼາຍອັນ (ບາງອັນເປັນທາງເລືອກ, ເບິ່ງ ໂມດູນ Weblate ເພີ່ມເຕີມ):
accounts
ບັນຊີຜູ້ໃຊ້, ໂປຣໄຟລ໌ ແລະ ການແຈ້ງເຕືອນ.
addons
Add-ons ເພື່ອປັບແຕ່ງພຶດຕິກຳຂອງ Weblate, ເບິ່ງ ສ່ວນເສີມ.
api
API ທີ່ອີງໃສ່ Django REST framework.
auth
ການຢືນຢັນຕົວຕົນ ແລະ ການອະນຸຍາດ.
billing
ໂມດູນ ການຮຽກເກັບເງິນ ເປັນທາງເລືອກ.
checks
ໂມດູນການກວດສອບ (checks) ຂໍ້ຄວາມການແປ ການກວດສອບຄຸນນະພາບ.
fonts
ໂມດູນກວດສອບການສະແດງຜົນຕົວອັກສອນ.
formats
ຊັ້ນນາມມະທຳ (abstraction layer) ຮູບແບບໄຟລ໌ ທີ່ອີງໃສ່ translate-toolkit.
gitexport
ໂມດູນ Git exporter ເປັນທາງເລືອກ.
lang
ໂມດູນທີ່ກຳນົດຮູບແບບພາສາ ແລະ ພົດພົດ (plural models).
legal
ໂມດູນ ໂມດູນທາງກົດໝາຍ ເປັນທາງເລືອກ.
machinery
ການເຊື່ອມໂຍງບໍລິການແປພາສາດ້ວຍເຄື່ອງຈັກ.
memory
ໜ່ວຍຄວາມຈຳການແປ (translation memory) ທີ່ຕິດມາພ້ອມ, ເບິ່ງ ໜ່ວຍຄວາມຈຳການແປ.
screenshots
ໂມດູນການຈັດການພາບໜ້າຈໍ ແລະ OCR.
trans
ໂມດູນຫຼັກທີ່ຈັດການການແປພາສາ.
utils
ເຄື່ອງມືຊ່ວຍເຫຼືອຕ່າງໆ.
vcs
ການເຮັດນາມມະທຳລະບົບຄວບຄຸມເວີຊັນ.
wladmin
ການປັບແຕ່ງອິນເຕີເຟສຜູ້ເບິ່ງແລລະບົບ (Admin interface) ຂອງ Django.
Translation sources¶
A unit has a canonical file source and may have a translation from another
language as its effective source. Keep Unit.source and Unit.source_unit
canonical: repository synchronization and file formats depend on this. Use
effective_source and its language and plural accessors for content shown to
translators. Do not replace source on a copied unit to simulate an effective
source; other fields and related objects still describe the canonical source.
Use Unit.source_snapshot when an operation needs to preserve the source text,
language, plural rules, and terminology metadata together. Its identity defines source changes for
dependency reconciliation, editor conflict detection, and AI diagnostics. For
historical rendering and reports, read the snapshot recorded on the change,
rather than reconstructing it from the current unit.
A missing configured parent remains a custom source: its text is empty, its
language is retained, and its child is blocked. effective_source_unit is
then None. Only removing the workflow or selecting the canonical language
restores the canonical source.
Text-only accessors do not load language or plural metadata. For batch consumers
that need the complete effective source, use
UnitQuerySet.prefetch_translation_parent() alongside their existing unit
prefetches. prefetch_source() already includes this. Ordinary searches keep
the canonical query path and ordinary units retain their existing content hashes.
Source-dependent writes enter source_operation() before locking unit rows.
The outer operation takes a shared project gate and reads its workflow mapping
in one database round trip, including for projects without custom workflows.
Workflow changes take source_project_gate(..., exclusive=True) before
validation or persistence. Configuration changes affecting several projects
acquire their gates in ascending project ID order. Never upgrade a shared gate
to an exclusive one inside an operation.
The database gate function locks first and reads workflows in a separate statement, so a waiter sees configuration committed while it waited. Write paths use this transaction-scoped view rather than cached model settings. Nested operations reuse it; rolled-back savepoints discard their dependency work. Queued dependencies are reconciled before commit and external memory updates are scheduled after commit. Source-change history is written in bulk, preserving individual records while batching their notification dispatch.
Acquire any required repository locks before project gates, then component and unit row locks. Reconciliation itself only changes database state and does not acquire repository locks. Apply this boundary to bulk imports, automatic translation, file-save failures, deletion, and restoration as well as editor writes. Language and plural-rule changes require exclusive gates before their updates. Historical migrations use historical models without these runtime helpers.
Machinery source selection happens before mapping language codes to a provider.
Use get_unit_source_language() for translation and uses_custom_source()
for workflow-specific glossary handling. Provider codes can merge distinct
language variants, so code equality cannot determine whether a workflow source
was selected. Explicit component or secondary source selection takes precedence
over the workflow source.
ໂຄງສ້າງພາຍໃນຂອງວຽກເບື້ອງຫຼັງ¶
Hint
ພາກສ່ວນນີ້ອະທິບາຍໂຄງສ້າງພາຍໃນຂອງວຽກ Celery. ວຽກງານເບື້ອງຫຼັງໂດຍໃຊ້ Celery ອະທິບາຍວິທີການຕັ້ງຄ່າ Celery ເພື່ອຮັນວຽກເຫຼົ່ານັ້ນ.
Weblate ໃຊ້ Celery ເພື່ອປະມວນຜົນວຽກຢູ່ເບື້ອງຫຼັງ. ບາງວຽກຖືກກະຕຸ້ນດ້ວຍເຫດການ (event-triggered), ແລະ ບາງວຽກຖືກກະຕຸ້ນຕາມຕາຕະລາງ (schedule-triggered).
Celery Beat ຖືກໃຊ້ສຳລັບການກຳນົດຕາຕະລາງວຽກ, ແລະ django-celery-beat ຖືກໃຊ້ເພື່ອເກັບຕາຕະລາງວຽກທີ່ເກີດຂຶ້ນຊ້ຳໆ ໄວ້ໃນຖານຂໍ້ມູນ. ຕາຕະລາງວຽກຈະຖືກຕັ້ງຄ່າໃນ tasks.py ໃນແຕ່ລະແອັບ Django.
ວຽກຕ່າງໆຈະຖືກບໍລິໂພກໂດຍໃຊ້ຫຼາຍຄິວ; ການ routing ຖືກຕັ້ງຄ່າໄວ້ໃນ settings.py. ຄິວເຫຼົ່ານີ້ຖືກອອກແບບມາເພື່ອແຍກປະເພດວຽກທີ່ແຕກຕ່າງກັນ:
celeryຄິວເລີ່ມຕົ້ນ (Default queue) ບ່ອນທີ່ວຽກເບື້ອງຫຼັງຖືກປະມວນຜົນ.
notifyສົ່ງອີເມວການແຈ້ງເຕືອນ, ທັງສຳລັບເຫດການພາຍໃນ Weblate ແລະ ສຳລັບການຢືນຢັນຕົວຕົນ ຫຼື ການລົງທະບຽນ. ນີ້ແມ່ນຄິວແຍກຕ່າງຫາກເພື່ອເຮັດໃຫ້ການສົ່ງອີເມວເປັນໄປຢ່າງລາບລື່ນເຖິງແມ່ນວ່າຈະມີວຽກອື່ນຄ້າງຢູ່ຫຼາຍກໍຕາມ.
memoryອັບເດດລາຍການໃນໜ່ວຍຄວາມຈຳການແປ. ຄິວການອັບເດດອາດຈະຍາວເມື່ອນຳເຂົ້າຂໍ້ຄວາມໃໝ່ໆ, ແລະ ການປະມວນຜົນທີ່ຍາວນານກໍບໍ່ແມ່ນບັນຫາໃຫຍ່ໃນຈຸດນີ້, ສະນັ້ນການມີຄິວແຍກຕ່າງຫາກຈະຊ່ວຍບໍ່ໃຫ້ວຽກອື່ນໆຖືກຂັດຂວາງ.
backupວຽກສຳຮອງ (Backup) ບໍ່ສາມາດດຳເນີນການແບບຂະໜານກັນໄດ້, ແລະ Worker ທີ່ອຸທິດຕົນອັນດຽວຈະເຮັດໃຫ້ເລື່ອງນີ້ງ່າຍຂຶ້ນ.
translateວຽກການແປພາສາອັດຕະໂນມັດມັກຈະໃຊ້ເວລາດົນ ເພາະມັນຕ້ອງຕິດຕໍ່ກັບບໍລິການພາຍນອກ.