import { type Json, type SerializedSchema, type SourcePath } from "@valbuild/core"; /** * Where an editor goes when the Studio's language changes under them. * * - `stay`: the path is in that language, or in none. * - `path`: the same entry in that language (`counterpart`), or the nearest * parent that is not in another language (`parent`). * - `home`: neither exists, so the editor goes to the Studio's start, with * nothing selected. */ export type LocaleRelocation = { type: "stay"; } | { type: "path"; path: SourcePath; reason: "counterpart" | "parent"; } | { type: "home"; }; /** * Where to move a path to when the Studio is switched to `locale`. * * The rule, in the order it is tried: * * 1. **The same entry in `locale`, where Val KNOWS it.** That is two cases: * a locale-keyed record, where the counterpart of `"en-US"` is the * `"nb-NO"` key of the same record; and a router whose URLs name their * language, where `/about` and `/nb/about` differ only in it. Only a key * that exists is taken, and the rest of the path is kept as far as it * still exists, so an editor on a field lands on that field. * 2. **Otherwise the nearest parent that is not in another language.** An * English post in a list of posts gives the list, now showing Norwegian. * 3. **Otherwise the Studio's start**, which is `home`: nothing selected. That * is where an object at the module root opened the scope (the whole module * is in another language), and where the parent would be a router: a list * of pages is not a page, and the Pages tree is how an editor sees one. * * Not the site's root page, and not any other page: which language a page is * in is the page's own business, and `/` can be in the language the editor * just left. The start screen is in no language. * * Never a guess. Two pages whose URLs differ in more than the language — a * Norwegian slug for a Norwegian page — are not known to be translations of * each other, so that is `home` rather than whichever page looks closest. */ export declare function relocateForLocale(path: SourcePath, locale: string, schema: SerializedSchema, source: Json, available: readonly string[]): LocaleRelocation;