import type { CreatePackageTypes, Locale, PackageI18n, PackageTranslations, TranslationParams, TranslationSchema, Translations, TypedTranslationFunction } from './types.js'; export interface CreatePackageI18nOptions { /** * Per-locale lazy loaders (WP4 code-splitting). Each returns the package's * bundle for that locale as a dynamic-import chunk, e.g. * `() => import('./translations/de').then((m) => m.default)`. Listed locales * stay out of the initial bundle until activated by the provider / `setLocale`; * the eager bundle passed in `translations` (typically `en`) is the base/ * fallback. Compile-time key parity is NOT checked for lazy locales — pair with * `validatePackageTranslations` in a test to guard parity at runtime/CI. */ loaders?: Partial Promise>>; } /** * Creates a standardized i18n integration for a package. * * Generic over the `en` bundle: with `` the literal key/param types of * `en` flow through `PackageI18n` into a fully typed `t` — real `DeepKeys` * plus `ExtractParams`, so `t('dialog.close')` autocompletes and * `t('dialog.nope')` is a compile error. Other locales are checked against * `TranslationSchema` (T's structure with its string values widened), which * enforces key parity at compile time while allowing locale-specific strings. * * Opt-in code-splitting (WP4): pass `options.loaders` to keep non-base locales * out of the initial bundle as dynamic-import chunks, loaded only when activated. */ export declare function createPackageI18n(packageName: string, translations: { en: T; } & Partial>>, options?: CreatePackageI18nOptions): PackageI18n; /** * Creates a package-translations descriptor (data only — does NOT register). * * @deprecated Superseded by {@link createPackageI18n}, which registers and * returns a typed `t` in one step. Retained for back-compat; the `types` field * is a non-functional placeholder (`CreatePackageTypes` degenerates * to `string` keys, predating the generic factory). */ export declare function createPackageTranslations(packageName: string, translations: Partial>): { packageName: string; translations: Partial>; types: CreatePackageTypes; }; /** * Creates a typed translation package with auto-registration. * * @deprecated Use {@link createPackageI18n} directly. Since that factory became * generic (``) it already infers literal keys and returns a fully typed * `t`; this wrapper adds only a redundant `tt` alias and a `packageName`/ * `translations` passthrough. Kept as a thin, typed shim for back-compat — it * will be removed in a future major. */ export declare function createTypedPackage(packageName: string, translations: { en: T; } & Partial>>): { packageName: string; translations: { en: T; } & Partial>>; tt: TypedTranslationFunction; useTranslate: () => TypedTranslationFunction; t: TypedTranslationFunction; exists: (key: string) => boolean; getLocales: () => Locale[]; register: () => void; registerLocale: (locale: Locale, bundle: Translations) => void; types: CreatePackageTypes; }; /** * Register translation loaders for lazy loading * Useful for larger packages with many translations */ export declare function registerTranslationLoaders(loaders: Record Promise>): void; /** * Smart component integration helper * Provides common patterns for component i18n integration */ export declare function createComponentI18n(packageName: string, translations: { en: T; } & Partial>>, defaultOptions?: { useI18n?: boolean; fallbackToGlobal?: boolean; }): { getText: (key: string, customText?: string, params?: TranslationParams, options?: { useI18n?: boolean; }) => string; maybeT: (key: string, params?: TranslationParams, options?: { useI18n?: boolean; fallback?: string; }) => string; useTranslate: () => TypedTranslationFunction; t: TypedTranslationFunction; exists: (key: string) => boolean; getLocales: () => Locale[]; register: () => void; registerLocale: (locale: Locale, bundle: Translations) => void; types: CreatePackageTypes; }; /** * Batch register multiple packages * Useful for apps that use many packages */ export declare function registerPackages(packages: Array<{ name: string; translations: PackageTranslations; }>): void; /** * Validates deep-key parity across a package's locale bundles. * * Compares the full recursive leaf-key set (not just top-level keys) of every * locale against the base locale (`en` first by convention). A missing nested * key is an error; an extra nested key is a warning. Pair with a per-package * vitest assertion (`expect(errors).toEqual([])`) to fail CI on drift — * complementing the compile-time parity `satisfies`/generic factory enforce for * statically-typed bundles, and covering dynamically/lazily loaded ones. */ export declare function validatePackageTranslations(packageName: string, translations: Partial>): { isValid: boolean; errors: string[]; warnings: string[]; };