feat(translator): auto-translate on source-locale content change (#51)#76
Open
SearheiParkhamchuk wants to merge 3 commits into
Open
feat(translator): auto-translate on source-locale content change (#51)#76SearheiParkhamchuk wants to merge 3 commits into
SearheiParkhamchuk wants to merge 3 commits into
Conversation
Opt-in, per-collection auto-translation. Wrap a collection with `withAutoTranslate(collection, opts)` and the plugin queues translations for the configured target locales whenever source-locale content changes. Off by default; configured by the developer in code. - Config source of truth on `collection.custom` via `withAutoTranslate` (mirrors `withFieldTranslation`); payload-free reader `getAutoTranslateConfig`. - Drift gate `hasSourceContentChanged` (source fingerprint) skips unchanged saves. - Debounce via optional `TaskInput.waitUntil` + existing pending-job supersession. - Loop guard: source-locale check + a transient `req.context` flag set by the translate handler's write-back. - Publish-only trigger; auto-translated target status mirrors the source. - `AutoTranslatePolicyResolver(slug, doc)` seam reserved for a future document-level manager layer (`doc` ignored in v1). - Best-effort hook (never fails the editor's save). Public API `@since 0.9.0`; README documents the serverless/Vercel autorun caveat.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
… popups Mark collections opted into auto-translate with a quiet lightning-bolt marker in the header of both translation popups (document + collection); the source locale, target locales, and the publish trigger are in its tooltip. Ambient config, kept out of the popup's main flow. The opt-in is propagated onto the registered collection's `custom` at init, so the UI reads it reliably even when only the plugin-param object was wrapped with `withAutoTranslate` (the registered collection can be a different object). Internal only — no public API change; ships in 0.9.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opt-in, per-collection auto-translation that queues translations for configured target locales whenever a document's source-locale content changes. Off by default; configured by the developer in code.
Closes #51. Public API
@since 0.9.0(feat → minor).How it works
Wrap a collection with
withAutoTranslate(collection, { targets, ... }). The plugin injects a best-effortafterChangehook that:hasSourceContentChanged(source fingerprint) skips saves that didn't change source content.Design decisions
collection.customviawithAutoTranslate(mirrorswithFieldTranslation); payload-free readergetAutoTranslateConfig.TaskInput.waitUntil+ existing pending-job supersession — a fresh edit cancels and replaces the delayed job.req.contextflag set by the translate handler's write-back.AutoTranslatePolicyResolver(slug, doc)seam reserved (v1 ignoresdoc).Serverless / Vercel caveat
Auto-translate only enqueues; execution depends on the job runner's autorun. On serverless (e.g. Vercel) where cron-based autorun may not run, enqueued translations can sit unexecuted until triggered externally. Documented on the
withAutoTranslateJSDoc + README.Testing
check-types✓test✓ (1079 tests, incl. new units for policy, enqueue hook, config reader,hasSourceContentChanged, plugin wiring, both task runners)lint✓ (no new warnings vs.mainbaseline)Design doc:
docs/plans/2026-07-15-auto-translate-on-source-change-51.md.