@astroscope/i18n 0.1.0 → 0.2.1

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 (188) hide show
  1. package/README.md +23 -1
  2. package/dist/{chunk-FAKBSLNW.js → chunk-7MSGHEST.js} +14 -7
  3. package/dist/{chunk-JJEDOJBR.js → chunk-EO4FUQXR.js} +49 -18
  4. package/dist/{chunk-QFAAGCP5.js → chunk-RHWEV4L2.js} +58 -1
  5. package/dist/client/directives/idle.d.ts +4 -1
  6. package/dist/client/directives/idle.js +13 -6
  7. package/dist/client/directives/load.d.ts +4 -1
  8. package/dist/client/directives/load.js +6 -6
  9. package/dist/client/directives/media.d.ts +4 -1
  10. package/dist/client/directives/media.js +16 -6
  11. package/dist/client/directives/only.d.ts +6 -1
  12. package/dist/client/directives/only.js +6 -6
  13. package/dist/client/directives/utils.d.ts +6 -5
  14. package/dist/client/directives/utils.js +3 -3
  15. package/dist/client/directives/visible.d.ts +4 -1
  16. package/dist/client/directives/visible.js +23 -6
  17. package/dist/client/t.d.ts +2 -2
  18. package/dist/extraction/index.d.ts +3 -3
  19. package/dist/extraction/index.js +1 -1
  20. package/dist/{i18n-BGfrSNM8.d.ts → i18n-mTHTcD8K.d.ts} +9 -2
  21. package/dist/index.d.ts +26 -3
  22. package/dist/index.js +6 -2
  23. package/dist/internal.d.ts +4 -4
  24. package/dist/internal.js +1 -1
  25. package/dist/server/t.d.ts +1 -1
  26. package/dist/server/t.js +1 -1
  27. package/dist/{types-BaaSiz9n.d.ts → types-BeDFfFIL.d.ts} +1 -1
  28. package/dist/{types-Bzp6KxsI.d.ts → types-DNRFj1XA.d.ts} +1 -0
  29. package/dist/{types-DsNK_9sI.d.ts → types-DTUho6gi.d.ts} +7 -1
  30. package/package.json +8 -7
  31. package/src/components/I18nScript.astro +2 -23
  32. package/dist/babel-plugin-FUTQRKLT.js +0 -121
  33. package/dist/chunk-22ZZFFC2.js +0 -159
  34. package/dist/chunk-2PSXD3JJ.js +0 -144
  35. package/dist/chunk-3VI62RLT.js +0 -176
  36. package/dist/chunk-4DAQPWXI.js +0 -36
  37. package/dist/chunk-4OGX6AF5.js +0 -10
  38. package/dist/chunk-4PHYKXO3.js +0 -227
  39. package/dist/chunk-4UBFISFY.js +0 -376
  40. package/dist/chunk-5DERF6DV.js +0 -266
  41. package/dist/chunk-5KGNHFTC.js +0 -344
  42. package/dist/chunk-5PP4D2VK.js +0 -23
  43. package/dist/chunk-6BW3PN23.js +0 -14
  44. package/dist/chunk-6ESQ4JQI.js +0 -263
  45. package/dist/chunk-A7MPXMOP.js +0 -202
  46. package/dist/chunk-AWZ2SQDW.js +0 -149
  47. package/dist/chunk-AYY2YIBQ.js +0 -52
  48. package/dist/chunk-BMNEJFTD.js +0 -56
  49. package/dist/chunk-BSXQGEUK.js +0 -16
  50. package/dist/chunk-BSYTJFGF.js +0 -21
  51. package/dist/chunk-BVPXEGTT.js +0 -12
  52. package/dist/chunk-C4DJYWF6.js +0 -193
  53. package/dist/chunk-C5EJYE2P.js +0 -245
  54. package/dist/chunk-CLNOQHMS.js +0 -254
  55. package/dist/chunk-E5MCIRSU.js +0 -144
  56. package/dist/chunk-E7ZJS7WX.js +0 -162
  57. package/dist/chunk-ESFGCYYH.js +0 -24
  58. package/dist/chunk-FHBVI3TL.js +0 -372
  59. package/dist/chunk-FI5KZ5IO.js +0 -17
  60. package/dist/chunk-H5R6YMOL.js +0 -233
  61. package/dist/chunk-H62K3FGA.js +0 -236
  62. package/dist/chunk-HDG2R6XT.js +0 -211
  63. package/dist/chunk-HGXU5QAK.js +0 -344
  64. package/dist/chunk-HHRMR3TM.js +0 -17
  65. package/dist/chunk-HS4HVBAD.js +0 -127
  66. package/dist/chunk-IPJWKKHJ.js +0 -324
  67. package/dist/chunk-ITTL4V7J.js +0 -24
  68. package/dist/chunk-IWUBCMOK.js +0 -128
  69. package/dist/chunk-JJBBY2GR.js +0 -14
  70. package/dist/chunk-JTUKXNIJ.js +0 -23
  71. package/dist/chunk-K7YULG4A.js +0 -14
  72. package/dist/chunk-KNONI6DP.js +0 -89
  73. package/dist/chunk-LMTEO22Y.js +0 -17
  74. package/dist/chunk-LRLZEX4D.js +0 -147
  75. package/dist/chunk-MFKPLUAN.js +0 -241
  76. package/dist/chunk-MIWXQOO3.js +0 -316
  77. package/dist/chunk-MJRTAWPR.js +0 -261
  78. package/dist/chunk-MZEPQCXX.js +0 -249
  79. package/dist/chunk-NHHTSFA7.js +0 -237
  80. package/dist/chunk-NTTXM7AG.js +0 -23
  81. package/dist/chunk-NZFAVJXR.js +0 -192
  82. package/dist/chunk-OFNFSDW3.js +0 -13
  83. package/dist/chunk-PG3XDNGF.js +0 -227
  84. package/dist/chunk-PVEVTPNK.js +0 -139
  85. package/dist/chunk-QAO4BXS4.js +0 -244
  86. package/dist/chunk-QCTULQQK.js +0 -34
  87. package/dist/chunk-QKND2KCA.js +0 -163
  88. package/dist/chunk-QZEGY6RJ.js +0 -151
  89. package/dist/chunk-RAE2L6FT.js +0 -193
  90. package/dist/chunk-S3ABJBU3.js +0 -255
  91. package/dist/chunk-SVDVCPCV.js +0 -236
  92. package/dist/chunk-T35ZUWTL.js +0 -153
  93. package/dist/chunk-T6WV5DW6.js +0 -156
  94. package/dist/chunk-TGUXVDA3.js +0 -82
  95. package/dist/chunk-TYMO7K3A.js +0 -173
  96. package/dist/chunk-V4RBFLQL.js +0 -23
  97. package/dist/chunk-V4XWJXXZ.js +0 -23
  98. package/dist/chunk-VQCY3OKK.js +0 -258
  99. package/dist/chunk-WLGOJPDJ.js +0 -15
  100. package/dist/chunk-WUEPDJIL.js +0 -259
  101. package/dist/chunk-X3L7WZLY.js +0 -254
  102. package/dist/chunk-XDD62ZM3.js +0 -255
  103. package/dist/chunk-XFXXEDRD.js +0 -36
  104. package/dist/chunk-XKYOR5UK.js +0 -8
  105. package/dist/chunk-Y26535SI.js +0 -239
  106. package/dist/chunk-Y3PQX5TX.js +0 -152
  107. package/dist/chunk-Y4BE2V6F.js +0 -347
  108. package/dist/chunk-Z4IZYDIA.js +0 -24
  109. package/dist/chunk-Z52G4CYY.js +0 -14
  110. package/dist/chunk-ZGLUYWVM.js +0 -128
  111. package/dist/client/import-with-i18n.d.ts +0 -16
  112. package/dist/client/import-with-i18n.js +0 -8
  113. package/dist/client-directives/idle.d.ts +0 -9
  114. package/dist/client-directives/idle.js +0 -15
  115. package/dist/client-directives/load.d.ts +0 -9
  116. package/dist/client-directives/load.js +0 -15
  117. package/dist/client-directives/media.d.ts +0 -9
  118. package/dist/client-directives/media.js +0 -15
  119. package/dist/client-directives/only.d.ts +0 -9
  120. package/dist/client-directives/only.js +0 -15
  121. package/dist/client-directives/utils.d.ts +0 -9
  122. package/dist/client-directives/utils.js +0 -7
  123. package/dist/client-directives/visible.d.ts +0 -9
  124. package/dist/client-directives/visible.js +0 -15
  125. package/dist/i18n-3cZHoHwP.d.ts +0 -86
  126. package/dist/i18n-BHU81LMA.d.ts +0 -55
  127. package/dist/i18n-BagoeH4_.d.ts +0 -62
  128. package/dist/i18n-BeL84090.d.ts +0 -77
  129. package/dist/i18n-BeRWDfHi.d.ts +0 -55
  130. package/dist/i18n-Bfs2PVcf.d.ts +0 -79
  131. package/dist/i18n-BrL7p3aN.d.ts +0 -99
  132. package/dist/i18n-CNQNCFU0.d.ts +0 -55
  133. package/dist/i18n-CX_uU8V2.d.ts +0 -80
  134. package/dist/i18n-Cr1QZCwe.d.ts +0 -64
  135. package/dist/i18n-CzTRxGeX.d.ts +0 -80
  136. package/dist/i18n-DUOFiC7g.d.ts +0 -77
  137. package/dist/i18n-DcF47BHS.d.ts +0 -77
  138. package/dist/i18n-DifWvtaO.d.ts +0 -60
  139. package/dist/i18n-DumSqX1t.d.ts +0 -55
  140. package/dist/i18n-fWTJw12h.d.ts +0 -80
  141. package/dist/import-with-i18n.d.ts +0 -23
  142. package/dist/import-with-i18n.js +0 -7
  143. package/dist/init.d.ts +0 -2
  144. package/dist/init.js +0 -8
  145. package/dist/middleware-entrypoint-C0Drh9E_.d.ts +0 -29
  146. package/dist/middleware-entrypoint-mEl66IUy.d.ts +0 -29
  147. package/dist/middleware-entrypoint.d.ts +0 -5
  148. package/dist/middleware-entrypoint.js +0 -30
  149. package/dist/server/middleware-entrypoint.d.ts +0 -2
  150. package/dist/server/middleware-entrypoint.js +0 -28
  151. package/dist/t-BY_C9lZ1.d.ts +0 -30
  152. package/dist/t-CG3yDiEa.d.ts +0 -30
  153. package/dist/t-CHsBfrPr.d.ts +0 -30
  154. package/dist/t-DQpXaDhP.d.ts +0 -30
  155. package/dist/t.client.d.ts +0 -11
  156. package/dist/t.client.js +0 -35
  157. package/dist/t.server.d.ts +0 -22
  158. package/dist/t.server.js +0 -12
  159. package/dist/types-8uKCwFda.d.ts +0 -24
  160. package/dist/types-BC6K-pID.d.ts +0 -110
  161. package/dist/types-BUV7BZML.d.ts +0 -55
  162. package/dist/types-BWGB322F.d.ts +0 -46
  163. package/dist/types-B_-RxW4A.d.ts +0 -7
  164. package/dist/types-Bgl2V5xo.d.ts +0 -102
  165. package/dist/types-BwhB6IT4.d.ts +0 -111
  166. package/dist/types-C6rOJFY2.d.ts +0 -24
  167. package/dist/types-C7lD-Woj.d.ts +0 -50
  168. package/dist/types-CLWZeQhD.d.ts +0 -54
  169. package/dist/types-COXt613w.d.ts +0 -19
  170. package/dist/types-CUlkbl9-.d.ts +0 -50
  171. package/dist/types-CVv7GGPj.d.ts +0 -46
  172. package/dist/types-CiIDN2sW.d.ts +0 -64
  173. package/dist/types-Cr86qjYl.d.ts +0 -58
  174. package/dist/types-CxnObiEO.d.ts +0 -7
  175. package/dist/types-D44mFUjA.d.ts +0 -97
  176. package/dist/types-D85m9UTC.d.ts +0 -137
  177. package/dist/types-DWhsmSPP.d.ts +0 -102
  178. package/dist/types-DdprXGJ1.d.ts +0 -46
  179. package/dist/types-DhVJ2ZIo.d.ts +0 -43
  180. package/dist/types-DnbOuM1L.d.ts +0 -7
  181. package/dist/types-DvWBr9Xp.d.ts +0 -17
  182. package/dist/types-DwkIalh6.d.ts +0 -24
  183. package/dist/types-OYRgjtE_.d.ts +0 -110
  184. package/dist/types-SV8S05GX.d.ts +0 -7
  185. package/dist/types-TYn9WnxY.d.ts +0 -46
  186. package/dist/types-aXCBbdhq.d.ts +0 -55
  187. package/dist/types-gn4aNKGx.d.ts +0 -54
  188. package/dist/types-nippsMkm.d.ts +0 -54
