@better-auth-ui/core
Version:
Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.
30 lines (29 loc) • 1.62 kB
TypeScript
import { AuthPlugin } from './auth-plugin';
import { Localization } from './localization';
export type AuthLocaleDirection = "ltr" | "rtl";
/** A complete set of translated Better Auth UI messages. */
export interface AuthLocale {
/** Canonical BCP 47 language tag, such as `de-DE` or `zh-CN`. */
languageTag: string;
/** Text direction for this locale. @default "ltr" */
direction?: AuthLocaleDirection;
/** Core authentication and settings messages. */
localization: Localization;
/** Optional messages keyed by auth plugin ID. */
plugins?: Record<string, Record<string, unknown>>;
}
export declare const defaultAuthLocale: AuthLocale;
/** Defines a locale while preserving its narrow language-tag type. */
export declare function defineAuthLocale<const TLocale extends AuthLocale>(locale: TLocale): TLocale;
export type MatchAuthLocaleOptions<TLocale extends AuthLocale> = {
/** Browser languages or an `Accept-Language` header value. */
requested: string | readonly string[] | null | undefined;
/** Locales that the application has imported. */
supported: readonly TLocale[];
/** Locale returned when no requested language matches. */
fallback: TLocale;
};
/** Matches exact language tags first, then matches their base languages. */
export declare function matchAuthLocale<TLocale extends AuthLocale>({ requested, supported, fallback }: MatchAuthLocaleOptions<TLocale>): TLocale;
/** Applies locale messages to registered plugins without mutating them. */
export declare function localizeAuthPlugins(plugins: AuthPlugin[], locale: AuthLocale): AuthPlugin[];