Repository navigation
feat(kiritan): wire up plugins.stores for custom TranslationStore strategies - #43
Merged
Merged
Conversation
…ategies build/check/translate/extract now dispatch a source whose strategy matches a plugins.stores key to that TranslationStore's read/write/ status instead of throwing. The two TranslatedContent shapes it declares generalize the built-ins cleanly: a "full-text" result is treated sidecar-style (parsed fresh as the whole document), a "segments" result (or nothing stored yet) catalog-style, fed into renderForLocale's existing per-id fallback — no new fallback logic needed. Staleness is left entirely to the store's own status(); check/ translate trust it outright rather than recomputing it the way the built-in sidecar/catalog formats do for themselves, since a plugin store is a black box. check only calls status(), not read(), so there is no generic "machine-translated" issue for a plugin store the way catalog's own machine flag produces one — that stays catalog-specific for now. translate/extract both no-op for a store with no write (a read-only store, e.g. backed by an external TMS). A strategy matching neither a built-in nor a registered store now throws in all four commands, not just build as before — a custom strategy typo was always a mistake with no legitimate use, and there is now an actual registration mechanism to check it against. plugins.renderers stays unwired: the declared Renderer interface (parse/reassemble over raw strings) can't represent the mdast tree the real pipeline depends on end-to-end, and a working design needs an actual second renderer (text/mdx, a separate roadmap item) to validate the interface's real shape against first.
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
plugins.storeshalf ofdocs/DESIGN.mdchapter 13's "wiringplugins.stores/plugins.renderers" roadmap item.plugins.renderersstays unwired — see below for why, and the updated chapter 11/13 explanation inbase/DESIGN.base.md.build/check/translate/extractnow dispatch a source whosestrategymatches aconfig.plugins.storeskey to thatTranslationStore'sread/write/status, instead ofbuildthrowing andcheck/translate/extractsilently doing nothing (today's behavior for any strategy string outsidesidecar/inline/catalog).TranslatedContentshapes ("full-text","segments") turned out to generalize the built-ins cleanly: a"full-text"result is treated sidecar-style, a"segments"result (or nothing stored yet) catalog-style — fed straight intorenderForLocale's existing per-id fallback, so no new fallback logic was needed anywhere.status()—check/translatetrust it outright rather than recomputing it the way the built-insidecar/catalogformats do for themselves (they own their own file format; a plugin store is a black box).checkonly callsstatus(), notread(), so there's no generic "machine-translated, needs review" issue for a plugin store — that stays acatalog-specific concept for now.translate/extractboth no-op for a store with nowrite(a legitimately read-only store, e.g. one backed by an external TMS kiritan can only pull from).strategymatching neither a built-in nor a registered store now throws in all four commands, not justbuildas before — a deliberate tightening, since a custom-strategy typo ("catalogg") was always a mistake with no legitimate use, and there's now an actual registration mechanism to check it against.plugins.rendererstoo: investigated first — the declaredRendererinterface (parse(sourceText): { raw: string },reassemble(doc, translated: string)) can't represent the mdast treedirective/render.ts'srenderForLocale/collectCatalogSegments/etc. actually operate on end-to-end. Wiring it as declared would mean building against an interface shape that doesn't fit the real pipeline; a working design needs an actual second renderer (text/mdx, a separate not-yet-started roadmap item) to validate the interface's real shape against first.Test plan
npm run ci(prettier + eslint)npm run typechecknpm run test(19 new tests across all four pipeline files: full-text/segments content, missing/partial/stale/completestatus()mapping, a read-only store, and the new unrecognized-strategy error — full existing suite passes unchanged, confirming no regression tosidecar/inline/catalog)npm run docs:build/npm run docs:checkfix-unnatural-line-breakslint on every edited file.kiritanconfigin a scratch project registering a disk-JSON-backedplugins.storesentry (a genuinely different storage format from the built-in catalog JSON, to prove the abstraction), and ran the fullcheck→extract→check→translate→check→buildround trip across separate CLI invocations, confirming the dispatch and persistence actually work outside the unit tests too. Also confirmed the unrecognized-strategy error via the real CLI.