refactor(translator): unify locale-set invariants into one Locales kernel - #89
Open
SearheiParkhamchuk wants to merge 1 commit into
Open
refactor(translator): unify locale-set invariants into one Locales kernel#89SearheiParkhamchuk wants to merge 1 commit into
SearheiParkhamchuk wants to merge 1 commit into
Conversation
…rnel Dedup, unknown-locale dropping, and source-locale exclusion were hand-written in 2-3 places (the manual /enqueue resolver, the auto-translate config-time filter, and the auto-translate runtime task builder), risking silent drift if one copy changed. Extract them into a pure, payload-free kernel (core/domain/locales), exposed as a namespace (Locales.dedupe, Locales.resolveTargets, ...), and route every path through it. No behavior change: the existing manual + auto-translate tests pass unchanged; new tests cover the kernel primitives and pin the auto-translate dedup call site.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Extracts the locale-set invariants that were hand-written in 2–3 places into a single, pure,
payload-free kernel, and routes every enqueue path through it. This is the planned follow-up to the
tier-C fixes (#85) — the "fold the duplicated locale logic into one shared unit" slice.
Why
Dedup, unknown-locale dropping, and source-locale exclusion each lived in 2–3 copies:
/enqueueresolver (resolveTargetLocales),normalizeAutoTranslateConfigdedup +filterPolicyToKnownLocales),buildAutoTranslateTaskssource-exclusion).If one copy changed (e.g. case-insensitive matching, trimming), the others would silently drift.
What
New kernel
src/core/domain/locales/— pure primitives with one canonical implementation each:isKnown,dedupe,dropUnknown,excludeSource, plus the composedresolveTargetsfor the manualone-shot. Each path composes the primitives it needs at its own phase (the config/runtime split of
auto-translate is preserved — no per-save warnings introduced).
Consumed as a namespace (
export * as Locales): call sites readLocales.dedupe(...)/Locales.resolveTargets(...).export * askeeps each member individually tree-shakeable, unlike anobject literal or a static class. This is a pilot for that grouping convention; if it reads well we can
extend it to other cohesive kernels.
The old
enqueue-translation/resolveTargetLocales.ts(+ its test) is deleted — moved into the kernel.No behavior change
This is a characterized refactor:
site (so a reverted
dedupe(config.targets)turns a test red, not just the primitive test).Verification
dist.tscdeclaration build succeed; lint clean on changed files.confirmed; no surviving findings.