Kind: Class
Source: atloria-monorepo/apps/api/src/l10n/translate.worker.ts
TranslateWorker — consumer of the 'l10n-translate' queue (B6).
One job = one (document, targetLanguage) variant: build the directive-preserving prompt (with the project glossary), call the doc-automation AI provider (AZURE_GPT52_PROVIDER — the same gpt-5.6-terra deployment the generation pipeline uses), then ENFORCE the contract: the result only auto-publishes when every protected segment (directives, code fences) survived verbatim. A violating result is saved as a DRAFT for human review — a broken page must never reach readers on the say-so of a model.
Kill-switch: L10N_TRANSLATE_WORKER === 'false' disables processing (enqueue-only pods). Default ON — translate jobs are independent per variant and idempotent (upsert), so concurrent processing across api replicas is safe.
Implements: OnModuleInit, OnModuleDestroy
Methods
| Method | Signature | Returns |
|---|---|---|
onModuleInit | onModuleInit() | void |
process | `process(job: Job | { data: TranslateJob })` |
outcome: 'published' | 'draft-needs-review' | 'skipped'; reason?: string;
}>| |onModuleDestroy|onModuleDestroy()|Promise
Where it refuses work
TranslateWorkerstops the work withErrorwhen!this.aiProvider— “AI provider unavailable (AZURE_GPT52_PROVIDER not configured)”.TranslateWorkerstops the work withErrorwhen!parsed.content.trim()— “model returned empty translation”.TranslateWorkerstops the work with an early return when!pair.source.content?.trim().TranslateWorkerstops the work with an early return whenpair.source.language === language.TranslateWorkerstops the work with an early return whenpair.variant && !pair.variant.machineTranslated.
Referenced By
L10nModule(MODULE_PROVIDES)
Was this page helpful?