@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,30 +0,0 @@
1
- import { T as TranslationMeta } from './types-BwhB6IT4.js';
2
-
3
- /**
4
- * Translate function signature
5
- *
6
- * @param key - Translation key (e.g., 'checkout.title')
7
- * @param meta - Metadata with example and variable definitions (extracted at build time)
8
- * @param values - Runtime values for interpolation
9
- * @returns Translated string
10
- *
11
- * @example
12
- * // Simple
13
- * t('checkout.title', { example: 'Bestellübersicht' })
14
- *
15
- * @example
16
- * // With variables
17
- * t('checkout.tax', {
18
- * example: 'Enthält {name} MwSt.',
19
- * variables: { name: { example: '19%' } }
20
- * }, { name: taxRate })
21
- *
22
- * @example
23
- * // Pluralization (ICU)
24
- * t('cart.items', {
25
- * example: '{count, plural, one {# item} other {# items}}'
26
- * }, { count: itemCount })
27
- */
28
- type TranslateFunction = (key: string, meta: TranslationMeta, values?: Record<string, unknown>) => string;
29
-
30
- export type { TranslateFunction as T };
@@ -1,30 +0,0 @@
1
- import { T as TranslationMeta } from './types-OYRgjtE_.js';
2
-
3
- /**
4
- * Translate function signature
5
- *
6
- * @param key - Translation key (e.g., 'checkout.title')
7
- * @param meta - Metadata with example and variable definitions (extracted at build time)
8
- * @param values - Runtime values for interpolation
9
- * @returns Translated string
10
- *
11
- * @example
12
- * // Simple
13
- * t('checkout.title', { example: 'Bestellübersicht' })
14
- *
15
- * @example
16
- * // With variables
17
- * t('checkout.tax', {
18
- * example: 'Enthält {name} MwSt.',
19
- * variables: { name: { example: '19%' } }
20
- * }, { name: taxRate })
21
- *
22
- * @example
23
- * // Pluralization (ICU)
24
- * t('cart.items', {
25
- * example: '{count, plural, one {# item} other {# items}}'
26
- * }, { count: itemCount })
27
- */
28
- type TranslateFunction = (key: string, meta: TranslationMeta, values?: Record<string, unknown>) => string;
29
-
30
- export type { TranslateFunction as T };
@@ -1,30 +0,0 @@
1
- import { T as TranslationMeta } from './types-BC6K-pID.js';
2
-
3
- /**
4
- * Translate function signature
5
- *
6
- * @param key - Translation key (e.g., 'checkout.title')
7
- * @param meta - Metadata with example and variable definitions (extracted at build time)
8
- * @param values - Runtime values for interpolation
9
- * @returns Translated string
10
- *
11
- * @example
12
- * // Simple
13
- * t('checkout.title', { example: 'Bestellübersicht' })
14
- *
15
- * @example
16
- * // With variables
17
- * t('checkout.tax', {
18
- * example: 'Enthält {name} MwSt.',
19
- * variables: { name: { example: '19%' } }
20
- * }, { name: taxRate })
21
- *
22
- * @example
23
- * // Pluralization (ICU)
24
- * t('cart.items', {
25
- * example: '{count, plural, one {# item} other {# items}}'
26
- * }, { count: itemCount })
27
- */
28
- type TranslateFunction = (key: string, meta: TranslationMeta, values?: Record<string, unknown>) => string;
29
-
30
- export type { TranslateFunction as T };
@@ -1,30 +0,0 @@
1
- import { T as TranslationMeta } from './types-D44mFUjA.js';
2
-
3
- /**
4
- * Translate function signature
5
- *
6
- * @param key - Translation key (e.g., 'checkout.title')
7
- * @param meta - Metadata with example and variable definitions (extracted at build time)
8
- * @param values - Runtime values for interpolation
9
- * @returns Translated string
10
- *
11
- * @example
12
- * // Simple
13
- * t('checkout.title', { example: 'Bestellübersicht' })
14
- *
15
- * @example
16
- * // With variables
17
- * t('checkout.tax', {
18
- * example: 'Enthält {name} MwSt.',
19
- * variables: { name: { example: '19%' } }
20
- * }, { name: taxRate })
21
- *
22
- * @example
23
- * // Pluralization (ICU)
24
- * t('cart.items', {
25
- * example: '{count, plural, one {# item} other {# items}}'
26
- * }, { count: itemCount })
27
- */
28
- type TranslateFunction = (key: string, meta: TranslationMeta, values?: Record<string, unknown>) => string;
29
-
30
- export type { TranslateFunction as T };
@@ -1,11 +0,0 @@
1
- import { d as TranslateFunction } from './types-DWhsmSPP.js';
2
- export { T as TranslationMeta } from './types-DWhsmSPP.js';
3
-
4
- /**
5
- * Client-side translate function
6
- * Reads from window.__i18n__.translations (injected per-chunk)
7
- * Falls back to meta.example if translation is missing
8
- */
9
- declare const t: TranslateFunction;
10
-
11
- export { TranslateFunction, t };
package/dist/t.client.js DELETED
@@ -1,35 +0,0 @@
1
- // src/t.client.ts
2
- import MessageFormat from "@messageformat/core";
3
- var compiledCache = /* @__PURE__ */ new Map();
4
- var mf = null;
5
- function getMessageFormat() {
6
- if (!mf) {
7
- mf = new MessageFormat(window.__i18n__.locale);
8
- }
9
- return mf;
10
- }
11
- function compileMessage(message) {
12
- try {
13
- return getMessageFormat().compile(message);
14
- } catch {
15
- return (values) => {
16
- if (!values) return message;
17
- return Object.entries(values).reduce(
18
- (result, [key, value]) => result.replace(new RegExp(`\\{${key}\\}`, "g"), String(value)),
19
- message
20
- );
21
- };
22
- }
23
- }
24
- var t = (key, meta, values) => {
25
- let compiled = compiledCache.get(key);
26
- if (!compiled) {
27
- const raw = window.__i18n__.translations[key] ?? meta.example;
28
- compiled = compileMessage(raw);
29
- compiledCache.set(key, compiled);
30
- }
31
- return compiled(values);
32
- };
33
- export {
34
- t
35
- };
@@ -1,22 +0,0 @@
1
- import { I as I18nContext, d as TranslateFunction } from './types-DWhsmSPP.js';
2
- export { T as TranslationMeta } from './types-DWhsmSPP.js';
3
-
4
- /**
5
- * Set the i18n context for the current request (called by middleware)
6
- */
7
- declare function setContext(context: I18nContext): void;
8
- /**
9
- * Get the current i18n context
10
- */
11
- declare function getContext(): I18nContext | null;
12
- /**
13
- * Clear the context after request (called by middleware)
14
- */
15
- declare function clearContext(): void;
16
- /**
17
- * Server-side translate function
18
- * Reads from request-scoped context set by middleware
19
- */
20
- declare const t: TranslateFunction;
21
-
22
- export { TranslateFunction, clearContext, getContext, setContext, t };
package/dist/t.server.js DELETED
@@ -1,12 +0,0 @@
1
- import {
2
- clearContext,
3
- getContext,
4
- setContext,
5
- t
6
- } from "./chunk-KNONI6DP.js";
7
- export {
8
- clearContext,
9
- getContext,
10
- setContext,
11
- t
12
- };
@@ -1,24 +0,0 @@
1
- import { T as TranslationMeta } from './types-Bzp6KxsI.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
- export type { ChunkManifest as C, ExtractedKey as E, ExtractionManifest as a };
@@ -1,110 +0,0 @@
1
- /**
2
- * Variable definition with optional example for CMS/documentation
3
- */
4
- type VariableDef = {
5
- example?: string;
6
- description?: string;
7
- };
8
- /**
9
- * Metadata for a translation key - extracted at build time, synced to CMS
10
- */
11
- type TranslationMeta = {
12
- example: string;
13
- variables?: Record<string, VariableDef>;
14
- description?: string;
15
- };
16
- /**
17
- * Compiled translation ready for runtime use
18
- */
19
- type CompiledTranslation = (values?: Record<string, unknown>) => string;
20
- /**
21
- * Map of translation keys to compiled functions
22
- */
23
- type CompiledTranslations = Record<string, CompiledTranslation>;
24
- /**
25
- * Raw translation strings from CMS (before compilation)
26
- */
27
- type RawTranslations = Record<string, string>;
28
- /**
29
- * Extracted metadata for a single translation key
30
- */
31
- type ExtractedKey = {
32
- key: string;
33
- meta: TranslationMeta;
34
- file: string;
35
- line: number;
36
- };
37
- /**
38
- * Chunk-to-keys mapping produced by Vite plugin
39
- */
40
- type ChunkManifest = Record<string, string[]>;
41
- /**
42
- * Full extraction manifest
43
- */
44
- type ExtractionManifest = {
45
- keys: ExtractedKey[];
46
- chunks: ChunkManifest;
47
- };
48
- /**
49
- * Fallback behavior when translation is missing
50
- */
51
- type FallbackBehavior = 'key' | 'example' | 'throw' | ((key: string, meta?: TranslationMeta) => string);
52
- /**
53
- * CMS adapter interface
54
- */
55
- type CmsAdapter = {
56
- /**
57
- * Fetch translations for given locale and keys
58
- */
59
- fetch: (locale: string, keys: string[]) => Promise<RawTranslations>;
60
- /**
61
- * Sync extracted keys to CMS (push metadata)
62
- */
63
- sync?: (manifest: ExtractionManifest) => Promise<void>;
64
- };
65
- /**
66
- * Integration options
67
- */
68
- type I18nIntegrationOptions = {
69
- /**
70
- * Supported locales
71
- */
72
- locales: string[];
73
- /**
74
- * Default locale
75
- */
76
- defaultLocale: string;
77
- /**
78
- * Fallback behavior when translation is missing
79
- * @default 'example'
80
- */
81
- fallback?: FallbackBehavior;
82
- /**
83
- * CMS adapter for fetching/syncing translations
84
- */
85
- cms: CmsAdapter;
86
- /**
87
- * Function to detect locale from request
88
- * @default reads from Astro.currentLocale or Accept-Language header
89
- */
90
- detectLocale?: (request: Request) => string;
91
- };
92
- /**
93
- * Request-scoped i18n context
94
- */
95
- type I18nContext = {
96
- locale: string;
97
- translations: CompiledTranslations;
98
- fallback: FallbackBehavior;
99
- meta: Record<string, TranslationMeta>;
100
- };
101
- /**
102
- * Global i18n config (from virtual module)
103
- */
104
- type I18nConfig = {
105
- locales: string[];
106
- defaultLocale: string;
107
- fallback: FallbackBehavior;
108
- };
109
-
110
- export type { CmsAdapter as C, ExtractedKey as E, FallbackBehavior as F, I18nIntegrationOptions as I, RawTranslations as R, TranslationMeta as T, VariableDef as V, ChunkManifest as a, CompiledTranslation as b, CompiledTranslations as c, ExtractionManifest as d, I18nContext as e, I18nConfig as f };
@@ -1,55 +0,0 @@
1
- /**
2
- * Variable definition with optional example for CMS/documentation
3
- */
4
- type VariableDef = {
5
- example?: string;
6
- description?: string;
7
- };
8
- /**
9
- * Metadata for a translation key - extracted at build time, synced to CMS
10
- */
11
- type TranslationMeta = {
12
- example: string;
13
- variables?: Record<string, VariableDef>;
14
- description?: string;
15
- };
16
- /**
17
- * Compiled translation ready for runtime use
18
- */
19
- type CompiledTranslation = (values?: Record<string, unknown>) => string;
20
- /**
21
- * Map of translation keys to compiled functions
22
- */
23
- type CompiledTranslations = Record<string, CompiledTranslation>;
24
- /**
25
- * Raw translation strings from CMS (before compilation)
26
- */
27
- type RawTranslations = Record<string, string>;
28
- /**
29
- * Translate function signature
30
- *
31
- * @param key - Translation key (e.g., 'checkout.title')
32
- * @param meta - Metadata with example and variable definitions (extracted at build time)
33
- * @param values - Runtime values for interpolation
34
- * @returns Translated string
35
- *
36
- * @example
37
- * // Simple
38
- * t('checkout.title', { example: 'Bestellübersicht' })
39
- *
40
- * @example
41
- * // With variables
42
- * t('checkout.tax', {
43
- * example: 'Enthält {name} MwSt.',
44
- * variables: { name: { example: '19%' } }
45
- * }, { name: taxRate })
46
- *
47
- * @example
48
- * // Pluralization (ICU)
49
- * t('cart.items', {
50
- * example: '{count, plural, one {# item} other {# items}}'
51
- * }, { count: itemCount })
52
- */
53
- type TranslateFunction = (key: string, meta: TranslationMeta, values?: Record<string, unknown>) => string;
54
-
55
- export type { CompiledTranslations as C, RawTranslations as R, TranslationMeta as T, VariableDef as V, CompiledTranslation as a, TranslateFunction as b };
@@ -1,46 +0,0 @@
1
- /**
2
- * Variable definition for CMS/documentation
3
- */
4
- type VariableDef = {
5
- fallback?: string | undefined;
6
- description?: string | undefined;
7
- };
8
- /**
9
- * Metadata for a translation key - extracted at build time, synced to CMS
10
- */
11
- type TranslationMeta = {
12
- fallback: string;
13
- variables?: Record<string, VariableDef> | undefined;
14
- description?: string | undefined;
15
- };
16
- /**
17
- * Compiled translation ready for runtime use
18
- */
19
- type CompiledTranslation = (values?: Record<string, unknown> | undefined) => string;
20
- /**
21
- * Map of translation keys to compiled functions
22
- */
23
- type CompiledTranslations = Record<string, CompiledTranslation>;
24
- /**
25
- * Raw translation strings from CMS (before compilation)
26
- */
27
- type RawTranslations = Record<string, string>;
28
- /**
29
- * Translate function signature
30
- *
31
- * @param key - Translation key (e.g., 'checkout.title')
32
- * @param meta - Fallback string or full metadata object
33
- * @param values - Runtime values for interpolation
34
- *
35
- * @example
36
- * t('checkout.title', 'Order Summary')
37
- *
38
- * @example
39
- * t('cart.items', '{count, plural, one {# item} other {# items}}', { count: itemCount })
40
- *
41
- * @example
42
- * t('cart.total', { fallback: 'Total: {amount}', description: 'Cart total' }, { amount: '$49.99' })
43
- */
44
- type TranslateFunction = (key: string, meta: TranslationMeta | string, values?: Record<string, unknown> | undefined) => string;
45
-
46
- export type { CompiledTranslations as C, RawTranslations as R, TranslateFunction as T, TranslationMeta as a };
@@ -1,7 +0,0 @@
1
- import { I as I18nClientState } from './types-Bzp6KxsI.js';
2
-
3
- declare global {
4
- interface Window {
5
- __i18n__: I18nClientState;
6
- }
7
- }
@@ -1,102 +0,0 @@
1
- /**
2
- * Variable definition with optional example for CMS/documentation
3
- */
4
- type VariableDef = {
5
- example?: string;
6
- description?: string;
7
- };
8
- /**
9
- * Metadata for a translation key - extracted at build time, synced to CMS
10
- */
11
- type TranslationMeta = {
12
- example: string;
13
- variables?: Record<string, VariableDef>;
14
- description?: string;
15
- };
16
- /**
17
- * Compiled translation ready for runtime use
18
- */
19
- type CompiledTranslation = (values?: Record<string, unknown>) => string;
20
- /**
21
- * Map of translation keys to compiled functions
22
- */
23
- type CompiledTranslations = Record<string, CompiledTranslation>;
24
- /**
25
- * Raw translation strings from CMS (before compilation)
26
- */
27
- type RawTranslations = Record<string, string>;
28
- /**
29
- * Extracted metadata for a single translation key
30
- */
31
- type ExtractedKey = {
32
- key: string;
33
- meta: TranslationMeta;
34
- file: string;
35
- line: number;
36
- };
37
- /**
38
- * Chunk-to-keys mapping produced by Vite plugin
39
- */
40
- type ChunkManifest = Record<string, string[]>;
41
- /**
42
- * Full extraction manifest
43
- */
44
- type ExtractionManifest = {
45
- keys: ExtractedKey[];
46
- chunks: ChunkManifest;
47
- };
48
- /**
49
- * Fallback behavior when translation is missing
50
- */
51
- type FallbackBehavior = 'key' | 'example' | 'throw' | ((key: string, meta?: TranslationMeta) => string);
52
- /**
53
- * Request-scoped i18n context
54
- */
55
- type I18nContext = {
56
- locale: string;
57
- translations: CompiledTranslations;
58
- fallback: FallbackBehavior;
59
- meta: Record<string, TranslationMeta>;
60
- };
61
- /**
62
- * Client-side i18n state stored on window.__i18n__
63
- * Fallback is handled server-side; client just uses example from t() call if missing
64
- */
65
- type I18nClientState = {
66
- locale: string;
67
- hashes: Record<string, string>;
68
- translations: Record<string, string>;
69
- };
70
- /**
71
- * Translate function signature
72
- *
73
- * @param key - Translation key (e.g., 'checkout.title')
74
- * @param meta - Metadata with example and variable definitions (extracted at build time)
75
- * @param values - Runtime values for interpolation
76
- * @returns Translated string
77
- *
78
- * @example
79
- * // Simple
80
- * t('checkout.title', { example: 'Bestellübersicht' })
81
- *
82
- * @example
83
- * // With variables
84
- * t('checkout.tax', {
85
- * example: 'Enthält {name} MwSt.',
86
- * variables: { name: { example: '19%' } }
87
- * }, { name: taxRate })
88
- *
89
- * @example
90
- * // Pluralization (ICU)
91
- * t('cart.items', {
92
- * example: '{count, plural, one {# item} other {# items}}'
93
- * }, { count: itemCount })
94
- */
95
- type TranslateFunction = (key: string, meta: TranslationMeta, values?: Record<string, unknown>) => string;
96
- declare global {
97
- interface Window {
98
- __i18n__?: I18nClientState;
99
- }
100
- }
101
-
102
- export type { ChunkManifest as C, ExtractedKey as E, FallbackBehavior as F, I18nContext as I, RawTranslations as R, TranslationMeta as T, VariableDef as V, CompiledTranslations as a, CompiledTranslation as b, ExtractionManifest as c, TranslateFunction as d };
@@ -1,111 +0,0 @@
1
- /**
2
- * Variable definition with optional example for CMS/documentation
3
- */
4
- type VariableDef = {
5
- example?: string;
6
- description?: string;
7
- };
8
- /**
9
- * Metadata for a translation key - extracted at build time, synced to CMS
10
- */
11
- type TranslationMeta = {
12
- example: string;
13
- variables?: Record<string, VariableDef>;
14
- description?: string;
15
- };
16
- /**
17
- * Compiled translation ready for runtime use
18
- */
19
- type CompiledTranslation = (values?: Record<string, unknown>) => string;
20
- /**
21
- * Map of translation keys to compiled functions
22
- */
23
- type CompiledTranslations = Record<string, CompiledTranslation>;
24
- /**
25
- * Raw translation strings from CMS (before compilation)
26
- */
27
- type RawTranslations = Record<string, string>;
28
- /**
29
- * Extracted metadata for a single translation key
30
- */
31
- type ExtractedKey = {
32
- key: string;
33
- meta: TranslationMeta;
34
- file: string;
35
- line: number;
36
- };
37
- /**
38
- * Chunk-to-keys mapping produced by Vite plugin
39
- */
40
- type ChunkManifest = Record<string, string[]>;
41
- /**
42
- * Full extraction manifest
43
- */
44
- type ExtractionManifest = {
45
- keys: ExtractedKey[];
46
- chunks: ChunkManifest;
47
- };
48
- /**
49
- * Fallback behavior when translation is missing
50
- */
51
- type FallbackBehavior = 'key' | 'example' | 'throw' | ((key: string, meta?: TranslationMeta) => string);
52
- /**
53
- * CMS adapter interface
54
- */
55
- type CmsAdapter = {
56
- /**
57
- * Fetch translations for given locale and keys
58
- */
59
- fetch: (locale: string, keys: string[]) => Promise<RawTranslations>;
60
- /**
61
- * Sync extracted keys to CMS (push metadata)
62
- */
63
- sync?: (manifest: ExtractionManifest) => Promise<void>;
64
- };
65
- /**
66
- * User's i18n.ts exports
67
- */
68
- type I18nUserConfig = {
69
- /**
70
- * CMS adapter for fetching/syncing translations
71
- */
72
- cms: CmsAdapter;
73
- /**
74
- * Optional chunk manifest for per-chunk loading
75
- * In production, this should be loaded from build output
76
- */
77
- chunkManifest?: ChunkManifest;
78
- };
79
- /**
80
- * Request-scoped i18n context
81
- */
82
- type I18nContext = {
83
- locale: string;
84
- translations: CompiledTranslations;
85
- fallback: FallbackBehavior;
86
- meta: Record<string, TranslationMeta>;
87
- };
88
- /**
89
- * Global i18n config (from virtual module)
90
- */
91
- type I18nConfig = {
92
- locales: string[];
93
- defaultLocale: string;
94
- fallback: FallbackBehavior;
95
- };
96
- /**
97
- * Client-side i18n state stored on window.__i18n__
98
- * Fallback is handled server-side; client just uses example from t() call if missing
99
- */
100
- type I18nClientState = {
101
- locale: string;
102
- hashes: Record<string, string>;
103
- translations: Record<string, string>;
104
- };
105
- declare global {
106
- interface Window {
107
- __i18n__?: I18nClientState;
108
- }
109
- }
110
-
111
- export type { CmsAdapter as C, ExtractedKey as E, FallbackBehavior as F, I18nUserConfig as I, RawTranslations as R, TranslationMeta as T, VariableDef as V, ChunkManifest as a, CompiledTranslation as b, CompiledTranslations as c, ExtractionManifest as d, I18nContext as e, I18nConfig as f };
@@ -1,24 +0,0 @@
1
- import { a as TranslationMeta } from './types-CLWZeQhD.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
- export type { ChunkManifest as C, ExtractionManifest as E, ExtractedKey as a };