# Locale API

Language dictionaries, fallback helpers and message parsing.

Source: https://docs.peax.co/consent/reference/locales



## Public entry points [#public-entry-points]

| Entry        | Runtime exports                                                                                                        |
| ------------ | ---------------------------------------------------------------------------------------------------------------------- |
| Package root | `getMessages`, `getPreferencesMessages`, `resolveLocale`, `parseMessage`, `en`, `de`, `enPreferences`, `dePreferences` |
| `/en`        | `en`, `enPreferences`                                                                                                  |
| `/de`        | `de`, `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 [#published-signatures]

```ts
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 [#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](/consent/guides/localization) for React examples.
