Reported: with Settings → "Split contact email by purpose" ON, the Batch tab showed only the old single "📧 Business inquiries:" line, while the Output tab correctly showed the grouped 📧 BUSINESS / CONTACT block with all three addresses. Root cause is not in the engine. `renderAll` had three call sites, each hand-copying the same twelve settings fields into an options object, and BatchPage's copy was missing two: `splitContactEmail` and `showThirdPartyAds` (plus `tEn`). An absent flag defaults to `false` inside `buildDescription`, so the else-branch emitted the legacy single line — silently, with no type error and no failing test, because the engine tests call `buildDescription` directly with an explicit options object and never exercise the wiring. Rather than add a third copy of the list, the mapping now lives in one place: - `SettingsRenderOptions` (settings-derived) is split from `RenderOptionOverrides` (per-caller: `tEn`, `bilingualContentBlocks`), and `RenderOptions` is their intersection. Same shape as before for `renderAll`. - New `useRenderOptions` / `buildRenderOptions` produce the settings half; all three call sites consume it and layer only their own overrides. Two guards, both verified to fail when the original bug is reintroduced: - Compile-time: `buildRenderOptions` builds a `Required<SettingsRenderOptions>`, so dropping a key is `TS2741: Property 'splitContactEmail' is missing`. - Runtime: `tests/hooks/render-options-parity.test.ts` diffs the produced keys against `SETTINGS_DERIVED_RENDER_KEYS` in both directions and names the offending key in the failure message. Also fixed by the same change, since Batch was dropping it too: `showThirdPartyAds` — the SPONSORS & PARTNERS block now renders in Batch. Batch deliberately still passes no `tEn`: its rows are one language each, so the bilingual `EN · LOCAL` treatment would duplicate every content-warning line. Note for the changelog: Batch descriptions get *longer* for anyone who had either toggle on, because those blocks were being silently dropped. Tests 621 → 629. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
39 lines
1.8 KiB
TypeScript
39 lines
1.8 KiB
TypeScript
import { useMemo } from "react";
|
|
import i18n from "i18next";
|
|
import { renderAll } from "@engine/template-renderer";
|
|
import type { GeneratorOutput, SupportedLanguage } from "@engine/types";
|
|
import { useCurrentGeneratorInput } from "./use-current-generator-input";
|
|
import { useLanguagesReady } from "./use-languages-ready";
|
|
import { useRenderOptions } from "./use-render-options";
|
|
|
|
export function useMultilangOutput(
|
|
languages: SupportedLanguage[],
|
|
): Record<string, GeneratorOutput> {
|
|
const baseInput = useCurrentGeneratorInput();
|
|
// Lazy-loaded locales (v0.26): all-or-nothing gate — OutputPage already
|
|
// renders nothing for an absent tab entry, and the per-language chunks
|
|
// load in parallel, so partial results aren't worth the complexity.
|
|
const ready = useLanguagesReady(languages);
|
|
|
|
// Always-English `t` for the bilingual translation-quality disclaimer.
|
|
// In multi-language tabs each tab is already a single target language, so
|
|
// we pass `bilingualContentBlocks: false` below — `tEn` therefore drives
|
|
// ONLY the AI-translation disclaimer here (content warnings / tech notes /
|
|
// playthrough notes stay single-language per tab), unlike `useGeneratedOutput`
|
|
// where `tEn` also makes those blocks bilingual `EN · LOCAL`. v0.29.3.
|
|
// `en` is eagerly bundled, so it never needs the readiness gate.
|
|
const tEn = useMemo(() => i18n.getFixedT("en", "templates"), []);
|
|
const options = useRenderOptions(tEn, false);
|
|
|
|
return useMemo(() => {
|
|
const results: Record<string, GeneratorOutput> = {};
|
|
if (!ready) return results;
|
|
for (const lang of languages) {
|
|
const tFn = i18n.getFixedT(lang, "templates");
|
|
const input = { ...baseInput, language: lang };
|
|
results[lang] = renderAll(input, tFn, options);
|
|
}
|
|
return results;
|
|
}, [ready, languages, baseInput, options]);
|
|
}
|