nuxt-i18n-micro
Version:
Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.
47 lines (46 loc) • 1.56 kB
TypeScript
import { type CacheControlOptions } from '@i18n-micro/utils/cache-control';
export interface LoadOptions {
apiBaseUrl: string;
baseURL: string;
apiBaseClientHost?: string;
apiBaseServerHost?: string;
dateBuild?: string | number;
routesLocaleLinks?: Record<string, string>;
}
export interface LoadResult {
data: Record<string, unknown>;
cacheKey: string;
}
declare class TranslationStorage {
private cc;
constructor();
/**
* Configure cache limits. Call once from plugin with config values.
*/
configure(options: CacheControlOptions): void;
/** Plain clone before freeze — SSR payload chunks may be Vue reactive proxies. */
private freezePlainClone;
private getCacheKey;
private fetchTranslations;
/**
* Seed translation cache from SSR payload (`useState('i18n-ssr-chunks')`).
* Called on client before the first fetch.
*/
seedFromSsrChunks(chunks: Record<string, Record<string, unknown>>): void;
/**
* Synchronous cache check and retrieval.
* Returns data if cached (and not expired), otherwise null.
*/
getFromCache(locale: string, routeName?: string): LoadResult | null;
/**
* Load translations (with caching).
* Returns data, cache key, and JSON for injection (server only).
*/
load(locale: string, routeName: string | undefined, options: LoadOptions): Promise<LoadResult>;
/**
* Clear cache and metadata.
*/
clear(): void;
}
export declare const translationStorage: TranslationStorage;
export {};