/// import { App } from 'vue'; import { CleanTranslation } from '@i18n-micro/types'; import { defaultPlural } from '@i18n-micro/core'; import { FormatService } from '@i18n-micro/core'; import { Getter } from '@i18n-micro/types'; import { I18nGroup } from '@i18n-micro/vue'; import { I18nLink } from '@i18n-micro/vue'; import { I18nPlugin } from '@i18n-micro/vue'; import { I18nRoutingStrategy } from '@i18n-micro/vue'; import { I18nSwitcher } from '@i18n-micro/vue'; import { I18nT } from '@i18n-micro/vue'; import { interpolate } from '@i18n-micro/core'; import { Locale } from '@i18n-micro/types'; import { LocaleCode } from '@i18n-micro/types'; import { Params } from '@i18n-micro/types'; import { Plugin as Plugin_2 } from 'vite'; import { PluralFunc } from '@i18n-micro/types'; import { Ref } from 'vue'; import { Translations } from '@i18n-micro/types'; import { useI18n } from '@i18n-micro/vue'; import { UseI18nOptions } from '@i18n-micro/vue'; import { VueI18nOptions } from '@i18n-micro/vue'; export { CleanTranslation } /** * Universal VitePress i18n: Vue plugin + path helpers + `enhanceApp` sync. * Path methods are the router adapter’s own functions (no wrapper layer). */ export declare function createI18n(options: CreateI18nOptions): CreateI18nResult; export declare interface CreateI18nOptions { locale: string; fallbackLocale?: string; locales?: Locale[]; defaultLocale?: string; messages?: Record; /** * Page-scoped dictionaries keyed by route name (`guide-demo`), then locale. * Loaded from `locales/pages/**` when using `withI18n`. */ routeMessages?: Record>; plural?: PluralFunc; missingWarn?: boolean; numberFormats?: VueI18nOptions['numberFormats']; datetimeFormats?: VueI18nOptions['datetimeFormats']; timeZone?: string; missingHandler?: (locale: string, key: string, routeName: string) => void; /** * Sync i18n locale from the VitePress URL path on every navigation. * @default true */ syncWithVitePress?: boolean; /** * Map VitePress locale keys to i18n codes (`root` → default locale code). */ localeKeyToCode?: Record; /** * VitePress `site.base`. Needed so SSG paths (`withBase`) and lang switcher * do not treat the base segment as content / double-prefix links. */ base?: string; } export declare type CreateI18nResult = I18nPlugin & PathMethods & { /** Same as `.global` (VueI18n + path methods). */ i18n: I18nPlugin['global'] & PathMethods; enhanceApp: (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref | VitePressSiteDataLike; }) => void; }; export { defaultPlural } export { FormatService } /** * Detect i18n locale code from a URL path (prefix_except_default). * Path prefixes are VitePress locale keys; return value is the i18n code. * Pass `base` when the path may include VitePress `site.base` (SSG). */ export declare function getLocaleFromPath(path: string, localeCodes: string[], defaultLocale: string, localeKeyToCode?: Record, base?: string): string; export { Getter } export { I18nGroup } export { I18nLink } export { I18nPlugin } export { I18nRoutingStrategy } export { I18nSwitcher } export { I18nT } export { interpolate } export { Locale } export { LocaleCode } /** * Tiny helper if you still prefer `import.meta.glob` instead of `defineI18nTheme`. * Only unwraps Vite module namespaces — dictionaries with a `default` key stay intact. */ export declare function messagesFromGlob(modules: Record): Record; export { Params } /** Path helpers exposed on `createI18n` instances (slice of the router adapter). */ export declare type PathMethods = Pick; export { PluralFunc } /** * Route name for page-scoped dictionaries (`/guide/demo` → `guide-demo`). * Strips VitePress URL prefixes (keys), not only raw i18n codes. * * When `defaultLocale` is omitted (legacy 2-arg call), any segment that matches a * listed locale code is stripped — callers must not rely on `localeCodes[0]` as default. */ export declare function routeNameFromPath(path: string, localeCodes: string[], defaultLocale?: string, localeKeyToCode?: Record, base?: string): string; /** * Strip VitePress `site.base` from a path. Leaves query/hash intact. * No-op when `base` is missing or `/`. */ export declare function stripSiteBase(path: string, base?: string): string; export { Translations } export { useI18n } export { UseI18nOptions } export declare interface VirtualI18nConfig { defaultLocale: string; fallbackLocale: string; locales: Locale[]; localeCodes: string[]; missingWarn: boolean; syncWithVitePress: boolean; translationDir: string; disablePageLocales: boolean; localeKeyToCode: Record; /** VitePress `site.base` (normalized, trailing slash preserved from config). */ base?: string; numberFormats?: CreateI18nOptions['numberFormats']; datetimeFormats?: CreateI18nOptions['datetimeFormats']; timeZone?: string; } declare interface VitePressRouterAdapter extends I18nRoutingStrategy { getLocaleFromPath: (path: string) => string; switchLocalePath: (path: string, newLocale: string) => string; localizePath: (path: string, locale: string) => string; removeLocaleFromPath: (path: string) => string; /** Page dictionary route name (`/fr/guide/demo` → `guide-demo`). */ routeNameFromPath: (path: string) => string; /** Resolve VitePress locale key (`root` / `fr`) to i18n code. */ codeFromLocaleKey: (localeKey: string) => string; /** Resolve i18n code to VitePress locale key. */ localeKeyFromCode: (code: string) => string; localeCodes: string[]; defaultLocale: string; /** Snapshot of mapping used when building the adapter (for `i18nRouting` serialization). */ localeKeyToCode: Record; /** URL path prefixes (VitePress locale keys except `root`). */ urlPrefixes: string[]; /** VitePress `site.base` used when constructing this adapter (may be undefined). */ base?: string; } declare interface VitePressRouterLike { route: { path: string; hash?: string; query?: string; }; go: (to: string, options?: { initialLoad?: boolean; replace?: boolean; }) => void | Promise; onAfterRouteChange?: (to: string) => unknown; /** The only name VitePress calls before 1.6. */ onAfterRouteChanged?: (to: string) => unknown; } export declare interface VitePressSiteDataLike { locales?: Record; } /** * Minimal VitePress / Vite user config shape we merge into. * Avoid importing `vitepress` types so the package stays usable as a pure library dep. */ export declare interface VitePressUserConfigLike { base?: string; locales?: Record; themeConfig?: Record | null; transformHead?: (...args: any[]) => any; transformPageData?: (...args: any[]) => any; vite?: { plugins?: Plugin_2[] | Plugin_2[][]; ssr?: { noExternal?: string | true | Array; [key: string]: unknown; }; [key: string]: unknown; }; [key: string]: unknown; } export { VueI18nOptions } export declare interface WithI18nOptions extends CreateI18nOptions { /** * Directory with locale JSON (`en.json`, `pages/guide/demo/en.json`, …), relative to Vite root * (VitePress content / docs root). Used by `virtual:i18n-micro/messages`. * @default 'locales' */ translationDir?: string; /** * When true, treat `pages/**` as root-level dictionaries. * @default false */ disablePageLocales?: boolean; /** * When true, logs a warning if VitePress `locales` keys do not align with * configured i18n locale codes. * @default true */ warnOnLocaleMismatch?: boolean; /** * Inject `themeConfig.i18nRouting` from adapter options + `config.base`. * Set `false` to skip. Skipped automatically when `themeConfig.i18nRouting` is already set. * @default true */ i18nRouting?: boolean; /** * Emit i18n SEO tags via `transformHead` (canonical, hreflang, og:locale…) — * Nuxt `meta` / plugin `02.meta` analogue. * Absolute link tags require `metaBaseUrl`. * @default true when `metaBaseUrl` is set, otherwise false */ meta?: boolean; /** * Public origin without trailing slash (`https://example.com`). * Same role as Nuxt `metaBaseUrl`. */ metaBaseUrl?: string; /** Also emit bare-language hreflang from `iso` (Nuxt `hreflangBaseLanguage`). @default false */ hreflangBaseLanguage?: boolean; /** Query keys kept on canonical / alternate URLs. @default [] */ canonicalQueryWhitelist?: string[]; } export { }