Skip to content

Core / locale: LocaleControlsConfig

Functions, types, and exports for Core / locale: LocaleControlsConfig.

Page outline
import type { LocaleControlsConfig } from "@palamedes/core/locale"

type LocaleControlsConfig<TLocale extends string> = {
    /** Supported locales; the first is not special, `defaultLocale` decides. */
    locales: readonly TLocale[];
    /** Fallback when nothing else resolves. */
    defaultLocale: TLocale;
    /** Display labels; defaults to `Intl.DisplayNames`, then the locale code. */
    labels?: Partial<Record<TLocale, string>>;
    /** Cookie names; default to `locale` and `locale-choice`. */
    cookies?: {
        locale?: string;
        choice?: string;
    };
    /** Optional host strategy (locale per host). */
    hosts?: HostLocaleConfig<TLocale>;
    /**
     * Scheme for host-carrying URLs from `canonicalUrl` and `suggest` (e.g.
     * `"https"`). Without it those URLs are protocol-relative (`//host/path`),
     * which stays correct on http (local) and https (deployed) alike.
     */
    protocol?: string;
};

Properties

NameTypeRequiredDescription
localesreadonly TLocale[]YesSupported locales; the first is not special, defaultLocale decides.
defaultLocaleTLocaleYesFallback when nothing else resolves.
labelsPartial<Record<TLocale, string>>NoDisplay labels; defaults to Intl.DisplayNames, then the locale code.
cookies{ locale?: string; choice?: string }NoCookie names; default to locale and locale-choice.
hostsHostLocaleConfig<TLocale>NoOptional host strategy (locale per host).
protocolstringNoScheme for host-carrying URLs from canonicalUrl and suggest (e.g.
"https"). Without it those URLs are protocol-relative (//host/path),
which stays correct on http (local) and https (deployed) alike.

Source entry on GitHub

Last updated: November 14, 2026