import type { TranslationBundle } from '../../i18n/translation-store.js'; import type { ApiDocument } from '../api-document.js'; import type { DocumentElement } from './document-element.js'; /** * The only properties a translation bundle is ever allowed to replace. * Everything else in the schema — `examples[].value`, enum values, * `default`, `pattern`, names, paths — is data, not prose, and is never * touched. */ export type TranslatableField = 'description' | 'title' | 'deprecated'; /** * Passed through `export()` to collect the translation keys a document * *would* look up, instead of (well, alongside) resolving them — see * `extractTranslations`. Deliberately driven by the same `export()` walk * and the same per-call whitelist the runtime lookup uses, so an extracted * skeleton can't drift from what is actually asked for at serve time. */ export interface TranslationCollector { /** The document being extracted. Nodes belonging to anything else - a * referenced document's types, reached through this one - are skipped, so * that a bundle only ever holds keys the same document will look up again * (see `findTexts`, which resolves against a node's *own* document). */ document: ApiDocument; /** The skeleton being built, pre-filled with whatever the source says. */ bundle: TranslationBundle; /** Keys whose last segment had to be derived from something that isn't a * stable identifier (a RegExp-named parameter, an example's position) — * a `docKey` should be declared for each of these. */ unstable: string[]; } /** * Replaces `element`'s own prose in an already-built schema object with the * requested language's text, if there is any. A no-op unless * `options.lang` was given, which is what keeps a plain `export()`/ * `toJSON()` returning exactly what the source declares. * * Each `toJSON()` calls this once with its own list of prose properties, so * the whitelist lives at the call site where it can be read next to the * object it applies to, rather than in a table somewhere else. */ export declare function applyTranslations>(element: DocumentElement, out: T, options: ApiDocument.ExportOptions | undefined, fields: TranslatableField[], /** Extra segments below `element`'s own key, for prose that belongs to a * plain object rather than a document element of its own (a server, a * section, an example). */ extraSegments?: string[], /** Set where those extra segments had to be made up rather than taken * from a real identifier — the element-level equivalent is * `DocumentElement#docKeyUnstable`. */ extraUnstable?: boolean): T;