Skip to content

TranslateWorker

reference
1 min readUpdated

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

MethodSignatureReturns
onModuleInitonModuleInit()void
process`process(job: Job{ data: TranslateJob })`
outcome: 'published' | 'draft-needs-review' | 'skipped';
reason?: string;

}>| |onModuleDestroy|onModuleDestroy()|Promise` |

Where it refuses work

  • TranslateWorker stops the work with Error when !this.aiProvider — “AI provider unavailable (AZURE_GPT52_PROVIDER not configured)”.
  • TranslateWorker stops the work with Error when !parsed.content.trim() — “model returned empty translation”.
  • TranslateWorker stops the work with an early return when !pair.source.content?.trim().
  • TranslateWorker stops the work with an early return when pair.source.language === language.
  • TranslateWorker stops the work with an early return when pair.variant && !pair.variant.machineTranslated.

Referenced By

  • L10nModule (MODULE_PROVIDES)

Was this page helpful?

Download as PDF