PeaxDocsv0.2.0
Reference

Consent v0.2.0

Locale API

Language dictionaries, fallback helpers and message parsing.

Public entry points

EntryRuntime exports
Package rootgetMessages, getPreferencesMessages, resolveLocale, parseMessage, en, de, enPreferences, dePreferences
/enen, enPreferences
/dede, dePreferences

The root includes both dictionaries. Per-language entries include the selected language. All entries are ESM and safe for server-side use.

resolveLocale accepts regional tags, trims and normalizes case, and falls back to English. getMessages returns banner copy; getPreferencesMessages returns section copy, without checked/disabled behavior.

Published signatures

export declare type BannerLocale = 'en' | 'de';
export declare type BannerMessages = Readonly<{
    title: string;
    collapsedText: string;
    acceptAllLabel: string;
    rejectAllLabel: string;
    customizePreferencesLabel: string;
    preferencesTitle: string;
    preferencesText?: string;
    closePreferencesLabel: string;
    applyPreferencesLabel: string;
    cookiePolicyLabel: string;
}>;
export declare type BuiltInPreferencesSectionId = 'essential' | 'analytics' | 'marketing';
export declare const de: BannerMessages;
export declare const dePreferences: PreferencesMessages;
export declare const en: BannerMessages;
export declare const enPreferences: PreferencesMessages;
export declare function getMessages(locale?: string): BannerMessages;
export declare function getPreferencesMessages(locale?: string): PreferencesMessages;
export declare type MessagePart<Link extends string = string> = Readonly<{
    offset: number;
    value: string;
} & ({
    type: 'text';
} | {
    type: 'link';
    name: Link;
})>;
export declare function parseMessage<Link extends string>(message: string, links: readonly Link[]): MessagePart<Link>[];
export declare type PreferencesMessages = Readonly<Record<BuiltInPreferencesSectionId, Readonly<{
    title: string;
    text: string;
}>>>;
/** Regional tags use the supported base language; unknown locales fall back to English. */
export declare function resolveLocale(locale?: string): BannerLocale;
export {};

Safe message parsing

parseMessage takes an explicit placeholder allowlist. It returns text and link parts in source order, including source offsets. Unknown, nested, attributed or malformed markup remains literal text; HTML entities are not decoded. Your renderer supplies elements and URLs.

See localization for React examples.

On this page