Skip to content

refactor(translator): unify locale-set invariants into one Locales kernel - #89

Open
SearheiParkhamchuk wants to merge 1 commit into
mainfrom
refactor/translator-locale-kernel
Open

refactor(translator): unify locale-set invariants into one Locales kernel#89
SearheiParkhamchuk wants to merge 1 commit into
mainfrom
refactor/translator-locale-kernel

Conversation

@SearheiParkhamchuk

Copy link
Copy Markdown
Contributor

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:

  • manual /enqueue resolver (resolveTargetLocales),
  • auto-translate config-time filter (normalizeAutoTranslateConfig dedup + filterPolicyToKnownLocales),
  • auto-translate runtime task builder (buildAutoTranslateTasks source-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 composed resolveTargets for the manual
one-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 read Locales.dedupe(...) /
Locales.resolveTargets(...). export * as keeps each member individually tree-shakeable, unlike an
object 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:

  • The existing manual + auto-translate tests pass unchanged — the proof that behavior is preserved.
  • New tests cover the kernel primitives directly, and a new case pins the auto-translate dedup call
    site (so a reverted dedupe(config.targets) turns a test red, not just the primitive test).

Verification

  • Unit: 1189 pass. Integration: 9 files / 32 tests pass against the built dist.
  • Type-check (turbo) + real tsc declaration build succeed; lint clean on changed files.
  • Deep review pass (4 angles + adversarial opus verify): line-by-line equivalence vs. the deleted code
    confirmed; no surviving findings.

…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.
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
turbo-cms-kit-payload Ready Ready Preview Jul 31, 2026 4:32pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant