@i18n-micro/astro 1.3.24 → 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 (75) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -64
  3. package/dist/auto-middleware.d.ts +1 -0
  4. package/dist/client/core.d.cts +86 -0
  5. package/dist/client/core.d.ts +71 -8
  6. package/dist/client/index.d.cts +2 -6
  7. package/dist/client/index.d.ts +2 -6
  8. package/dist/client/index.js +1 -6
  9. package/dist/client/preact.d.ts +12 -23
  10. package/dist/client/preact.js +13 -37
  11. package/dist/client/react.d.ts +14 -21
  12. package/dist/client/react.js +12 -37
  13. package/dist/client/svelte.d.ts +14 -14
  14. package/dist/client/svelte.js +17 -47
  15. package/dist/client/vue.d.ts +15 -15
  16. package/dist/client/vue.js +37 -2
  17. package/dist/composer.d.cts +16 -0
  18. package/dist/composer.d.ts +10 -30
  19. package/dist/core-CgrgdmGy.cjs +1 -0
  20. package/dist/core-DTAcn2yF.js +72 -0
  21. package/dist/env.d.ts +8 -2
  22. package/dist/index.cjs +11 -3
  23. package/dist/index.d.cts +10 -13
  24. package/dist/index.d.ts +10 -13
  25. package/dist/index.mjs +171 -482
  26. package/dist/integration.d.cts +26 -0
  27. package/dist/integration.d.ts +14 -15
  28. package/dist/middleware-BT3OA5YL.cjs +1 -0
  29. package/dist/middleware-Ch8E0iV_.js +257 -0
  30. package/dist/middleware.d.cts +34 -0
  31. package/dist/middleware.d.ts +17 -8
  32. package/dist/middleware.js +23 -0
  33. package/dist/node.d.ts +26 -0
  34. package/dist/node.js +22 -0
  35. package/dist/request.d.ts +69 -0
  36. package/dist/router/adapter.d.cts +9 -0
  37. package/dist/router/adapter.d.ts +5 -4
  38. package/dist/router/types.d.cts +66 -0
  39. package/dist/router/types.d.ts +3 -2
  40. package/dist/utils.d.cts +112 -0
  41. package/dist/utils.d.ts +39 -35
  42. package/dist/virtual.d.ts +21 -0
  43. package/package.json +28 -15
  44. package/src/auto-middleware.ts +26 -0
  45. package/src/client/core.ts +124 -59
  46. package/src/client/index.ts +2 -11
  47. package/src/client/preact.tsx +12 -127
  48. package/src/client/react.tsx +11 -123
  49. package/src/client/svelte.ts +6 -69
  50. package/src/client/vue.ts +22 -77
  51. package/src/components/i18n-link.astro +2 -59
  52. package/src/components/i18n-switcher.astro +46 -149
  53. package/src/components/i18n-t.astro +6 -54
  54. package/src/composer.ts +25 -115
  55. package/src/env.d.ts +7 -0
  56. package/src/index.ts +1 -6
  57. package/src/integration.ts +113 -52
  58. package/src/middleware.ts +174 -120
  59. package/src/node.ts +51 -0
  60. package/src/request.ts +177 -0
  61. package/src/router/adapter.ts +47 -149
  62. package/src/router/types.ts +3 -2
  63. package/src/utils.ts +149 -323
  64. package/src/virtual.d.ts +21 -0
  65. package/dist/components/index.d.cts +0 -0
  66. package/dist/components/index.d.ts +0 -0
  67. package/dist/core-DwkpOV-H.cjs +0 -1
  68. package/dist/core-VSnkGRWR.js +0 -28
  69. package/dist/load-translations.d.ts +0 -43
  70. package/dist/routing-context.d.ts +0 -4
  71. package/dist/vue-BNiEwZr2.cjs +0 -5
  72. package/dist/vue-CWHjIOiS.js +0 -1724
  73. package/src/components/index.ts +0 -11
  74. package/src/load-translations.ts +0 -106
  75. package/src/routing-context.ts +0 -23
@@ -1,27 +1,27 @@
1
- import { CleanTranslation, Params, TranslationKey } from '@i18n-micro/types';
2
- import { Ref } from 'vue';
3
- import { I18nClientProps } from '../utils';
4
- import { I18nState } from './core';
1
+ import { MaybeRefOrGetter, Ref } from 'vue';
2
+ import { I18nClientProps } from '../utils.js';
3
+ import { I18nState } from './core.js';
5
4
  /**
6
- * Initializes the i18n provider for a Vue island
7
- * Call in the island's root component
5
+ * Initializes the i18n provider for a Vue island. Call in the island's root component, with a
6
+ * getter (`() => props.i18n`) so an island kept by `transition:persist` follows its new props.
7
+ * `shallowRef`: translations are never edited in place, and deep tracking costs 11× on every `t`.
8
8
  */
9
- export declare function provideI18n(props: I18nClientProps): Ref<I18nState>;
9
+ export declare function provideI18n(props: MaybeRefOrGetter<I18nClientProps>): Ref<I18nState>;
10
10
  /**
11
11
  * Hook for using i18n in Vue components
12
12
  */
13
13
  export declare function useAstroI18n(): {
14
- t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation;
15
- ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string;
16
- tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string;
17
- tn: (value: number, options?: Intl.NumberFormatOptions) => string;
18
- td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
19
- tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string;
20
- has: (key: TranslationKey, routeName?: string) => boolean;
21
14
  locale: import('vue').WritableComputedRef<string, string>;
22
15
  fallbackLocale: import('vue').ComputedRef<string>;
23
16
  currentRoute: import('vue').WritableComputedRef<string, string>;
24
17
  setLocale: (locale: string) => void;
25
- setRoute: (routeName: string) => void;
18
+ setRoute: (currentRoute: string) => void;
19
+ t: (key: import('@i18n-micro/types').TranslationKey, params?: import('@i18n-micro/types').Params, defaultValue?: string | null, routeName?: string) => import('@i18n-micro/types').CleanTranslation;
20
+ ts: (key: import('@i18n-micro/types').TranslationKey, params?: import('@i18n-micro/types').Params, defaultValue?: string, routeName?: string) => string;
21
+ tc: (key: import('@i18n-micro/types').TranslationKey, count: number | import('@i18n-micro/types').Params, defaultValue?: string) => string;
22
+ tn: (value: number, options?: Intl.NumberFormatOptions) => string;
23
+ td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string;
24
+ tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string;
25
+ has: (key: import('@i18n-micro/types').TranslationKey, routeName?: string) => boolean;
26
26
  getRoute: () => string;
27
27
  };