@@ -1,64 +0,0 @@
1
- import { C as ChunkManifest, a as ExtractedKey, E as ExtractionManifest } from './types-C6rOJFY2.js';
2
- import { a as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-CLWZeQhD.js';
3
-
4
- /**
5
- * Fallback behavior when translation is missing
6
- */
7
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
8
- /**
9
- * Request-scoped i18n context
10
- */
11
- type I18nContext = {
12
- locale: string;
13
- translations: CompiledTranslations;
14
- fallback: FallbackBehavior;
15
- };
16
-
17
- type I18nConfig = {
18
- locales: string[];
19
- defaultLocale?: string | undefined;
20
- fallback?: FallbackBehavior | undefined;
21
- };
22
- type NormalizedConfig = {
23
- locales: string[];
24
- defaultLocale: string;
25
- fallback: FallbackBehavior;
26
- };
27
- declare class I18nSingleton {
28
- private config;
29
- private rawCache;
30
- private compiledCache;
31
- private hashCache;
32
- private manifest;
33
- configure(config: I18nConfig): void;
34
- isConfigured(): boolean;
35
- getConfig(): NormalizedConfig;
36
- setTranslations(locale: string, raw: RawTranslations): void;
37
- getTranslations(locale: string): RawTranslations;
38
- getCompiledTranslations(locale: string): CompiledTranslations;
39
- getChunkManifest(): ChunkManifest;
40
- /**
41
- * Get extracted translation keys with metadata.
42
- * Use this to populate your translation provider with keys extracted from the codebase.
43
- */
44
- getExtractedKeys(): ExtractedKey[];
45
- /**
46
- * Get the full extraction manifest (keys + chunks).
47
- */
48
- getExtractionManifest(): ExtractionManifest;
49
- /**
50
- * Set the extraction manifest (called by init module).
51
- * @internal
52
- */
53
- setManifest(manifest: ExtractionManifest): void;
54
- getHashes(locale: string): Record<string, string>;
55
- /**
56
- * Clear translations for specified locale(s).
57
- * @param locales - Locale(s) to clear, or all if not specified
58
- */
59
- clear(locales?: string | string[] | undefined): void;
60
- private resolveLocales;
61
- }
62
- declare const i18n: I18nSingleton;
63
-
64
- export { type FallbackBehavior as F, type I18nContext as I, type I18nConfig as a, i18n as i };
@@ -1,80 +0,0 @@
1
- import { T as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-gn4aNKGx.js';
2
-
3
- /**
4
- * Extracted metadata for a single translation key
5
- */
6
- type ExtractedKey = {
7
- key: string;
8
- meta: TranslationMeta;
9
- file: string;
10
- line: number;
11
- };
12
- /**
13
- * Chunk-to-keys mapping produced by Vite plugin
14
- */
15
- type ChunkManifest = Record<string, string[]>;
16
- /**
17
- * Full extraction manifest
18
- */
19
- type ExtractionManifest = {
20
- keys: ExtractedKey[];
21
- chunks: ChunkManifest;
22
- };
23
-
24
- /**
25
- * Fallback behavior when translation is missing
26
- */
27
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
28
- /**
29
- * Request-scoped i18n context
30
- */
31
- type I18nContext = {
32
- locale: string;
33
- translations: CompiledTranslations;
34
- fallback: FallbackBehavior;
35
- };
36
-
37
- type I18nConfig = {
38
- locales: string[];
39
- defaultLocale?: string | undefined;
40
- fallback?: FallbackBehavior | undefined;
41
- };
42
- type NormalizedConfig = {
43
- locales: string[];
44
- defaultLocale: string;
45
- fallback: FallbackBehavior;
46
- };
47
- declare class I18nSingleton {
48
- private config;
49
- private rawCache;
50
- private compiledCache;
51
- private hashCache;
52
- configure(config: I18nConfig): void;
53
- isConfigured(): boolean;
54
- getConfig(): NormalizedConfig;
55
- setTranslations(locale: string, raw: RawTranslations): void;
56
- getTranslations(locale: string): RawTranslations;
57
- getCompiledTranslations(locale: string): CompiledTranslations;
58
- getChunkManifest(): ChunkManifest;
59
- /**
60
- * Get extracted translation keys with metadata.
61
- * Use this to populate your translation provider with keys extracted from the codebase.
62
- */
63
- getExtractedKeys(): ExtractedKey[];
64
- /**
65
- * Get the full extraction manifest (keys + chunks).
66
- * In dev mode, keys are available live but chunks are empty.
67
- * In build mode, both keys and chunk mappings are populated.
68
- */
69
- getExtractionManifest(): ExtractionManifest;
70
- getHashes(locale: string): Record<string, string>;
71
- /**
72
- * Clear translations for specified locale(s).
73
- * @param locales - Locale(s) to clear, or all if not specified
74
- */
75
- clear(locales?: string | string[] | undefined): void;
76
- private resolveLocales;
77
- }
78
- declare const i18n: I18nSingleton;
79
-
80
- export { type ExtractedKey as E, type FallbackBehavior as F, type I18nConfig as I, type ExtractionManifest as a, type I18nContext as b, i18n as i };
@@ -1,77 +0,0 @@
1
- import { T as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-nippsMkm.js';
2
-
3
- /**
4
- * Extracted metadata for a single translation key
5
- */
6
- type ExtractedKey = {
7
- key: string;
8
- meta: TranslationMeta;
9
- file: string;
10
- line: number;
11
- };
12
- /**
13
- * Chunk-to-keys mapping produced by Vite plugin
14
- */
15
- type ChunkManifest = Record<string, string[]>;
16
- /**
17
- * Full extraction manifest
18
- */
19
- type ExtractionManifest = {
20
- keys: ExtractedKey[];
21
- chunks: ChunkManifest;
22
- };
23
-
24
- /**
25
- * Fallback behavior when translation is missing
26
- */
27
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
28
- /**
29
- * Request-scoped i18n context
30
- */
31
- type I18nContext = {
32
- locale: string;
33
- translations: CompiledTranslations;
34
- fallback: FallbackBehavior;
35
- meta: Record<string, TranslationMeta>;
36
- };
37
-
38
- type I18nConfig = {
39
- locales: string[];
40
- defaultLocale?: string | undefined;
41
- fallback?: FallbackBehavior | undefined;
42
- };
43
- declare class I18nSingleton {
44
- private config;
45
- private rawCache;
46
- private compiledCache;
47
- private extractionManifest;
48
- private hashCache;
49
- configure(config: I18nConfig): void;
50
- getConfig(): I18nConfig | null;
51
- getDefaultLocale(): string | undefined;
52
- getFallbackBehavior(): FallbackBehavior;
53
- setTranslations(locale: string, raw: RawTranslations): void;
54
- getTranslations(locale: string): RawTranslations;
55
- getCompiledTranslations(locale: string): CompiledTranslations;
56
- getChunkManifest(): ChunkManifest;
57
- /**
58
- * Get extracted translation keys with metadata.
59
- * Use this to populate your CMS with keys extracted from the codebase.
60
- */
61
- getExtractedKeys(): ExtractedKey[] | null;
62
- /**
63
- * Get the full extraction manifest (keys + chunks).
64
- * Returns null in dev mode (manifest doesn't exist).
65
- */
66
- getExtractionManifest(): ExtractionManifest | null;
67
- getHashes(locale: string): Record<string, string>;
68
- /**
69
- * Clear translations for specified locale(s).
70
- * @param locales - Locale(s) to clear, or all if not specified
71
- */
72
- clear(locales?: string | string[] | undefined): void;
73
- private resolveLocales;
74
- }
75
- declare const i18n: I18nSingleton;
76
-
77
- export { type ExtractedKey as E, type FallbackBehavior as F, type I18nConfig as I, type ExtractionManifest as a, type I18nContext as b, i18n as i };
@@ -1,77 +0,0 @@
1
- import { T as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-nippsMkm.js';
2
-
3
- /**
4
- * Extracted metadata for a single translation key
5
- */
6
- type ExtractedKey = {
7
- key: string;
8
- meta: TranslationMeta;
9
- file: string;
10
- line: number;
11
- };
12
- /**
13
- * Chunk-to-keys mapping produced by Vite plugin
14
- */
15
- type ChunkManifest = Record<string, string[]>;
16
- /**
17
- * Full extraction manifest
18
- */
19
- type ExtractionManifest = {
20
- keys: ExtractedKey[];
21
- chunks: ChunkManifest;
22
- };
23
-
24
- /**
25
- * Fallback behavior when translation is missing
26
- */
27
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
28
- /**
29
- * Request-scoped i18n context
30
- */
31
- type I18nContext = {
32
- locale: string;
33
- translations: CompiledTranslations;
34
- fallback: FallbackBehavior;
35
- };
36
-
37
- type I18nConfig = {
38
- locales: string[];
39
- defaultLocale?: string | undefined;
40
- fallback?: FallbackBehavior | undefined;
41
- };
42
- declare class I18nSingleton {
43
- private config;
44
- private rawCache;
45
- private compiledCache;
46
- private extractionManifest;
47
- private hashCache;
48
- configure(config: I18nConfig): void;
49
- isConfigured(): boolean;
50
- getConfig(): I18nConfig;
51
- getDefaultLocale(): string;
52
- getFallbackBehavior(): FallbackBehavior;
53
- setTranslations(locale: string, raw: RawTranslations): void;
54
- getTranslations(locale: string): RawTranslations;
55
- getCompiledTranslations(locale: string): CompiledTranslations;
56
- getChunkManifest(): ChunkManifest;
57
- /**
58
- * Get extracted translation keys with metadata.
59
- * Use this to populate your CMS with keys extracted from the codebase.
60
- */
61
- getExtractedKeys(): ExtractedKey[] | null;
62
- /**
63
- * Get the full extraction manifest (keys + chunks).
64
- * Returns null in dev mode (manifest doesn't exist).
65
- */
66
- getExtractionManifest(): ExtractionManifest | null;
67
- getHashes(locale: string): Record<string, string>;
68
- /**
69
- * Clear translations for specified locale(s).
70
- * @param locales - Locale(s) to clear, or all if not specified
71
- */
72
- clear(locales?: string | string[] | undefined): void;
73
- private resolveLocales;
74
- }
75
- declare const i18n: I18nSingleton;
76
-
77
- export { type ExtractedKey as E, type FallbackBehavior as F, type I18nConfig as I, type ExtractionManifest as a, type I18nContext as b, i18n as i };
@@ -1,60 +0,0 @@
1
- import { E as ExtractionManifest } from './types-C6rOJFY2.js';
2
- import { a as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-CLWZeQhD.js';
3
-
4
- /**
5
- * Fallback behavior when translation is missing
6
- */
7
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
8
- /**
9
- * Request-scoped i18n context
10
- */
11
- type I18nContext = {
12
- locale: string;
13
- translations: CompiledTranslations;
14
- fallback: FallbackBehavior;
15
- };
16
-
17
- type I18nConfig = {
18
- locales: string[];
19
- defaultLocale?: string | undefined;
20
- fallback?: FallbackBehavior | undefined;
21
- };
22
- type NormalizedConfig = {
23
- locales: string[];
24
- defaultLocale: string;
25
- fallback: FallbackBehavior;
26
- };
27
- declare class I18nSingleton {
28
- private config;
29
- private rawCache;
30
- private compiledCache;
31
- private hashCache;
32
- private manifest;
33
- configure(config: I18nConfig): void;
34
- isConfigured(): boolean;
35
- getConfig(): NormalizedConfig;
36
- setTranslations(locale: string, raw: RawTranslations): void;
37
- getTranslations(locale: string): RawTranslations;
38
- getCompiledTranslations(locale: string): CompiledTranslations;
39
- /**
40
- * Get the extraction manifest (keys + chunks).
41
- * - keys: translation keys extracted from codebase with metadata
42
- * - chunks: mapping of chunk names to their translation keys
43
- */
44
- getManifest(): ExtractionManifest;
45
- /**
46
- * Set the extraction manifest (called by init module).
47
- * @internal
48
- */
49
- setManifest(manifest: ExtractionManifest): void;
50
- getHashes(locale: string): Record<string, string>;
51
- /**
52
- * Clear translations for specified locale(s).
53
- * @param locales - Locale(s) to clear, or all if not specified
54
- */
55
- clear(locales?: string | string[] | undefined): void;
56
- private resolveLocales;
57
- }
58
- declare const i18n: I18nSingleton;
59
-
60
- export { type FallbackBehavior as F, type I18nContext as I, type I18nConfig as a, i18n as i };
@@ -1,55 +0,0 @@
1
- import { a as ExtractionManifest } from './types-DwkIalh6.js';
2
- import { T as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-gn4aNKGx.js';
3
-
4
- /**
5
- * Fallback behavior when translation is missing
6
- */
7
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
8
- /**
9
- * Request-scoped i18n context
10
- */
11
- type I18nContext = {
12
- locale: string;
13
- translations: CompiledTranslations;
14
- fallback: FallbackBehavior;
15
- };
16
-
17
- type I18nConfig = {
18
- locales: string[];
19
- defaultLocale?: string | undefined;
20
- fallback?: FallbackBehavior | undefined;
21
- };
22
- type NormalizedConfig = {
23
- locales: string[];
24
- defaultLocale: string;
25
- fallback: FallbackBehavior;
26
- };
27
- declare class I18nSingleton {
28
- private config;
29
- private rawCache;
30
- private compiledCache;
31
- private hashCache;
32
- private manifestGetter;
33
- configure(config: I18nConfig): void;
34
- isConfigured(): boolean;
35
- getConfig(): NormalizedConfig;
36
- setTranslations(locale: string, raw: RawTranslations): void;
37
- getTranslations(locale: string): RawTranslations;
38
- getCompiledTranslations(locale: string): CompiledTranslations;
39
- /**
40
- * Get the extraction manifest (keys + chunks).
41
- * - keys: translation keys extracted from codebase with metadata
42
- * - chunks: mapping of chunk names to their translation keys
43
- */
44
- getManifest(): ExtractionManifest;
45
- getHashes(locale: string): Record<string, string>;
46
- /**
47
- * Clear translations for specified locale(s).
48
- * @param locales - Locale(s) to clear, or all if not specified
49
- */
50
- clear(locales?: string | string[] | undefined): void;
51
- private resolveLocales;
52
- }
53
- declare const i18n: I18nSingleton;
54
-
55
- export { type FallbackBehavior as F, type I18nConfig as I, type I18nContext as a, i18n as i };
@@ -1,80 +0,0 @@
1
- import { T as TranslationMeta, C as CompiledTranslations, R as RawTranslations } from './types-nippsMkm.js';
2
-
3
- /**
4
- * Extracted metadata for a single translation key
5
- */
6
- type ExtractedKey = {
7
- key: string;
8
- meta: TranslationMeta;
9
- file: string;
10
- line: number;
11
- };
12
- /**
13
- * Chunk-to-keys mapping produced by Vite plugin
14
- */
15
- type ChunkManifest = Record<string, string[]>;
16
- /**
17
- * Full extraction manifest
18
- */
19
- type ExtractionManifest = {
20
- keys: ExtractedKey[];
21
- chunks: ChunkManifest;
22
- };
23
-
24
- /**
25
- * Fallback behavior when translation is missing
26
- */
27
- type FallbackBehavior = 'key' | 'fallback' | 'throw' | ((key: string, meta?: TranslationMeta | undefined) => string);
28
- /**
29
- * Request-scoped i18n context
30
- */
31
- type I18nContext = {
32
- locale: string;
33
- translations: CompiledTranslations;
34
- fallback: FallbackBehavior;
35
- };
36
-
37
- type I18nConfig = {
38
- locales: string[];
39
- defaultLocale?: string | undefined;
40
- fallback?: FallbackBehavior | undefined;
41
- };
42
- type NormalizedConfig = {
43
- locales: string[];
44
- defaultLocale: string;
45
- fallback: FallbackBehavior;
46
- };
47
- declare class I18nSingleton {
48
- private config;
49
- private rawCache;
50
- private compiledCache;
51
- private extractionManifest;
52
- private hashCache;
53
- configure(config: I18nConfig): void;
54
- isConfigured(): boolean;
55
- getConfig(): NormalizedConfig;
56
- setTranslations(locale: string, raw: RawTranslations): void;
57
- getTranslations(locale: string): RawTranslations;
58
- getCompiledTranslations(locale: string): CompiledTranslations;
59
- getChunkManifest(): ChunkManifest;
60
- /**
61
- * Get extracted translation keys with metadata.
62
- * Use this to populate your CMS with keys extracted from the codebase.
63
- */
64
- getExtractedKeys(): ExtractedKey[] | null;
65
- /**
66
- * Get the full extraction manifest (keys + chunks).
67
- * Returns null in dev mode (manifest doesn't exist).
68
- */
69
- getExtractionManifest(): ExtractionManifest | null;
70
- getHashes(locale: string): Record<string, string>;
71
- /**
72
- * Clear translations for specified locale(s).
73
- * @param locales - Locale(s) to clear, or all if not specified
74
- */
75
- clear(locales?: string | string[] | undefined): void;
76
- private resolveLocales;
77
- }
78
- declare const i18n: I18nSingleton;
79
-
80
- export { type ExtractedKey as E, type FallbackBehavior as F, type I18nConfig as I, type ExtractionManifest as a, type I18nContext as b, i18n as i };
@@ -1,23 +0,0 @@
1
- import './types-DWhsmSPP.js';
2
-
3
- /**
4
- * Import a module with i18n translations loaded in parallel.
5
- * Use this for dynamic imports inside React components that use translations.
6
- *
7
- * The Vite plugin will transform calls to inject the chunk ID at build time.
8
- *
9
- * @example
10
- * ```tsx
11
- * // The Vite plugin transforms this:
12
- * const Module = await importWithI18n(() => import('./HeavyComponent'));
13
- *
14
- * // Into this at build time:
15
- * const Module = await importWithI18n(() => import('./HeavyComponent'), '_astro/HeavyComponent.abc123');
16
- * ```
17
- *
18
- * @param importFn - A function that returns the dynamic import promise
19
- * @param chunkId - (Injected by Vite plugin) The chunk ID for loading translations
20
- */
21
- declare function importWithI18n<T>(importFn: () => Promise<T>, chunkId?: string): Promise<T>;
22
-
23
- export { importWithI18n };
@@ -1,7 +0,0 @@
1
- import {
2
- importWithI18n
3
- } from "./chunk-V4XWJXXZ.js";
4
- import "./chunk-FI5KZ5IO.js";
5
- export {
6
- importWithI18n
7
- };
package/dist/init.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }
package/dist/init.js DELETED
@@ -1,8 +0,0 @@
1
- import {
2
- i18n
3
- } from "./chunk-2PSXD3JJ.js";
4
- import "./chunk-KNDYKTHE.js";
5
-
6
- // src/init.ts
7
- import { getManifest } from "virtual:@astroscope/i18n/manifest";
8
- i18n.setManifestGetter(getManifest);
@@ -1,29 +0,0 @@
1
- import { APIContext, MiddlewareHandler } from 'astro';
2
-
3
- type I18nMiddlewareOptions = {
4
- locale: (ctx: APIContext) => string;
5
- };
6
- /**
7
- * Detect locale from Accept-Language header.
8
- * Returns best match from configured locales, or undefined if none match.
9
- */
10
- declare function detectLocale(request: Request): string | undefined;
11
- /**
12
- * Create the i18n middleware.
13
- *
14
- * @example
15
- * ```typescript
16
- * import { createI18nMiddleware, detectLocale, i18n } from '@astroscope/i18n';
17
- *
18
- * export const i18nMiddleware = createI18nMiddleware({
19
- * locale: (ctx) =>
20
- * ctx.cookies.get('locale')?.value ??
21
- * detectLocale(ctx.request) ??
22
- * i18n.getDefaultLocale() ??
23
- * 'en',
24
- * });
25
- * ```
26
- */
27
- declare function createI18nMiddleware(options: I18nMiddlewareOptions): MiddlewareHandler;
28
-
29
- export { type I18nMiddlewareOptions as I, createI18nMiddleware as c, detectLocale as d };
@@ -1,29 +0,0 @@
1
- import { APIContext, MiddlewareHandler } from 'astro';
2
-
3
- type I18nMiddlewareOptions = {
4
- locale: (ctx: APIContext) => string;
5
- };
6
- /**
7
- * Detect locale from Accept-Language header.
8
- * Returns best match from configured locales, or undefined if none match.
9
- */
10
- declare function detectLocale(request: Request): string | undefined;
11
- /**
12
- * Create the i18n middleware.
13
- *
14
- * @example
15
- * ```typescript
16
- * import { createI18nMiddleware, detectLocale, i18n } from '@astroscope/i18n';
17
- *
18
- * export const i18nMiddleware = createI18nMiddleware({
19
- * locale: (ctx) =>
20
- * ctx.cookies.get('locale')?.value ??
21
- * detectLocale(ctx.request) ??
22
- * i18n.getConfig()?.defaultLocale ??
23
- * 'en',
24
- * });
25
- * ```
26
- */
27
- declare function createI18nMiddleware(options: I18nMiddlewareOptions): MiddlewareHandler;
28
-
29
- export { type I18nMiddlewareOptions as I, createI18nMiddleware as c, detectLocale as d };
@@ -1,5 +0,0 @@
1
- import * as astro from 'astro';
2
-
3
- declare const onRequest: astro.MiddlewareHandler;
4
-
5
- export { onRequest };
@@ -1,30 +0,0 @@
1
- import {
2
- createI18nMiddleware,
3
- getI18nService
4
- } from "./chunk-FHBVI3TL.js";
5
- import "./chunk-KNONI6DP.js";
6
-
7
- // src/middleware-entrypoint.ts
8
- import fs from "fs";
9
- function loadChunkManifest() {
10
- try {
11
- const manifestPath = new URL("./i18n-manifest.json", import.meta.url);
12
- const content = fs.readFileSync(manifestPath, "utf-8");
13
- const manifest = JSON.parse(content);
14
- return manifest.chunks;
15
- } catch {
16
- return void 0;
17
- }
18
- }
19
- var chunkManifest = loadChunkManifest();
20
- var service = getI18nService();
21
- var config = service.config;
22
- var onRequest = createI18nMiddleware({
23
- locales: config.locales,
24
- defaultLocale: config.defaultLocale,
25
- fallback: config.fallback,
26
- chunkManifest
27
- });
28
- export {
29
- onRequest
30
- };
@@ -1,2 +0,0 @@
1
- export { c as createI18nMiddleware, d as detectLocale } from '../middleware-entrypoint-C0Drh9E_.js';
2
- import 'astro';
@@ -1,28 +0,0 @@
1
- import {
2
- createI18nMiddleware,
3
- detectLocale,
4
- i18n
5
- } from "../chunk-NHHTSFA7.js";
6
- import "../chunk-JJBBY2GR.js";
7
- import "../chunk-KNDYKTHE.js";
8
-
9
- // src/server/middleware-entrypoint.ts
10
- import fs from "fs";
11
- function loadChunkManifest() {
12
- try {
13
- const manifestPath = new URL("./i18n-manifest.json", import.meta.url);
14
- const content = fs.readFileSync(manifestPath, "utf-8");
15
- const manifest = JSON.parse(content);
16
- return manifest.chunks;
17
- } catch {
18
- return void 0;
19
- }
20
- }
21
- var chunkManifest = loadChunkManifest();
22
- if (chunkManifest) {
23
- i18n.setChunkManifest(chunkManifest);
24
- }
25
- export {
26
- createI18nMiddleware,
27
- detectLocale
28
- };