Submission generator: language selector (DE / EN) to drive output document language #108
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
m's report (2026-05-25 16:22)
Scope
The submission generator currently produces output in the language baked into the template body (mostly DE for the demo templates). m wants the user to explicitly pick the output language (DE or EN) on the draft editor, and the generator should:
de.inf.lg.erwidg.docxvsde.inf.lg.erwidg.en.docx).{{procedural_event.name_de}}vs{{procedural_event.name_en}}).What to do
Backend
languagecolumn topaliad.submission_drafts(text NOT NULL DEFAULT 'de', CHECK in ('de','en')). Migration 129+ (verify slot).SubmissionVarsService.Buildalready returns both_deand_envariants; introduce alanguageparameter that selects the right one for unsuffixed placeholders (e.g.{{procedural_event.name}}becomes the language-matched value).{code}.{lang}.docx) → fallback to unsuffixed → fallback to_skeleton.{lang}.docx→ universal HL skeleton.?language=de|enquery OR reads from the draft row.Frontend
Sprache: ● DE ○ EN.i18n
submission.draft.language,submission.draft.language.de,submission.draft.language.en,submission.draft.language.fallback_notice.Files most likely touched
internal/models/models.go— addLanguagetoSubmissionDraftinternal/db/migrations/12X_submission_drafts_language.up.sqlinternal/services/submission_vars.go— language-aware resolutioninternal/services/submission_templates.go— language-suffixed template lookupinternal/handlers/submissions.go+submission_drafts.gofrontend/src/submission-draft.tsx/client/submission-draft.tsfrontend/src/client/i18n.ts+frontend/src/i18n-keys.tsHard rules
de(per project CLAUDE.md primary-language convention).devia the column default.go build ./... && go test ./internal/... && cd frontend && bun run buildclean.mai/<worker>/submission-draft-language-selector.Out of scope
Reporting
mai report completedwith branch + SHAs + migration slot + UX path: open a draft → switch language toggle → confirm preview re-renders with EN labels + EN-suffixed values → export → docx is EN.Shipped (gitster: demeter)
Branch:
mai/demeter/gitster-submissionCommit: 669764e
Migration slot: 130 (bumped from 129 to deconflict with atlas's #96, per paliadin instruction)
Backend
paliad.submission_drafts.language text NOT NULL DEFAULT 'de'(CHECK in('de','en')). Existing rows inheritdevia the default — every legacy draft renders byte-for-byte identically.SubmissionVarsContext.Langoverrides the user's UI lang.Build()uses it when set; falls back touser.Langotherwise, so Slice 1's format-only/generatekeeps working unchanged.SubmissionDraftService.BuildRenderBagthreadsdraft.Languagethrough;Create/EnsureLatestseed from the UI lang (DE default).DraftPatch.Languageadded;Updatevalidates and rejects values outside{de,en}. Both project-scoped and global PATCH endpoints surface the field.resolveSubmissionTemplate(ctx, code, lang)replaces the lang-less predecessor. Returns the matched tier (per_code_lang/per_code/skeleton_lang/skeleton/letterhead) so the editor knows whether the resolved template language-matches the request.fileRegistryregisters the EN skeleton siblingsubmission/_skeleton.en.docxalongside the DE one. Per-code EN variants land insubmissionTemplateENRegistry(empty for now — HLC authors per{code}.en.docx). Gitea 404s on missing variants fall through silently.POST /api/projects/{id}/submissions/{code}/generateaccepts?language=de|enoverride; defaults to the user's UI lang.Frontend
frontend/src/submission-draft.tsx. Switching the radio PATCHeslanguageand the server returns the freshly-resolved bag + preview HTML so the lawyer sees EN values immediately without a reload.submissions.draft.language[.de|.en|.fallback_notice]..submission-draft-language-row,.submission-draft-language-fallback).Tests
services.TestNormalizeDraftLanguagecovers DE / EN / case / whitespace / unknown.services.TestAddRuleVars_LanguageSelectsMatchedNamepinsprocedural_event.name(and the legacyrule.namealias) to the language-matched value across DE + EN; explicit_de/_enkeys stay unchanged regardless of lang.handlers.TestLanguageFallbacktruth table for all 10 (lang × tier) combinations — pins which tier counts as a fallback for the UI signal.go test ./internal/...).UX path
/projects/{id}/submissions/{code}/draft/{draft_id}).PATCH /api/submission-drafts/{id}with{language:"en"}→ server returns updated view withlang="en",language_fallback=true, EN-resolved values forprocedural_event.name,our_side_en, etc.Statement of Defence-{case}-{YYYY-MM-DD}.docx(file name picks EN viarule.NameEN).tplTierPerCodefor DE drafts counts as first-class).Out of scope (deferred per task brief)
submission/{code}.en.docxandsubmission/_skeleton.en.docx. Registry slot already exists; today it falls through to DE.Build hygiene
go build ./...clean.go vet ./...clean.go test ./internal/...clean.cd frontend && bun run buildclean (2877 i18n keys, data-i18n scan clean).Note on coordination
Paliadin flagged mid-flight that atlas's #96 also claimed slot 129. Migration was renamed to 130 before commit — no Go code references the slot number, so the rename was a single
mvpair.Rebased onto main (post-knuth #107 merge)
Branch:
mai/demeter/gitster-submission@ af7a1e9 (force-pushed; previous SHA 669764e).Conflicts resolved per paliadin's coordination note — kept BOTH contributions:
internal/handlers/files.gofirmSkeletonSubmissionSlugregistry entry + const (HL-formatted skeleton).skeletonSubmissionENSlugregistry entry + const (EN skeleton sibling).internal/handlers/submission_drafts.go(resolveSubmissionTemplate)Merged the firm-skeleton tier (t-paliad-275) with the language-aware lookup (t-paliad-276). Final fallback order:
de.inf.lg.erwidg.en.docxetc. (most specific)_skeleton.en.docx; only fires for EN drafts since DE drafts prefer the firm-skeleton (step 4)._firm-skeleton.docx(HL styles, DE prose). First-class for DE drafts; counts aslanguage_fallback=truefor EN drafts (handled bylanguageFallback())._skeleton.docx(plain DE, backstop)The
tplTierSkeletonLangtier still trumps any DE skeleton for EN drafts, so an EN draft with a registered_skeleton.en.docxgets a language-matched preview even when no per-code template exists.Build hygiene
go build ./...clean.go vet ./...clean.go test ./internal/...clean (all 3 new tests + every pre-existing test pass).cd frontend && bun run buildclean.Ready for merge.