@@ -1,2 +1,37 @@
1
- import { n as e, t } from "../vue-CWHjIOiS.js";
2
- export { t as provideI18n, e as useAstroI18n };
1
+ import { a as e, t } from "../core-DTAcn2yF.js";
2
+ import { computed as n, inject as r, provide as i, shallowRef as a, toValue as o, watch as s } from "vue";
3
+ // src/client/vue.ts
4
+ var c = Symbol("i18n-astro");
5
+ function l(e) {
6
+ let t = a(o(e));
7
+ return s(() => o(e), (e) => {
8
+ t.value = e;
9
+ }), i(c, t), t;
10
+ }
11
+ function u() {
12
+ let i = r(c);
13
+ if (!i) throw Error("useAstroI18n must be used within a component that calls provideI18n");
14
+ let a = (t) => {
15
+ i.value = e(i.value, t);
16
+ }, o = (e) => {
17
+ i.value = {
18
+ ...i.value,
19
+ currentRoute: e
20
+ };
21
+ };
22
+ return {
23
+ ...t(() => i.value),
24
+ locale: n({
25
+ get: () => i.value.locale,
26
+ set: a
27
+ }),
28
+ fallbackLocale: n(() => i.value.fallbackLocale),
29
+ currentRoute: n({
30
+ get: () => i.value.currentRoute,
31
+ set: o
32
+ }),
33
+ setLocale: a,
34
+ setRoute: o
35
+ };
36
+ }
37
+ export { l as provideI18n, u as useAstroI18n };
@@ -0,0 +1,16 @@
1
+ import { I18n, I18nOptions } from '@i18n-micro/runtime';
2
+ import { Translations } from '@i18n-micro/types';
3
+ export type AstroI18nOptions = I18nOptions;
4
+ /** The runtime instance, plus what Astro pages use on top: per-route reads and a reset that keeps `messages`. */
5
+ export declare class AstroI18n extends I18n {
6
+ private initialMessages;
7
+ private initialRouteMessages;
8
+ constructor(options: AstroI18nOptions);
9
+ /** Dictionaries loaded after the constructor that `clearCache` keeps too: a directory read at runtime. */
10
+ keepMessages(messages: Record<string, Translations>, routeMessages: Record<string, Record<string, Translations>>): void;
11
+ /** The `localeIso` option: what an island needs to plural in another locale. */
12
+ getLocaleIso(): Record<string, string>;
13
+ getRouteTranslations(locale: string, routeName: string): Translations | null;
14
+ mergeTranslations(locale: string, routeName: string, translations: Translations): void;
15
+ clearCache(): void;
16
+ }
@@ -1,36 +1,16 @@
1
- import { BaseI18n, DateTimeFormatsConfig, NumberFormatsConfig, TranslationStorage } from '@i18n-micro/core';
2
- import { PluralFunc, Translations } from '@i18n-micro/types';
3
- export interface AstroI18nOptions {
4
- locale: string;
5
- fallbackLocale?: string;
6
- messages?: Record<string, Translations>;
7
- plural?: PluralFunc;
8
- missingWarn?: boolean;
9
- missingHandler?: (locale: string, key: string, routeName: string) => void;
10
- numberFormats?: NumberFormatsConfig;
11
- datetimeFormats?: DateTimeFormatsConfig;
12
- _storage?: TranslationStorage;
13
- }
14
- export declare class AstroI18n extends BaseI18n {
15
- private _locale;
16
- private _fallbackLocale;
17
- private _currentRoute;
18
- readonly storage: TranslationStorage;
1
+ import { I18n, I18nOptions } from '@i18n-micro/runtime';
2
+ import { Translations } from '@i18n-micro/types';
3
+ export type AstroI18nOptions = I18nOptions;
4
+ /** The runtime instance, plus what Astro pages use on top: per-route reads and a reset that keeps `messages`. */
5
+ export declare class AstroI18n extends I18n {
19
6
  private initialMessages;
7
+ private initialRouteMessages;
20
8
  constructor(options: AstroI18nOptions);
21
- private cloneStorage;
22
- clone(newLocale?: string): AstroI18n;
23
- get locale(): string;
24
- set locale(val: string);
25
- get fallbackLocale(): string;
26
- set fallbackLocale(val: string);
27
- setRoute(routeName: string): void;
28
- getLocale(): string;
29
- getFallbackLocale(): string;
30
- getRoute(): string;
9
+ /** Dictionaries loaded after the constructor that `clearCache` keeps too: a directory read at runtime. */
10
+ keepMessages(messages: Record<string, Translations>, routeMessages: Record<string, Record<string, Translations>>): void;
11
+ /** The `localeIso` option: what an island needs to plural in another locale. */
12
+ getLocaleIso(): Record<string, string>;
31
13
  getRouteTranslations(locale: string, routeName: string): Translations | null;
32
- addTranslations(locale: string, translations: Translations, merge?: boolean): void;
33
- addRouteTranslations(locale: string, routeName: string, translations: Translations, merge?: boolean): void;
34
14
  mergeTranslations(locale: string, routeName: string, translations: Translations): void;
35
15
  clearCache(): void;
36
16
  }
@@ -0,0 +1 @@
1
+ let e=require("@i18n-micro/core");function t(t,n,r){let i=r||t.currentRoute,a=Object.prototype.hasOwnProperty.call(t.translations,i)?t.translations[i]:void 0;return(0,e.resolveTranslation)(a,n)??null}function n(n,r,i,a,o){if(!r)return``;let s=t(n,r,o)??(a||r);return typeof s==`object`?(0,e.convertible)(s):typeof s==`string`&&i?(0,e.interpolate)(s,i):s}function r(n,r,i,a){let{count:o,...s}=typeof i==`number`?{count:i}:i;return o==null?a??r:(0,e.defaultPlural)(r,Number(o),s,n.pluralLocale??n.locale,(r,i,a)=>{let o=t(n,r);return o===null?a===void 0?void 0:a||r:i&&typeof o==`string`?(0,e.interpolate)(o,i):o})??a??r}function i(e,n,r){return t(e,n,r)!==null}var a=(t,n)=>({...t,locale:n,pluralLocale:t.localeIso&&(0,e.ownValue)(t.localeIso,n)}),o=new e.FormatService,s=e=>e.pluralLocale??e.locale;function c(t){let a=(e,r,i,a)=>n(t(),e,r,i,a);return{t:a,ts:(t,n,r,i)=>(0,e.textOf)(a(t,n,r,i))??r??t,tc:(e,n,i)=>r(t(),e,n,i),tn:(e,n)=>o.formatNumber(e,s(t()),n),td:(e,n)=>o.formatDate(e,s(t()),n),tdr:(e,n)=>o.formatRelativeTime(e,s(t()),n),has:(e,n)=>i(t(),e,n),getRoute:()=>t().currentRoute}}function l(e){let{createContext:t,createElement:n,useCallback:r,useContext:i,useMemo:o,useState:s}=e,l=t(null);function u({children:e,value:t}){let[r,i]=s(t),[a,c]=s(t);a!==t&&(c(t),i(t));let u=o(()=>({state:r,setState:i}),[r]);return n(l.Provider,{value:u},e)}function d(){let e=i(l);if(!e)throw Error(`useAstroI18n must be used within an I18nProvider`);let{state:t,setState:n}=e,s=o(()=>c(()=>t),[t]),u=r(e=>n(t=>a(t,e)),[n]),d=r(e=>n(t=>({...t,currentRoute:e})),[n]);return{...s,locale:t.locale,fallbackLocale:t.fallbackLocale,currentRoute:t.currentRoute,setLocale:u,setRoute:d}}return{I18nProvider:u,useAstroI18n:d}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
@@ -0,0 +1,72 @@
1
+ import { FormatService as e, convertible as t, defaultPlural as n, interpolate as r, ownValue as i, resolveTranslation as a, textOf as o } from "@i18n-micro/core";
2
+ // src/client/core.ts
3
+ function s(e, t, n) {
4
+ let r = n || e.currentRoute, i = Object.prototype.hasOwnProperty.call(e.translations, r) ? e.translations[r] : void 0;
5
+ return a(i, t) ?? null;
6
+ }
7
+ function c(e, n, i, a, o) {
8
+ if (!n) return "";
9
+ let c = s(e, n, o) ?? (a || n);
10
+ return typeof c == "object" ? t(c) : typeof c == "string" && i ? r(c, i) : c;
11
+ }
12
+ function l(e, t, i, a) {
13
+ let { count: o, ...c } = typeof i == "number" ? { count: i } : i;
14
+ return o == null ? a ?? t : n(t, Number(o), c, e.pluralLocale ?? e.locale, (t, n, i) => {
15
+ let a = s(e, t);
16
+ return a === null ? i === void 0 ? void 0 : i || t : n && typeof a == "string" ? r(a, n) : a;
17
+ }) ?? a ?? t;
18
+ }
19
+ function u(e, t, n) {
20
+ return s(e, t, n) !== null;
21
+ }
22
+ var d = (e, t) => ({
23
+ ...e,
24
+ locale: t,
25
+ pluralLocale: e.localeIso && i(e.localeIso, t)
26
+ }), f = /*#__PURE__*/ new e(), p = (e) => e.pluralLocale ?? e.locale;
27
+ function m(e) {
28
+ let t = (t, n, r, i) => c(e(), t, n, r, i);
29
+ return {
30
+ t,
31
+ ts: (e, n, r, i) => o(t(e, n, r, i)) ?? r ?? e,
32
+ tc: (t, n, r) => l(e(), t, n, r),
33
+ tn: (t, n) => f.formatNumber(t, p(e()), n),
34
+ td: (t, n) => f.formatDate(t, p(e()), n),
35
+ tdr: (t, n) => f.formatRelativeTime(t, p(e()), n),
36
+ has: (t, n) => u(e(), t, n),
37
+ getRoute: () => e().currentRoute
38
+ };
39
+ }
40
+ function h(e) {
41
+ let { createContext: t, createElement: n, useCallback: r, useContext: i, useMemo: a, useState: o } = e, s = t(null);
42
+ function c({ children: e, value: t }) {
43
+ let [r, i] = o(t), [c, l] = o(t);
44
+ c !== t && (l(t), i(t));
45
+ let u = a(() => ({
46
+ state: r,
47
+ setState: i
48
+ }), [r]);
49
+ return n(s.Provider, { value: u }, e);
50
+ }
51
+ function l() {
52
+ let e = i(s);
53
+ if (!e) throw Error("useAstroI18n must be used within an I18nProvider");
54
+ let { state: t, setState: n } = e, o = a(() => m(() => t), [t]), c = r((e) => n((t) => d(t, e)), [n]), l = r((e) => n((t) => ({
55
+ ...t,
56
+ currentRoute: e
57
+ })), [n]);
58
+ return {
59
+ ...o,
60
+ locale: t.locale,
61
+ fallbackLocale: t.fallbackLocale,
62
+ currentRoute: t.currentRoute,
63
+ setLocale: c,
64
+ setRoute: l
65
+ };
66
+ }
67
+ return {
68
+ I18nProvider: c,
69
+ useAstroI18n: l
70
+ };
71
+ }
72
+ export { d as a, c as i, h as n, u as r, m as t };
package/dist/env.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { AstroI18n } from './composer';
1
+ import { AstroI18n } from './composer.js';
2
2
  import { Locale } from '@i18n-micro/types';
3
- import { I18nRoutingStrategy } from './router/types';
3
+ import { MiddlewareHandler } from 'astro';
4
+ import { I18nRoutingStrategy } from './router/types.js';
4
5
  declare global {
5
6
  namespace App {
6
7
  interface Locals {
@@ -8,8 +9,13 @@ declare global {
8
9
  locale: string
9
10
  defaultLocale: string
10
11
  locales: Locale[]
12
+ /** The page's URL: the original one after `Astro.rewrite`, the page's one in a server island. */
11
13
  currentUrl: URL
12
14
  routingStrategy?: I18nRoutingStrategy
15
+ /** Astro's `base`, no trailing slash. */
16
+ i18nBase?: string
17
+ /** The middleware that handled this request. */
18
+ i18nHandler?: MiddlewareHandler
13
19
  }
14
20
  }
15
21
  }
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@i18n-micro/core"),t=require("node:async_hooks"),n=require("node:fs"),r=require("node:path"),i=require("@i18n-micro/utils/parse-path"),a=require("@i18n-micro/utils/accept-language");var o=class t extends e.BaseI18n{constructor(e){let t=e._storage||{translations:new Map};if(super({storage:t,plural:e.plural,missingWarn:e.missingWarn,missingHandler:e.missingHandler,numberFormats:e.numberFormats,datetimeFormats:e.datetimeFormats}),this.initialMessages={},this.storage=t,this._locale=e.locale,this._fallbackLocale=e.fallbackLocale||e.locale,this._currentRoute=`index`,e.messages){this.initialMessages={...e.messages};for(let[t,n]of Object.entries(e.messages))this.helper.loadTranslations(t,n)}}cloneStorage(e){let t=new Map;for(let[n,r]of e.translations)t.set(n,{...r});return{translations:t}}clone(e){let n=this.cloneStorage(this.storage);return new t({locale:e||this._locale,fallbackLocale:this._fallbackLocale,plural:this.pluralFunc,missingWarn:this.missingWarn,missingHandler:this.missingHandler,numberFormats:this.formatter.getNumberFormats(),datetimeFormats:this.formatter.getDateTimeFormats(),_storage:n})}get locale(){return this._locale}set locale(e){this._locale=e}get fallbackLocale(){return this._fallbackLocale}set fallbackLocale(e){this._fallbackLocale=e}setRoute(e){this._currentRoute=e}getLocale(){return this._locale}getFallbackLocale(){return this._fallbackLocale}getRoute(){return this._currentRoute}getRouteTranslations(e,t){let n=`${e}:${t}`;return this.storage.translations.get(n)??null}addTranslations(e,t,n=!0){super.loadTranslationsCore(e,t,n)}addRouteTranslations(e,t,n,r=!0){super.loadRouteTranslationsCore(e,t,n,r)}mergeTranslations(e,t,n){this.helper.mergeTranslation(e,t,n,!0)}clearCache(){let e={...this.initialMessages};if(super.clearCache(),Object.keys(e).length>0)for(let[t,n]of Object.entries(e))this.helper.loadTranslations(t,n)}},s=null,c=new t.AsyncLocalStorage;function l(){let e=c.getStore();return e===void 0?s:e}function u(e){s=e}function d(e,t){return c.run(e,t)}function f(e){let{locale:t,fallbackLocale:n,translationDir:r,routingStrategy:i}=e;return u(i||null),{name:`@i18n-micro/astro`,hooks:{"astro:config:setup":i=>{let{updateConfig:a}=i,o=`virtual:i18n-micro/config`,s=`\0${o}`,c={defaultLocale:t,fallbackLocale:n||t,locales:e.locales||[],localeCodes:(e.locales||[]).map(e=>e.code),translationDir:r||null,autoDetect:e.autoDetect??!0,redirectToDefault:e.redirectToDefault??!1,localeCookie:e.localeCookie===null?null:e.localeCookie||`i18n-locale`,missingWarn:e.missingWarn??!1};a({vite:{plugins:[{name:`vite-plugin-i18n-micro-config`,resolveId(e){if(e===o)return s},load(e){if(e===s)return`export const config = ${JSON.stringify(c)}`}}]}})},"astro:config:done":e=>{let{injectTypes:t}=e;t({filename:`i18n-micro-env.d.ts`,content:`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./middleware-BT3OA5YL.cjs");let t=require("@i18n-micro/core"),n=require("@i18n-micro/utils/active-locales"),r=require("@i18n-micro/utils/app-path"),i=require("@i18n-micro/utils/locale-head");var a=[`messages`,`plural`,`missingHandler`,`routingStrategy`],o=`virtual:i18n-micro/config`,s=`virtual:i18n-micro/messages`,c=e=>`\0${e}`,l=`@i18n-micro/astro/node`;function u(e,t){let r=e.locales||[];return{defaultLocale:e.locale,fallbackLocale:e.fallbackLocale||e.locale,locales:r,localeCodes:(0,n.getEnabledLocaleCodes)(r),translationDir:e.translationDir||null,autoDetect:e.autoDetect??!0,redirectToDefault:e.redirectToDefault??!1,localeCookie:e.localeCookie===null?null:e.localeCookie||`i18n-locale`,missingWarn:e.missingWarn??!1,base:t===`/`?``:t}}function d(e,t){let n=`export const config = ${JSON.stringify(u(e,t.base))}`,i=[],a=async n=>{let{translationDir:r,disablePageLocales:a}=e;if(!r)return`export const messages = {"root":{},"routes":{}}`;let{readTranslationDir:o}=await import(l),{messages:s,files:c}=o({translationDir:r,rootDir:t.root,disablePageLocales:a});i=c;for(let e of c)n(e);return`export const messages = ${JSON.stringify(s)}`};return{name:`vite-plugin-i18n-micro-config`,resolveId(e){return e===o||e===s?c(e):void 0},load(e){return e===c(o)?n:e===c(s)?a(e=>this.addWatchFile(e)):void 0},configureServer(t){let n=e.translationDir&&`/${e.translationDir.replace(/^\.?\/+|\/+$/g,``)}/`;n&&t.watcher.on(`add`,e=>{e.endsWith(`.json`)&&(0,r.forwardSlashes)(e).includes(n)&&i[0]&&t.watcher.emit(`change`,i[0])})}}}function f(e,t){let r=(0,n.getEnabledLocaleCodes)(e.locales);return e.middleware!==!1||t.i18n||!r.includes(e.locale)?{}:{i18n:{locales:r,defaultLocale:e.locale,routing:`manual`}}}function p(e){let t=a.find(t=>e[t]!==void 0);if(t)throw Error(`[i18n-micro] i18nIntegration no longer takes "${t}": pass it to createI18n / createI18nMiddleware in src/middleware.ts`);return{name:`@i18n-micro/astro`,hooks:{"astro:config:setup":t=>{let{updateConfig:n,addMiddleware:r,config:i}=t;n({...f(e,i),vite:{ssr:{noExternal:[`@i18n-micro/astro`]},plugins:[d(e,i)]}}),e.middleware!==!1&&r({order:`pre`,entrypoint:`@i18n-micro/astro/middleware`})},"astro:config:done":e=>{let{injectTypes:t}=e;t({filename:`i18n-micro-env.d.ts`,content:`
2
2
  /// <reference types="@i18n-micro/astro/env" />
3
3
 
4
4
  declare module 'virtual:i18n-micro/config' {
@@ -11,7 +11,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require
11
11
  autoDetect: boolean;
12
12
  redirectToDefault: boolean;
13
13
  localeCookie: string | null;
14
- missingWarn: boolean | null;
14
+ missingWarn: boolean;
15
+ base: string;
15
16
  }
16
17
  }
17
- `})}}}}function p(e){return new o(e)}function m(e,t){if((0,n.existsSync)(e))for(let i of(0,n.readdirSync)(e)){let a=(0,r.join)(e,i);if((0,n.statSync)(a).isDirectory()){m(a,t);continue}i.endsWith(`.json`)&&t(a)}}function h(e){let{translationDir:t,rootDir:a=process.cwd(),disablePageLocales:o=!1}=e,s=(0,r.resolve)(a,t);if(!(0,n.existsSync)(s))return console.warn(`[i18n] Translation directory not found: ${s}`),{root:{},routes:{}};let c={root:{},routes:{}};return m(s,e=>{let t=(0,r.relative)(s,e).split(r.sep).join(`/`);try{let r=(0,n.readFileSync)(e,`utf-8`),a=JSON.parse(r);(0,i.storeLoadedTranslationFile)(c,t,a,o)}catch(t){console.error(`[i18n] Failed to load translation file: ${e}`,t)}}),c}function g(e,t){let{root:n,routes:r}=h(t);for(let[t,r]of Object.entries(n))e.addTranslations(t,r,!1);for(let[t,a]of Object.entries(r))for(let[r,o]of Object.entries(a))e.addRouteTranslations(r,t,(0,i.mergeRouteTranslationsWithRoot)(n[r],o),!1)}function _(e){let{i18n:t,defaultLocale:n,locales:r,localeObjects:i,autoDetect:a=!0,redirectToDefault:o=!1,routingStrategy:s}=e,c=s||l();return async(e,a)=>{if(e.locals.locale&&e.locals.i18n)return a();let o=e.url,s=o.pathname;if(!c){let c=t.clone(n),l=s===`/`||s===``?`index`:s.split(`/`).filter(Boolean).join(`-`);return c.setRoute(l),e.locals.i18n=c,e.locals.locale=n,e.locals.defaultLocale=n,e.locals.locales=i||r.map(e=>({code:e})),e.locals.currentUrl=o,a()}let l={...c,getCurrentPath:()=>s,getRoute:()=>({fullPath:o.pathname+o.search,query:Object.fromEntries(o.searchParams)})},u=s.split(`/`).filter(Boolean)[0],f=u!==void 0&&r.includes(u),p;p=f&&u?u:l.getLocaleFromPath?l.getLocaleFromPath(s,n,r):n;let m=t.clone(p),h=l.getRouteName?l.getRouteName(s,r):`index`;return m.setRoute(h),e.locals.i18n=m,e.locals.locale=p,e.locals.defaultLocale=n,e.locals.locales=i||r.map(e=>({code:e})),e.locals.currentUrl=o,e.locals.routingStrategy=l,d(l,()=>a())}}function v(e,t,n,r,i,o=`i18n-locale`,s){let c=s??l(),u=r;if(c?.getLocaleFromPath)u=c.getLocaleFromPath(e,r,i);else{let t=e.split(`/`).filter(Boolean)[0];t&&i.includes(t)&&(u=t)}if(o!==null&&u===r&&t.get(o)){let e=t.get(o)?.value;e&&i.includes(e)&&(u=e)}if(u===r)try{let e=(0,a.detectLocaleFromAcceptLanguage)(n.get(`accept-language`)??void 0,i);e&&(u=e)}catch{}return u}function y(e,t,n){let r=e.map(e=>e.code),i=(e,t=[])=>{let n=e.replace(/^\//,``).replace(/\/$/,``);if(!n)return`index`;let r=n.split(`/`).filter(Boolean),i=r[0];return i&&t.includes(i)&&r.shift(),r.length===0?`index`:r.join(`-`)},a=(e,t=`en`,n=[])=>{let r=e.split(`/`).filter(Boolean)[0];return r&&n.includes(r)?r:t},o=(e,t,n=[],r)=>{let i=e.split(`/`).filter(Boolean),a=i[0];return a&&n.includes(a)&&i.shift(),(t!==r||r===void 0)&&i.unshift(t),`/${i.join(`/`)}`},s=(e,t,n=[],r)=>{let i=(e.replace(/^\//,``).replace(/\/$/,``)||``).split(`/`).filter(Boolean),a=i[0];return a&&n.includes(a)&&i.shift(),(t!==r||r===void 0)&&i.unshift(t),`/${i.join(`/`)}`};return{getCurrentPath:()=>n?n().pathname:typeof window<`u`?window.location.pathname:`/`,getRouteName:i,getLocaleFromPath:a,switchLocalePath:o,localizePath:s,removeLocaleFromPath:(e,t=[])=>{let n=e.split(`/`).filter(Boolean),r=n[0];return r&&t.includes(r)&&n.shift(),`/${n.join(`/`)}`},resolvePath:(e,n)=>{let i=typeof e==`string`?e:e.path||`/`;return s(i,n,r,t)},getRoute:()=>{if(n){let e=n();return{fullPath:e.pathname+e.search,query:Object.fromEntries(e.searchParams)}}if(typeof window<`u`){let e=new URL(window.location.href);return{fullPath:e.pathname+e.search,query:Object.fromEntries(e.searchParams)}}return{fullPath:`/`,query:{}}},push:e=>{typeof window<`u`&&(window.location.href=e.path)},replace:e=>{typeof window<`u`&&window.location.replace(e.path)}}}function b(e){return e.iso?.trim()||String(e.code)}function x(e){let t=e.match(/^([A-Za-z]{2,3})(?:[-_](.+))?$/);return t?{language:t[1],region:t[2]}:{language:e}}function S(e,t={}){let{hreflangBaseLanguage:n=!1}=t;if(!n)return e.map(e=>{let t=String(e.code);return{hreflang:b(e),localeCode:t}});let r=new Map;for(let t of e){let e=String(t.code),n=b(t),{language:i,region:a}=x(n);i&&a&&!r.has(i)&&r.set(i,e),r.set(n,e)}let i=new Set,a=[];for(let t of e){let e=String(t.code),n=b(t),{language:o,region:s}=x(n);o&&s&&r.get(o)===e&&!i.has(o)&&(i.add(o),a.push({hreflang:o,localeCode:e})),i.has(n)||(i.add(n),a.push({hreflang:n,localeCode:e}))}return a}function C(e){let t=e.og?.trim();if(t)return t;let n=e.iso?.trim();if(!n)return null;let r=n.indexOf(`_`);if(r>0){let e=n.slice(0,r),t=n.slice(r+1);if(e.length>=2&&t.length===2)return`${e.toLowerCase()}_${t.toUpperCase()}`}let i=n.indexOf(`-`);if(i>0){let e=n.slice(0,i),t=n.slice(i+1);if(e.length>=2&&t.length===2&&/^[A-Za-z]{2}$/.test(t))return`${e.toLowerCase()}_${t.toUpperCase()}`}return null}function w(e,t={}){if(C(e)!==null||t.missingWarn===!1||process.env.NODE_ENV===`production`)return;let n=t.tag??`og:locale`,r=String(e.code??`unknown`),i=e.iso?`, iso: '${e.iso}'`:``;console.warn(`[i18n] Cannot derive ${n} for locale '${r}'${i}. Set locale.og (e.g. 'en_US') or use iso with a 2-letter region (e.g. 'en-US').`)}function T(e){let t=e.locals.i18n;if(!t)throw Error(`i18n instance not found. Make sure i18n middleware is configured.`);return t}function E(e){return e.locals.locale||`en`}function D(e){return e.locals.defaultLocale||`en`}function O(e){return e.locals.locales||[]}function k(e){return e.locals.routingStrategy||null}function A(e){let t=T(e),n=E(e),r=D(e),i=O(e),a=i.map(e=>e.code),o=k(e);return{locale:n,defaultLocale:r,locales:i,t:(e,n,r,i)=>t.t(e,n,r,i),ts:(e,n,r,i)=>t.ts(e,n,r,i),tc:(e,n,r)=>t.tc(e,n,r),tn:t.tn.bind(t),td:t.td.bind(t),tdr:t.tdr.bind(t),has:(e,n)=>t.has(e,n),getRoute:()=>t.getRoute(),getRouteName:t=>{let n=t||e.url.pathname;if(o?.getRouteName)return o.getRouteName(n,a);let r=n.replace(/^\//,``).replace(/\/$/,``);if(!r)return`index`;let i=r.split(`/`).filter(Boolean),s=i[0];return s&&a.includes(s)&&i.shift(),i.length===0?`index`:i.join(`-`)},getLocaleFromPath:t=>{let n=t||e.url.pathname;if(o?.getLocaleFromPath)return o.getLocaleFromPath(n,r,a);let i=n.split(`/`).filter(Boolean)[0];return i&&a.includes(i)?i:r},switchLocalePath:t=>{if(o?.switchLocalePath)return o.switchLocalePath(e.url.pathname,t,a,r);let n=e.url.pathname.split(`/`).filter(Boolean),i=n[0];return i&&a.includes(i)&&n.shift(),t!==r&&n.unshift(t),`/${n.join(`/`)}`},localizePath:(e,t)=>{if(o?.localizePath)return o.localizePath(e,t||n,a,r);let i=(e.replace(/^\//,``).replace(/\/$/,``)||``).split(`/`).filter(Boolean),s=i[0];return s&&a.includes(s)&&i.shift(),t&&t!==r&&i.unshift(t),`/${i.join(`/`)}`},getI18n:()=>t,getBasePath:t=>{let n=(t||e.url).pathname.split(`/`).filter(Boolean),r=n[0];return r&&a.includes(r)&&n.shift(),n.length>0?`/${n.join(`/`)}`:`/`},addTranslations:(e,n,r=!0)=>{t.addTranslations(e,n,r)},addRouteTranslations:(e,n,r,i=!0)=>{t.addRouteTranslations(e,n,r,i)},mergeTranslations:(e,n,r)=>{t.mergeTranslations(e,n,r)},clearCache:()=>{t.clearCache()}}}function j(e){let t=e.locals.currentUrl??e.url;return A(e).getBasePath(t)}function M(e){let{locale:t}=e.params,n=O(e).map(e=>e.code);if(!t||!n.includes(t))return new Response(null,{status:404});let r=e.locals.i18n;return r&&(r.locale=t,e.locals.locale=t),j(e)}function N(e,t={}){let{baseUrl:n=`/`,addDirAttribute:r=!0,addSeoAttributes:i=!0,hreflangBaseLanguage:a=!1}=t,o=E(e),s=D(e),c=O(e).filter(e=>!e.disabled),l=c.filter(e=>e.seo!==!1),u=c.find(e=>e.code===o);if(!u)return{htmlAttrs:{},link:[],meta:[]};let d=u.iso||o,f=C(u),p=u.dir||`auto`,m={htmlAttrs:{lang:d,...r?{dir:p}:{}},link:[],meta:[]};if(!i)return m;let h=`${n}${e.url.pathname}`;m.link.push({rel:`canonical`,href:h});let g=k(e),_=c.map(e=>e.code),v=new Map;for(let t of l){let r=e.url.pathname;if(g?.switchLocalePath)r=g.switchLocalePath(e.url.pathname,t.code,_,s);else{let n=e.url.pathname.split(`/`).filter(Boolean),i=n[0];i&&_.includes(i)&&n.shift(),t.code!==s&&n.unshift(t.code),r=`/${n.join(`/`)}`}v.set(String(t.code),`${n}${r}`)}for(let{hreflang:e,localeCode:t}of S(l,{hreflangBaseLanguage:a})){let n=v.get(t);n&&m.link.push({rel:`alternate`,href:n,hreflang:e})}if(c.find(e=>e.code===s)?.seo!==!1){let t=e.url.pathname;if(g?.switchLocalePath)t=g.switchLocalePath(e.url.pathname,s,_,s);else{let n=e.url.pathname.split(`/`).filter(Boolean),r=n[0];r&&_.includes(r)&&n.shift(),t=`/${n.join(`/`)}`}m.link.push({rel:`alternate`,href:`${n}${t}`,hreflang:`x-default`})}f?m.meta.push({property:`og:locale`,content:f}):w(u,{tag:`og:locale`}),m.meta.push({property:`og:url`,content:h});for(let e of l){if(e.code===o)continue;let t=C(e);if(!t){w(e,{tag:`og:locale:alternate`});continue}m.meta.push({property:`og:locale:alternate`,content:t})}return m}function P(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];i[t]||(i[t]={}),i=i[t]}let a=r[r.length-1];a!==void 0&&(i[a]=n)}function F(e,t){let n=T(e),r=E(e),i=D(e),a=n.getRoute(),o={};if(t&&t.length>0){let e={};for(let r of t){let t=n.t(r,void 0,void 0,a);t!=null&&t!==r&&P(e,r,t)}Object.keys(e).length>0&&(o[a]=e)}else{let e=n.getRouteTranslations(r,a);e&&(o[a]=e)}return{locale:r,fallbackLocale:i,currentRoute:a,translations:o}}exports.AstroI18n=o,Object.defineProperty(exports,"FormatService",{enumerable:!0,get:function(){return e.FormatService}}),exports.createAstroRouterAdapter=y,exports.createI18n=p,exports.createI18nMiddleware=_,Object.defineProperty(exports,"defaultPlural",{enumerable:!0,get:function(){return e.defaultPlural}}),exports.detectLocale=v,exports.getDefaultLocale=D,exports.getGlobalRoutingStrategy=l,exports.getI18n=T,exports.getI18nProps=F,exports.getLocale=E,exports.getLocaleRewritePath=j,exports.getLocales=O,exports.i18nIntegration=f,Object.defineProperty(exports,"interpolate",{enumerable:!0,get:function(){return e.interpolate}}),exports.loadTranslationsFromDir=h,exports.loadTranslationsIntoI18n=g,exports.prepareLocaleRewrite=M,exports.runWithRoutingStrategy=d,exports.setGlobalRoutingStrategy=u,exports.useI18n=A,exports.useLocaleHead=N;
18
+
19
+ declare module 'virtual:i18n-micro/messages' {
20
+ export const messages: {
21
+ root: Record<string, import('@i18n-micro/types').Translations>;
22
+ routes: Record<string, Record<string, import('@i18n-micro/types').Translations>>;
23
+ }
24
+ }
25
+ `})}}}}function m(t){return new e.o(t)}function h(e){let t=e.locals.i18n;if(!t)throw Error(`i18n instance not found. Make sure i18n middleware is configured.`);return t}function g(e){return e.locals.locale??h(e).getLocale()}function _(e){return e.locals.defaultLocale??h(e).getFallbackLocale()}function v(e){return e.locals.locales||[]}function y(t){let{locals:i}=t,a=i.i18nBase??``,o=_(t),s=v(t);return{base:a,defaultLocale:o,codes:(0,n.getEnabledLocaleCodes)(s),strategy:i.routingStrategy??e.r(s,o),path:(0,r.withoutAppBaseURL)((i.currentUrl??t.url).pathname,a)}}function b(t){let n=h(t),i=g(t),a=_(t),o=v(t),s=y(t),{strategy:c,codes:l,base:u,path:d}=s,f=e=>(0,r.withoutAppBaseURL)(e,u);return{locale:i,defaultLocale:a,locales:o,t:n.t.bind(n),ts:n.ts.bind(n),tc:n.tc.bind(n),tn:n.tn.bind(n),td:n.td.bind(n),tdr:n.tdr.bind(n),has:n.has.bind(n),getRoute:n.getRoute.bind(n),getRouteName:e=>e===void 0?n.getRoute():c.getRouteName(f(e),l),getLocaleFromPath:e=>c.getLocaleFromPath(e===void 0?d:f(e),a,l),switchLocalePath:t=>e.a(c.switchLocalePath(d,t,l,a),u),localizePath:(t,n)=>e.i(t,n||i,s),getI18n:()=>n,getBasePath:e=>c.removeLocaleFromPath(e?f(e.pathname):d,l),addTranslations:n.addTranslations.bind(n),addRouteTranslations:n.addRouteTranslations.bind(n),mergeTranslations:n.mergeTranslations.bind(n),clearCache:n.clearCache.bind(n)}}function x(e){return b(e).getBasePath(e.locals.currentUrl??e.url)}function S(e){let{locale:t}=e.params;if(!t||!(0,n.getEnabledLocaleCodes)(v(e)).includes(t))return new Response(null,{status:404});let r=e.locals.i18n;return r&&(r.locale=t,e.locals.locale=t),x(e)}function C(t,r={}){let{addDirAttribute:a,addSeoAttributes:o,hreflangBaseLanguage:s}=r,c=r.baseUrl??t.site?.origin??``,{base:l,defaultLocale:u,codes:d,strategy:f,path:p}=y(t),m=g(t),h=(0,n.getEnabledLocales)(v(t)),_=h.find(e=>e.code===m);if(!_)return{htmlAttrs:{},link:[],meta:[]};let b=t=>(0,i.joinBase)(c,e.a(f.switchLocalePath(p,t,d,u),l)),x=h.find(e=>e.code===u);return(0,i.buildLocaleHead)({locale:_,seoLocales:h.filter(e=>e.seo!==!1),hrefOf:b,canonical:(0,i.joinBase)(c,e.a(p,l)),xDefault:x&&x.seo!==!1?b(u):void 0,addDirAttribute:a,addSeoAttributes:o,hreflangBaseLanguage:s})}function w(e,n){let r={};for(let i of n){let n=(0,t.getByPath)(e,i);n!=null&&(r=(0,t.setTranslationAtKey)(r,i,n))}return r}var T=2e4,E=new WeakSet;function D(e){try{return JSON.stringify(e).length}catch{return 0}}function O(e){if((0,t.isProduction)()||E.has(e))return;E.add(e);let n=D(e);n>T&&console.warn(`[i18n-micro] getI18nProps() without keys puts ${n} bytes in every island's props: pass the keys the island uses.`)}function k(e,t){let n=h(e),r=n.getRoute(),i=n.resolveTranslations(r);t?.length||O(i);let a=n.getLocaleIso();return{locale:g(e),pluralLocale:n.pluralLocale(),...Object.keys(a).length>0&&{localeIso:a},fallbackLocale:n.getFallbackLocale(),currentRoute:r,translations:{[r]:t&&t.length>0?w(i,t):i}}}exports.AstroI18n=e.o,Object.defineProperty(exports,"FormatService",{enumerable:!0,get:function(){return t.FormatService}}),exports.createAstroRouterAdapter=e.r,exports.createI18n=m,exports.createI18nMiddleware=e.t,Object.defineProperty(exports,"defaultPlural",{enumerable:!0,get:function(){return t.defaultPlural}}),exports.detectLocale=e.n,exports.getDefaultLocale=_,exports.getI18n=h,exports.getI18nProps=k,exports.getLocale=g,exports.getLocaleRewritePath=x,exports.getLocales=v,exports.i18nIntegration=p,Object.defineProperty(exports,"interpolate",{enumerable:!0,get:function(){return t.interpolate}}),Object.defineProperty(exports,"localeIsoMap",{enumerable:!0,get:function(){return t.localeIsoMap}}),exports.prepareLocaleRewrite=S,exports.useI18n=b,exports.useLocaleHead=C;
package/dist/index.d.cts CHANGED
@@ -1,14 +1,11 @@
1
- export { defaultPlural, FormatService, interpolate } from '@i18n-micro/core';
1
+ export { defaultPlural, FormatService, interpolate, localeIsoMap } from '@i18n-micro/core';
2
2
  export type { CleanTranslation, Getter, Locale, LocaleCode, Params, PluralFunc, Translations } from '@i18n-micro/types';
3
- export { AstroI18n, type AstroI18nOptions } from './composer';
4
- export type { I18nIntegrationOptions } from './integration';
5
- export { createI18n, i18nIntegration } from './integration';
6
- export { getGlobalRoutingStrategy, runWithRoutingStrategy, setGlobalRoutingStrategy } from './routing-context';
7
- export type { LoadedTranslations, LoadTranslationsOptions } from './load-translations';
8
- export { loadTranslationsFromDir, loadTranslationsIntoI18n } from './load-translations';
9
- export type { I18nMiddlewareOptions } from './middleware';
10
- export { createI18nMiddleware, detectLocale } from './middleware';
11
- export { createAstroRouterAdapter } from './router/adapter';
12
- export type { I18nRoutingStrategy } from './router/types';
13
- export type { I18nClientProps, LocaleHeadOptions, LocaleHeadResult } from './utils';
14
- export { getDefaultLocale, getI18n, getI18nProps, getLocale, getLocaleRewritePath, getLocales, prepareLocaleRewrite, useI18n, useLocaleHead, } from './utils';
3
+ export { AstroI18n, type AstroI18nOptions } from './composer.cjs';
4
+ export type { I18nIntegrationOptions } from './integration.cjs';
5
+ export { createI18n, i18nIntegration } from './integration.cjs';
6
+ export type { I18nMiddlewareOptions } from './middleware.cjs';
7
+ export { createI18nMiddleware, detectLocale } from './middleware.cjs';
8
+ export { createAstroRouterAdapter } from './router/adapter.cjs';
9
+ export type { I18nRoutingStrategy } from './router/types.cjs';
10
+ export type { I18nClientProps, LocaleHeadOptions, LocaleHeadResult } from './utils.cjs';
11
+ export { getDefaultLocale, getI18n, getI18nProps, getLocale, getLocaleRewritePath, getLocales, prepareLocaleRewrite, useI18n, useLocaleHead, } from './utils.cjs';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,11 @@
1
- export { defaultPlural, FormatService, interpolate } from '@i18n-micro/core';
1
+ export { defaultPlural, FormatService, interpolate, localeIsoMap } from '@i18n-micro/core';
2
2
  export type { CleanTranslation, Getter, Locale, LocaleCode, Params, PluralFunc, Translations } from '@i18n-micro/types';
3
- export { AstroI18n, type AstroI18nOptions } from './composer';
4
- export type { I18nIntegrationOptions } from './integration';
5
- export { createI18n, i18nIntegration } from './integration';
6
- export { getGlobalRoutingStrategy, runWithRoutingStrategy, setGlobalRoutingStrategy } from './routing-context';
7
- export type { LoadedTranslations, LoadTranslationsOptions } from './load-translations';
8
- export { loadTranslationsFromDir, loadTranslationsIntoI18n } from './load-translations';
9
- export type { I18nMiddlewareOptions } from './middleware';
10
- export { createI18nMiddleware, detectLocale } from './middleware';
11
- export { createAstroRouterAdapter } from './router/adapter';
12
- export type { I18nRoutingStrategy } from './router/types';
13
- export type { I18nClientProps, LocaleHeadOptions, LocaleHeadResult } from './utils';
14
- export { getDefaultLocale, getI18n, getI18nProps, getLocale, getLocaleRewritePath, getLocales, prepareLocaleRewrite, useI18n, useLocaleHead, } from './utils';
3
+ export { AstroI18n, type AstroI18nOptions } from './composer.js';
4
+ export type { I18nIntegrationOptions } from './integration.js';
5
+ export { createI18n, i18nIntegration } from './integration.js';
6
+ export type { I18nMiddlewareOptions } from './middleware.js';
7
+ export { createI18nMiddleware, detectLocale } from './middleware.js';
8
+ export { createAstroRouterAdapter } from './router/adapter.js';
9
+ export type { I18nRoutingStrategy } from './router/types.js';
10
+ export type { I18nClientProps, LocaleHeadOptions, LocaleHeadResult } from './utils.js';
11
+ export { getDefaultLocale, getI18n, getI18nProps, getLocale, getLocaleRewritePath, getLocales, prepareLocaleRewrite, useI18n, useLocaleHead, } from './utils.js';