@i18n-micro/vitepress 1.1.14 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +13 -91
  3. package/dist/adapter-BbqZKi2F.cjs +2 -0
  4. package/dist/adapter-BbqZKi2F.cjs.map +1 -0
  5. package/dist/adapter-DTS0CTC7.js +131 -0
  6. package/dist/adapter-DTS0CTC7.js.map +1 -0
  7. package/dist/config.cjs +6 -6
  8. package/dist/config.cjs.map +1 -1
  9. package/dist/config.d.cts +7 -0
  10. package/dist/config.d.ts +7 -0
  11. package/dist/config.mjs +129 -220
  12. package/dist/config.mjs.map +1 -1
  13. package/dist/create-Bo6VND8l.js +87 -0
  14. package/dist/create-Bo6VND8l.js.map +1 -0
  15. package/dist/create-Dn1m6fyc.cjs +2 -0
  16. package/dist/create-Dn1m6fyc.cjs.map +1 -0
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +8 -0
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.mjs +6 -7
  22. package/dist/index.mjs.map +1 -1
  23. package/dist/node.cjs +1 -1
  24. package/dist/node.cjs.map +1 -1
  25. package/dist/node.mjs +3 -4
  26. package/dist/theme.cjs +1 -1
  27. package/dist/theme.cjs.map +1 -1
  28. package/dist/theme.d.cts +42 -1
  29. package/dist/theme.d.ts +42 -1
  30. package/dist/theme.mjs +9 -7
  31. package/dist/theme.mjs.map +1 -1
  32. package/dist/vitepress-locales-CwOlvAa0.cjs.map +1 -1
  33. package/dist/{vitepress-locales-DOhKs3q5.js → vitepress-locales-DYuP6i_x.js} +2 -3
  34. package/dist/{vitepress-locales-DOhKs3q5.js.map → vitepress-locales-DYuP6i_x.js.map} +1 -1
  35. package/package.json +24 -13
  36. package/dist/adapter-CAJNI6Sw.js +0 -127
  37. package/dist/adapter-CAJNI6Sw.js.map +0 -1
  38. package/dist/adapter-eYZZOC9d.cjs +0 -2
  39. package/dist/adapter-eYZZOC9d.cjs.map +0 -1
  40. package/dist/create-C_dXg23X.js +0 -81
  41. package/dist/create-C_dXg23X.js.map +0 -1
  42. package/dist/create-Cwu2djcO.cjs +0 -2
  43. package/dist/create-Cwu2djcO.cjs.map +0 -1
  44. package/dist/plugin/virtual-stubs/config.d.cts +0 -14
  45. package/dist/runtime/define-theme.d.cts +0 -39
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-C_dXg23X.js","names":["createI18n","createVueI18n","createVitePressRouterAdapter","applyRouteMessages","routeMessages","routeName","byLocale","locale","translations","mergeRouteTranslationsWithRoot","root","createI18n$1","defaultLocale","options","locales","syncWithVitePress","plugin","createI18n","paths","pathMethods","pageRouteNames","byApp","ctx","state","app","adapter","route","router","href","navOptions","sync","nextLocale","path","derived","current","to","url"],"sources":["../src/runtime/create.ts"],"sourcesContent":["import type { Locale, PluralFunc, Translations } from '@i18n-micro/types'\nimport { mergeRouteTranslationsWithRoot } from '@i18n-micro/utils/parse-path'\nimport { createI18n as createVueI18n, type I18nPlugin } from '@i18n-micro/vue'\nimport type { App, Ref } from 'vue'\nimport { createVitePressRouterAdapter, type PathMethods, type VitePressRouterAdapter, type VitePressRouterLike } from '../router/adapter'\n\nexport type { PathMethods }\n\nexport interface CreateI18nOptions {\n locale: string\n fallbackLocale?: string\n locales?: Locale[]\n defaultLocale?: string\n messages?: Record<string, Translations>\n /**\n * Page-scoped dictionaries keyed by route name (`guide-demo`), then locale.\n * Loaded from `locales/pages/**` when using `withI18n`.\n */\n routeMessages?: Record<string, Record<string, Translations>>\n plural?: PluralFunc\n missingWarn?: boolean\n missingHandler?: (locale: string, key: string, routeName: string) => void\n /**\n * Sync i18n locale from the VitePress URL path on every navigation.\n * @default true\n */\n syncWithVitePress?: boolean\n /**\n * Map VitePress locale keys to i18n codes (`root` → default locale code).\n */\n localeKeyToCode?: Record<string, string>\n /**\n * VitePress `site.base`. Needed so SSG paths (`withBase`) and lang switcher\n * do not treat the base segment as content / double-prefix links.\n */\n base?: string\n}\n\nexport interface VitePressSiteDataLike {\n locales?: Record<string, { lang?: string; link?: string; label?: string }>\n}\n\nexport type CreateI18nResult = I18nPlugin &\n PathMethods & {\n /** Same as `.global` (VueI18n + path methods). */\n i18n: I18nPlugin['global'] & PathMethods\n enhanceApp: (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => void\n }\n\nfunction applyRouteMessages(\n plugin: I18nPlugin,\n root: Record<string, Translations> | undefined,\n routeMessages: Record<string, Record<string, Translations>> | undefined,\n): void {\n if (!routeMessages) return\n for (const [routeName, byLocale] of Object.entries(routeMessages)) {\n for (const [locale, translations] of Object.entries(byLocale)) {\n plugin.global.addRouteTranslations(locale, routeName, mergeRouteTranslationsWithRoot(root?.[locale], translations), false)\n }\n }\n}\n\n/**\n * Universal VitePress i18n: Vue plugin + path helpers + `enhanceApp` sync.\n * Path methods are the router adapter’s own functions (no wrapper layer).\n */\nexport function createI18n(options: CreateI18nOptions): CreateI18nResult {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = options.locales ?? []\n const syncWithVitePress = options.syncWithVitePress !== false\n\n const plugin = createVueI18n({\n locale: options.locale,\n fallbackLocale: options.fallbackLocale ?? defaultLocale,\n messages: options.messages,\n plural: options.plural,\n missingWarn: options.missingWarn,\n missingHandler: options.missingHandler,\n locales,\n defaultLocale,\n })\n\n applyRouteMessages(plugin, options.messages, options.routeMessages)\n\n const paths = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n const pathMethods: PathMethods = {\n localizePath: paths.localizePath,\n switchLocalePath: paths.switchLocalePath,\n getLocaleFromPath: paths.getLocaleFromPath,\n removeLocaleFromPath: paths.removeLocaleFromPath,\n routeNameFromPath: paths.routeNameFromPath,\n }\n plugin.global.extend(pathMethods)\n\n const pageRouteNames = new Set(Object.keys(options.routeMessages ?? {}))\n\n const byApp = new WeakMap<\n object,\n {\n adapter: VitePressRouterAdapter\n boundSyncHandler: ((to: string) => unknown) | null\n chainedPrevious: ((to: string) => unknown) | undefined\n }\n >()\n\n const enhanceApp = (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => {\n const { app, router } = ctx\n\n let state = byApp.get(app)\n if (!state) {\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n getPath: () => {\n const route = router.route\n return `${route.path}${route.query || ''}${route.hash || ''}`\n },\n go: (href, navOptions) => router.go(href, navOptions),\n })\n\n app.use(plugin)\n plugin.setRoutingStrategy(adapter)\n state = { adapter, boundSyncHandler: null, chainedPrevious: undefined }\n byApp.set(app, state)\n }\n\n if (!syncWithVitePress) return\n\n const { adapter } = state\n const sync = (path = router.route.path) => {\n const nextLocale = adapter.getLocaleFromPath(path)\n if (plugin.global.getLocale() !== nextLocale) {\n plugin.global.locale = nextLocale\n }\n const derived = adapter.routeNameFromPath(path)\n plugin.global.setRoute(pageRouteNames.has(derived) ? derived : 'index')\n }\n\n sync()\n\n const current = router.onAfterRouteChange\n if (current !== state.boundSyncHandler) {\n state.chainedPrevious = typeof current === 'function' ? current : undefined\n }\n state.boundSyncHandler = async (to: string) => {\n if (typeof state.chainedPrevious === 'function') {\n await state.chainedPrevious(to)\n }\n const path = to.startsWith('http')\n ? (() => {\n const url = new URL(to)\n return url.pathname + url.search + url.hash\n })()\n : to\n sync(path)\n }\n router.onAfterRouteChange = state.boundSyncHandler\n }\n\n return Object.assign(plugin, pathMethods, {\n get i18n() {\n return plugin.global as I18nPlugin['global'] & PathMethods\n },\n enhanceApp,\n }) as CreateI18nResult\n}\n"],"mappings":";;;;AAiDA,SAASG,EACP,GACA,GACA,GACM;CACN,IAAKC,GACL,KAAK,IAAM,CAACC,GAAWC,MAAa,OAAO,QAAQF,CAAa,GAC9D,KAAK,IAAM,CAACG,GA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C3D;KACA,KAAK,GAAM,MAAeC,EAAO,GAAGC,GAAMC,CAAU;IACtD,CAAC;IAKD,AAHAL,EAAI,IAAIR,CAAM,GACdA,EAAO,mBAAmBS,CAAO,GACjC,IAAQ;KAAE;KAAS,kBAAkB;KAAM,iBAAiB,KAAA;IAAU,GACtEJ,EAAM,IAAIG,GAAKD,CAAK;GACtB;GAEA,IAAI,CAACR,GAAmB;GAExB,IAAM,EAAE,eAAYQ,GACdO,KAAQ,IAAOH,EAAO,MAAM,SAAS;IACzC,IAAMI,IAAaN,EAAQ,kBAAkBO,CAAI;IACjD,AAAIhB,EAAO,OAAO,UAAU,MAAMe,MAChC,EAAO,OAAO,SAASA;IAEzB,IAAME,IAAUR,EAAQ,kBAAkBO,CAAI;IAC9C,EAAO,OAAO,SAASZ,EAAe,IAAIa,CAAO,IAAIA,IAAU,OAAO;GACxE;GAEA,EAAK;GAEL,IAAMC,IAAUP,EAAO;GAgBvB,AAfIO,MAAYX,EAAM,qBACpB,EAAM,kBAAkB,OAAOW,KAAY,aAAaA,IAAU,KAAA,IAEpE,EAAM,mBAAmB,OAAO,MAAe;IAC7C,AAAI,OAAOX,EAAM,mBAAoB,cACnC,MAAMA,EAAM,gBAAgBY,CAAE;IAEhC,IAAMH,IAAOG,EAAG,WAAW,MAAM,WACtB;KACL,IAAMC,IAAM,IAAI,IAAID,CAAE;KACtB,OAAOC,EAAI,WAAWA,EAAI,SAASA,EAAI;IACzC,EAAA,CAAG,IACHD;IACJ,EAAKH,CAAI;GACX,GACA,EAAO,qBAAqBT,EAAM;EACpC;CAOA,CAAC;AACH"}
@@ -1,2 +0,0 @@
1
- const e=require("./adapter-eYZZOC9d.cjs");let t=require("@i18n-micro/utils/parse-path"),n=require("@i18n-micro/vue");function r(e,n,r){if(r)for(let[i,a]of Object.entries(r))for(let[r,o]of Object.entries(a))e.global.addRouteTranslations(r,i,(0,t.mergeRouteTranslationsWithRoot)(n?.[r],o),!1)}function i(t){let i=t.defaultLocale||t.locale,a=t.locales??[],o=t.syncWithVitePress!==!1,s=(0,n.createI18n)({locale:t.locale,fallbackLocale:t.fallbackLocale??i,messages:t.messages,plural:t.plural,missingWarn:t.missingWarn,missingHandler:t.missingHandler,locales:a,defaultLocale:i});r(s,t.messages,t.routeMessages);let c=e.t({locales:a,defaultLocale:i,localeKeyToCode:t.localeKeyToCode,base:t.base}),l={localizePath:c.localizePath,switchLocalePath:c.switchLocalePath,getLocaleFromPath:c.getLocaleFromPath,removeLocaleFromPath:c.removeLocaleFromPath,routeNameFromPath:c.routeNameFromPath};s.global.extend(l);let u=new Set(Object.keys(t.routeMessages??{})),d=new WeakMap;return Object.assign(s,l,{get i18n(){return s.global},enhanceApp:n=>{let{app:r,router:c}=n,l=d.get(r);if(!l){let n=e.t({locales:a,defaultLocale:i,localeKeyToCode:t.localeKeyToCode,base:t.base,getPath:()=>{let e=c.route;return`${e.path}${e.query||``}${e.hash||``}`},go:(e,t)=>c.go(e,t)});r.use(s),s.setRoutingStrategy(n),l={adapter:n,boundSyncHandler:null,chainedPrevious:void 0},d.set(r,l)}if(!o)return;let{adapter:f}=l,p=(e=c.route.path)=>{let t=f.getLocaleFromPath(e);s.global.getLocale()!==t&&(s.global.locale=t);let n=f.routeNameFromPath(e);s.global.setRoute(u.has(n)?n:`index`)};p();let m=c.onAfterRouteChange;m!==l.boundSyncHandler&&(l.chainedPrevious=typeof m==`function`?m:void 0),l.boundSyncHandler=async e=>{typeof l.chainedPrevious==`function`&&await l.chainedPrevious(e);let t=e.startsWith(`http`)?(()=>{let t=new URL(e);return t.pathname+t.search+t.hash})():e;p(t)},c.onAfterRouteChange=l.boundSyncHandler}})}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
2
- //# sourceMappingURL=create-Cwu2djcO.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-Cwu2djcO.cjs","names":["mergeRouteTranslationsWithRoot","createVueI18n","createVitePressRouterAdapter","require_adapter","_i18n_micro_utils_parse_path","_i18n_micro_vue","applyRouteMessages","routeMessages","routeName","byLocale","locale","translations","plugin","root","createI18n","defaultLocale","options","locales","syncWithVitePress","paths","pathMethods","pageRouteNames","byApp","ctx","state","app","adapter","route","router","href","navOptions","sync","nextLocale","path","derived","current","to","url"],"sources":["../src/runtime/create.ts"],"sourcesContent":["import type { Locale, PluralFunc, Translations } from '@i18n-micro/types'\nimport { mergeRouteTranslationsWithRoot } from '@i18n-micro/utils/parse-path'\nimport { createI18n as createVueI18n, type I18nPlugin } from '@i18n-micro/vue'\nimport type { App, Ref } from 'vue'\nimport { createVitePressRouterAdapter, type PathMethods, type VitePressRouterAdapter, type VitePressRouterLike } from '../router/adapter'\n\nexport type { PathMethods }\n\nexport interface CreateI18nOptions {\n locale: string\n fallbackLocale?: string\n locales?: Locale[]\n defaultLocale?: string\n messages?: Record<string, Translations>\n /**\n * Page-scoped dictionaries keyed by route name (`guide-demo`), then locale.\n * Loaded from `locales/pages/**` when using `withI18n`.\n */\n routeMessages?: Record<string, Record<string, Translations>>\n plural?: PluralFunc\n missingWarn?: boolean\n missingHandler?: (locale: string, key: string, routeName: string) => void\n /**\n * Sync i18n locale from the VitePress URL path on every navigation.\n * @default true\n */\n syncWithVitePress?: boolean\n /**\n * Map VitePress locale keys to i18n codes (`root` → default locale code).\n */\n localeKeyToCode?: Record<string, string>\n /**\n * VitePress `site.base`. Needed so SSG paths (`withBase`) and lang switcher\n * do not treat the base segment as content / double-prefix links.\n */\n base?: string\n}\n\nexport interface VitePressSiteDataLike {\n locales?: Record<string, { lang?: string; link?: string; label?: string }>\n}\n\nexport type CreateI18nResult = I18nPlugin &\n PathMethods & {\n /** Same as `.global` (VueI18n + path methods). */\n i18n: I18nPlugin['global'] & PathMethods\n enhanceApp: (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => void\n }\n\nfunction applyRouteMessages(\n plugin: I18nPlugin,\n root: Record<string, Translations> | undefined,\n routeMessages: Record<string, Record<string, Translations>> | undefined,\n): void {\n if (!routeMessages) return\n for (const [routeName, byLocale] of Object.entries(routeMessages)) {\n for (const [locale, translations] of Object.entries(byLocale)) {\n plugin.global.addRouteTranslations(locale, routeName, mergeRouteTranslationsWithRoot(root?.[locale], translations), false)\n }\n }\n}\n\n/**\n * Universal VitePress i18n: Vue plugin + path helpers + `enhanceApp` sync.\n * Path methods are the router adapter’s own functions (no wrapper layer).\n */\nexport function createI18n(options: CreateI18nOptions): CreateI18nResult {\n const defaultLocale = options.defaultLocale || options.locale\n const locales = options.locales ?? []\n const syncWithVitePress = options.syncWithVitePress !== false\n\n const plugin = createVueI18n({\n locale: options.locale,\n fallbackLocale: options.fallbackLocale ?? defaultLocale,\n messages: options.messages,\n plural: options.plural,\n missingWarn: options.missingWarn,\n missingHandler: options.missingHandler,\n locales,\n defaultLocale,\n })\n\n applyRouteMessages(plugin, options.messages, options.routeMessages)\n\n const paths = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n })\n const pathMethods: PathMethods = {\n localizePath: paths.localizePath,\n switchLocalePath: paths.switchLocalePath,\n getLocaleFromPath: paths.getLocaleFromPath,\n removeLocaleFromPath: paths.removeLocaleFromPath,\n routeNameFromPath: paths.routeNameFromPath,\n }\n plugin.global.extend(pathMethods)\n\n const pageRouteNames = new Set(Object.keys(options.routeMessages ?? {}))\n\n const byApp = new WeakMap<\n object,\n {\n adapter: VitePressRouterAdapter\n boundSyncHandler: ((to: string) => unknown) | null\n chainedPrevious: ((to: string) => unknown) | undefined\n }\n >()\n\n const enhanceApp = (ctx: { app: App; router: VitePressRouterLike; siteData?: Ref<VitePressSiteDataLike> | VitePressSiteDataLike }) => {\n const { app, router } = ctx\n\n let state = byApp.get(app)\n if (!state) {\n const adapter = createVitePressRouterAdapter({\n locales,\n defaultLocale,\n localeKeyToCode: options.localeKeyToCode,\n base: options.base,\n getPath: () => {\n const route = router.route\n return `${route.path}${route.query || ''}${route.hash || ''}`\n },\n go: (href, navOptions) => router.go(href, navOptions),\n })\n\n app.use(plugin)\n plugin.setRoutingStrategy(adapter)\n state = { adapter, boundSyncHandler: null, chainedPrevious: undefined }\n byApp.set(app, state)\n }\n\n if (!syncWithVitePress) return\n\n const { adapter } = state\n const sync = (path = router.route.path) => {\n const nextLocale = adapter.getLocaleFromPath(path)\n if (plugin.global.getLocale() !== nextLocale) {\n plugin.global.locale = nextLocale\n }\n const derived = adapter.routeNameFromPath(path)\n plugin.global.setRoute(pageRouteNames.has(derived) ? derived : 'index')\n }\n\n sync()\n\n const current = router.onAfterRouteChange\n if (current !== state.boundSyncHandler) {\n state.chainedPrevious = typeof current === 'function' ? current : undefined\n }\n state.boundSyncHandler = async (to: string) => {\n if (typeof state.chainedPrevious === 'function') {\n await state.chainedPrevious(to)\n }\n const path = to.startsWith('http')\n ? (() => {\n const url = new URL(to)\n return url.pathname + url.search + url.hash\n })()\n : to\n sync(path)\n }\n router.onAfterRouteChange = state.boundSyncHandler\n }\n\n return Object.assign(plugin, pathMethods, {\n get i18n() {\n return plugin.global as I18nPlugin['global'] & PathMethods\n },\n enhanceApp,\n }) as CreateI18nResult\n}\n"],"mappings":"qHAiDA,SAASM,EACP,EACA,EACA,EACM,CACN,GAAKC,EACL,IAAK,GAAM,CAACC,EAAWC,KAAa,OAAO,QAAQF,CAAa,EAC9D,IAAK,GAAM,CAACG,EAAQC,KAAiB,OAAO,QAAQF,CAAQ,EAC1DG,EAAO,OAAO,qBAAqBF,EAAQF,GAAA,EAAWR,EAAAA,+BAAAA,CAA+Ba,IAAOH,GAASC,CAAY,EAAG,EAAK,CAG/H,CAMA,SAAgBG,EAAW,EAA8C,CACvE,IAAMC,EAAgBC,EAAQ,eAAiBA,EAAQ,OACjDC,EAAUD,EAAQ,SAAW,CAAC,EAC9BE,EAAoBF,EAAQ,oBAAsB,GAElDJ,GAAA,EAASX,EAAAA,WAAAA,CAAc,CAC3B,OAAQe,EAAQ,OAChB,eAAgBA,EAAQ,gBAA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ACzC,IAAMI,EAAaN,EAAQ,kBAAkBO,CAAI,EAC7CrB,EAAO,OAAO,UAAU,IAAMoB,IAChC,EAAO,OAAO,OAASA,GAEzB,IAAME,EAAUR,EAAQ,kBAAkBO,CAAI,EAC9CrB,EAAO,OAAO,SAASS,EAAe,IAAIa,CAAO,EAAIA,EAAU,OAAO,CACxE,EAEAH,EAAK,EAEL,IAAMI,EAAUP,EAAO,mBACnBO,IAAYX,EAAM,mBACpB,EAAM,gBAAkB,OAAOW,GAAY,WAAaA,EAAU,IAAA,IAEpE,EAAM,iBAAmB,KAAO,IAAe,CACzC,OAAOX,EAAM,iBAAoB,YACnC,MAAMA,EAAM,gBAAgBY,CAAE,EAEhC,IAAMH,EAAOG,EAAG,WAAW,MAAM,OACtB,CACL,IAAMC,EAAM,IAAI,IAAID,CAAE,EACtB,OAAOC,EAAI,SAAWA,EAAI,OAASA,EAAI,IACzC,EAAA,CAAG,EACHD,EACJL,EAAKE,CAAI,CACX,EACA,EAAO,mBAAqBT,EAAM,gBACpC,CAOA,CAAC,CACH"}
@@ -1,14 +0,0 @@
1
- import { Locale } from '@i18n-micro/types';
2
- /** Typecheck stub — real module is provided by `withI18n` Vite plugin. */
3
- export declare const config: {
4
- defaultLocale: string;
5
- fallbackLocale: string;
6
- locales: Locale[];
7
- localeCodes: string[];
8
- missingWarn: boolean;
9
- syncWithVitePress: boolean;
10
- translationDir: string;
11
- disablePageLocales: boolean;
12
- localeKeyToCode: Record<string, string>;
13
- base?: string;
14
- };
@@ -1,39 +0,0 @@
1
- import { PluralFunc, Translations } from '@i18n-micro/types';
2
- import { Theme } from 'vitepress';
3
- import { VirtualI18nConfig } from '../plugin/with-i18n';
4
- export interface DefineI18nThemeOptions {
5
- /**
6
- * Extra `enhanceApp` run after i18n is installed.
7
- */
8
- enhanceApp?: NonNullable<Theme['enhanceApp']>;
9
- /**
10
- * Overrides not serializable into `virtual:i18n-micro/config`.
11
- */
12
- plural?: PluralFunc;
13
- missingHandler?: (locale: string, key: string, routeName: string) => void;
14
- localeKeyToCode?: Record<string, string>;
15
- /**
16
- * Optional overrides (tests / advanced). Defaults come from `virtual:i18n-micro/*`
17
- * registered by `withI18n`.
18
- */
19
- config?: VirtualI18nConfig;
20
- messages?: Record<string, Translations>;
21
- routeMessages?: Record<string, Record<string, Translations>>;
22
- }
23
- /**
24
- * Zero-boilerplate theme wiring. Requires `withI18n(...)` in `.vitepress/config`
25
- * so virtual config + messages modules exist.
26
- *
27
- * Uses **static** `virtual:i18n-micro/*` imports so VitePress SSG can rewrite them.
28
- * Import this helper from `@i18n-micro/vitepress/theme` (not the root entry) so Node
29
- * config evaluation never loads virtual modules.
30
- *
31
- * @example
32
- * ```ts
33
- * import DefaultTheme from 'vitepress/theme'
34
- * import { defineI18nTheme } from '@i18n-micro/vitepress/theme'
35
- *
36
- * export default defineI18nTheme(DefaultTheme)
37
- * ```
38
- */
39
- export declare function defineI18nTheme<T extends Theme>(base: T, options?: DefineI18nThemeOptions): T;