@shelchin/svelte-i18n
Version:
The last Svelte i18n library you'll ever need. Type-safe, AI-powered, zero-config.
53 lines (52 loc) • 1.76 kB
TypeScript
/**
* Unified SSR load function for i18n
* Combines the best features from both implementations
*/
import type { Cookies } from '@sveltejs/kit';
import type { I18nInstance, TranslationSchema } from '../core/types.js';
/**
* Server-side i18n loader with pathname detection support
* This is the main implementation that handles all SSR scenarios
*
* Priority: pathname locale > cookie locale > default locale
*
* @param i18n - The i18n instance
* @param cookies - SvelteKit cookies object
* @param url - Optional URL for pathname locale detection
* @param options - Configuration options
* @returns SSR data including locale, translations, and metadata
*/
export declare function loadI18nSSR<T = I18nInstance>(i18n: T & Pick<I18nInstance, 'locale' | 'locales' | 'setLocale'>, cookies: Cookies, url?: URL | {
pathname: string;
}, options?: {
cookieName?: string;
defaultLocale?: string;
namespace?: string;
}): Promise<{
locale: string;
locales: string[];
ssrTranslations: TranslationSchema | undefined;
isAutoDiscovered: boolean;
i18nReady: boolean;
cookieName: string;
namespace: string;
}>;
/**
* Backward compatible server load function
* Delegates to loadI18nSSR without URL parameter
*
* @deprecated Use loadI18nSSR instead for pathname support
*/
export declare function i18nServerLoad<T = I18nInstance>(i18n: T & Pick<I18nInstance, 'locale' | 'locales' | 'setLocale'>, cookies: Cookies, options?: {
cookieName?: string;
defaultLocale?: string;
namespace?: string;
}): Promise<{
locale: string;
locales: string[];
ssrTranslations: TranslationSchema | undefined;
isAutoDiscovered: boolean;
i18nReady: boolean;
cookieName: string;
namespace: string;
}>;