@menapo/vi18n 0.1.2 → 0.2.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/README.md +19 -0
  2. package/dist/{apply-FAHl1R6T.js → apply-Bg-3rB2m.js} +4 -4
  3. package/dist/{captured-CTjjDF5o.js → captured-DfLk50Ji.js} +1 -1
  4. package/dist/{check-DwFwOB1d.js → check-CunekuYs.js} +16 -7
  5. package/dist/cli.js +1 -1
  6. package/dist/{collisions-uMTuq36M.js → collisions-CDSdtLQm.js} +2 -2
  7. package/dist/{compile-CEvH-6sY.js → compile-hva0qjhZ.js} +6 -6
  8. package/dist/config.d.ts +1 -1
  9. package/dist/config.js +2 -2
  10. package/dist/{diagnostics-1onDF6Ua.js → diagnostics-LgIWyeSp.js} +2 -1
  11. package/dist/{duplicates-CsUXRX2J.js → duplicates-8cudcHNj.js} +1 -1
  12. package/dist/{engine-Bf7nVigL.js → engine-ecRD8-IE.js} +11 -11
  13. package/dist/engine.d.ts +1 -1
  14. package/dist/{exchange-DYG9RZoT.js → exchange-DjwlrTQ9.js} +3 -3
  15. package/dist/{exclude-vMnm3lqU.js → exclude-BFETmvde.js} +1 -1
  16. package/dist/{export-BYq0gfLd.js → export-D2tsqWIr.js} +6 -6
  17. package/dist/{extract-CYtuEo8u.js → extract-BxYchVmY.js} +7 -7
  18. package/dist/{formats-ChV1LVH_.js → formats-BaryZ2N7.js} +3 -3
  19. package/dist/{i18next-D66Icz3L.js → i18next-COO6o0tX.js} +6 -6
  20. package/dist/i18next-Dr7DCQlQ.js +1 -0
  21. package/dist/{import-BApbQlmm.js → import-vSC29Cn4.js} +6 -6
  22. package/dist/index.d.ts +1 -1
  23. package/dist/{init-J7AwwA5e.js → init-Cc7A-8VX.js} +9 -9
  24. package/dist/{library-BfSOBeBd.js → library-tp_xqzSY.js} +2 -2
  25. package/dist/{lingui-Ee2farVo.js → lingui-BnnlqGXT.js} +8 -8
  26. package/dist/lint.js +7 -6
  27. package/dist/{load-BFLLqY8x.js → load-BSIeGJ5v.js} +8 -6
  28. package/dist/{load-CMwhukZ4.js → load-SSrAeJVB.js} +5 -3
  29. package/dist/{locales-DxLDrx-h.js → locales-D0U-yVRm.js} +4 -4
  30. package/dist/{lsp-BC7xDGON.js → lsp-DvC11pBZ.js} +2 -2
  31. package/dist/{mcp-Cka8ywDF.js → mcp-D2zzOTBy.js} +2 -2
  32. package/dist/{merge-driver-B04Apm29.js → merge-driver-BLI8OtAc.js} +6 -6
  33. package/dist/migrate-1r43OBfe.js +1 -0
  34. package/dist/{migrate-D7TNl6SD.js → migrate-ChDGhlC-.js} +11 -11
  35. package/dist/{openai-RWw0YlAx.js → openai-CLn4puY8.js} +1 -1
  36. package/dist/{output-CF9uvk_-.js → output-D5tAt8q4.js} +3 -3
  37. package/dist/parse.d.ts +1 -1
  38. package/dist/{pipeline-sgl_q_op.js → pipeline-BJSkkRYC.js} +7 -7
  39. package/dist/{pipeline-B30irGMD.js → pipeline-BeCc441z.js} +1 -1
  40. package/dist/{project-DSzWKU3C.js → project-B5KIO0q-.js} +9 -9
  41. package/dist/{pseudo-DNbNNVGP.js → pseudo-B2DUpoLu.js} +2 -1
  42. package/dist/{react-intl-tzGIk6G3.js → react-intl-C8JehBBL.js} +6 -6
  43. package/dist/rename-ZVGq9ZG1.js +577 -0
  44. package/dist/repeated-uuI1tUGg.js +85 -0
  45. package/dist/{restore-BG_zMpSj.js → restore-xlBIrtRt.js} +8 -8
  46. package/dist/{rewrite-hAcRJwiZ.js → rewrite-BwzXoBiA.js} +1 -1
  47. package/dist/{run-CFzR3V93.js → run-CQ9pDLSa.js} +50 -23
  48. package/dist/scan-worker.d.ts +1 -1
  49. package/dist/scan-worker.js +1 -1
  50. package/dist/{server-ceuzzkal.js → server-Br8tAuG2.js} +28 -8
  51. package/dist/{server-WlxZH0oX.js → server-DJRpUQVZ.js} +793 -12
  52. package/dist/server.d.ts +1 -1
  53. package/dist/server.js +7 -1
  54. package/dist/{sitemap-796jJKUT.js → sitemap-CSAkm6oi.js} +4 -4
  55. package/dist/{sources-DuOdM02f.js → sources-DNVbYsgs.js} +4 -3
  56. package/dist/{status-CTH3qI-0.js → status-q6M3rBrh.js} +3 -3
  57. package/dist/{sync-CpL0Qsgw.js → sync-BNIAwMhR.js} +6 -6
  58. package/dist/test.d.ts +1 -1
  59. package/dist/test.js +53 -12
  60. package/dist/{translate-BrfVRkjl.js → translate-BP4iVhOR.js} +6 -6
  61. package/dist/{types-BaG1LboH.d.ts → types-B4wNX6PA.d.ts} +4 -2
  62. package/dist/{types-Cy2bPdSg.d.ts → types-_4UdFhR9.d.ts} +10 -1
  63. package/dist/{types-Ds_vebja.js → types-xR2exI3L.js} +1 -0
  64. package/dist/{units-VVLgQ7x7.js → units-DPPfCN7j.js} +3 -3
  65. package/dist/{validate-zv4-IZyZ.js → validate-CgzaDdOY.js} +2 -2
  66. package/dist/{version-BFs370Ce.js → version-DC-J5WvV.js} +2 -2
  67. package/dist/{vite-scan-DFKSGVE9.js → vite-scan-kM8Ta3rO.js} +6 -6
  68. package/dist/vite.d.ts +1 -1
  69. package/dist/vite.js +20 -16
  70. package/dist/{vue-i18n-CBmZqHbG.js → vue-i18n-_uIXlFVh.js} +6 -6
  71. package/dist/{which-BpyJyBkX.js → which-DFWk_KwN.js} +8 -8
  72. package/dist/{worker-BjzVqJVO.js → worker-zlhNj4y3.js} +4 -4
  73. package/package.json +1 -1
  74. package/dist/i18next-1waHziMy.js +0 -1
  75. package/dist/migrate-khCY8TE0.js +0 -1
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { h as Scope, m as RuntimeConfig, y as Translator } from "./types-BaG1LboH.js";
1
+ import { h as Scope, m as RuntimeConfig, y as Translator } from "./types-B4wNX6PA.js";
2
2
  /** Options of `handle()` and `withRequest()`. */
3
3
  interface HandleOptions {
4
4
  /** CSP nonce for the payload `<script>` elements. */
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as warnOnce, m as createScope, n as S, o as noop, t as textDirection, v as own } from "./dir-TGLYuOZb.js";
1
+ import { b as warnOnce, m as createScope, n as S, o as noop, s as page, t as textDirection, v as own } from "./dir-TGLYuOZb.js";
2
2
  import { a as matchLocale, c as urlLocale, o as readCookie, r as TIME_ZONE_COOKIE, t as LOCALE_HEADER } from "./match-BLDcj610.js";
3
3
  import { a as baseOf, c as localeOrigin, d as matchRoute, f as routePath, i as awayHref, l as localizePath, m as unprefixedLocale, n as atHome, p as splitLocalePath, r as atHost, s as hostLocale, u as localizedPathsFor } from "./url-D2_VlEeH.js";
4
4
  import { t as createScopedApi } from "./scoped-h3KE8XWW.js";
@@ -15,6 +15,11 @@ import { AsyncLocalStorage } from "node:async_hooks";
15
15
  * plugin behaves as production.
16
16
  */
17
17
  const DEV = typeof __VI18N_DEV__ !== "undefined" && !!__VI18N_DEV__;
18
+ /**
19
+ * Not a production build the plugin made: dev, Vitest, or code bundled
20
+ * without the plugin. Builds fold what only these need away.
21
+ */
22
+ const UNBUILT = typeof __VI18N_DEV__ === "undefined" || !!__VI18N_DEV__;
18
23
  /** `ROUTES` of the URL codec: localized paths and domains are compiled in. */
19
24
  const ROUTES = typeof __VI18N_ROUTES__ === "undefined" || !!__VI18N_ROUTES__;
20
25
  const error = (text) => /* @__PURE__ */ new Error("vi18n: " + text);
@@ -911,6 +916,7 @@ async function openScope(kind, locale, [timeZone, timeZoneSource], now, trackUse
911
916
  sources
912
917
  });
913
918
  if (DEV && cat.labels) scope.labels = cat.labels;
919
+ if (UNBUILT) scope.test = page.test;
914
920
  return scope;
915
921
  }
916
922
  function translatorScope(locale, options) {
@@ -1,9 +1,9 @@
1
- import { c as toRuntimeConfig, o as normalizeBase } from "./load-BFLLqY8x.js";
1
+ import { c as toRuntimeConfig, o as normalizeBase } from "./load-BSIeGJ5v.js";
2
2
  import { n as localeOrigin, r as localizePath, t as atHome } from "./url-Bpc6wLea.js";
3
- import { o as errorMessage, r as plural } from "./output-CF9uvk_-.js";
3
+ import { o as errorMessage, r as plural } from "./output-D5tAt8q4.js";
4
4
  import { n as readIfExists, r as writeFileAtomic } from "./fs-ezCMZeDV.js";
5
- import { g as usageError, s as loadProject } from "./project-DSzWKU3C.js";
6
- import { r as EXIT } from "./types-Ds_vebja.js";
5
+ import { g as usageError, s as loadProject } from "./project-B5KIO0q-.js";
6
+ import { r as EXIT } from "./types-xR2exI3L.js";
7
7
  import { resolve } from "node:path";
8
8
  import { readFile } from "node:fs/promises";
9
9
  // src/cli/commands/sitemap.ts
@@ -1,5 +1,5 @@
1
- import { a as DEFAULT_IMPORT_SOURCES, n as isDiagnosticError, t as diagnosticError } from "./diagnostics-1onDF6Ua.js";
2
- import { d as withoutQuery, g as isValidManualId, n as validateSource } from "./validate-zv4-IZyZ.js";
1
+ import { a as DEFAULT_IMPORT_SOURCES, n as isDiagnosticError, t as diagnosticError } from "./diagnostics-LgIWyeSp.js";
2
+ import { _ as isValidManualId, f as withoutQuery, n as validateSource } from "./validate-CgzaDdOY.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
5
5
  import { readFileSync, realpathSync, statSync } from "node:fs";
@@ -1941,6 +1941,7 @@ var Scanner = class {
1941
1941
  };
1942
1942
  if (analysis.context !== void 0) occurrence.context = analysis.context;
1943
1943
  if (analysis.maxLength !== void 0) occurrence.maxLength = analysis.maxLength;
1944
+ if (this.markers.ignored.length > 0 && isIgnored(this.markers, analysis.literal.start)) occurrence.ignored = true;
1944
1945
  return occurrence;
1945
1946
  }
1946
1947
  /**
@@ -2578,4 +2579,4 @@ function sourceSpecifiers(imports, file, config) {
2578
2579
  }
2579
2580
  return out;
2580
2581
  }
2581
- export { langFromId as C, locateLiteral as D, lineStartsOf as E, listImports as O, armRawParsing as S, lineColumn as T, insertImport as _, scanModule as a, skipTrivia as b, USE_T as c, markersOf as d, TYPE_KEYS as f, forEachBindingName as g, directives as h, stripJsonc as i, findMarkers as l, childNodes as m, sourceNeedles as n, GLUE as o, afterDirective as p, sourceSpecifiers as r, KEYS_MARKER as s, lastName as t, isIgnored as u, isNode as v, parseModule as w, unwrap as x, keyName as y };
2582
+ export { langFromId as C, locateLiteral as D, lineStartsOf as E, quoted as O, armRawParsing as S, lineColumn as T, insertImport as _, scanModule as a, skipTrivia as b, USE_T as c, markersOf as d, TYPE_KEYS as f, forEachBindingName as g, directives as h, stripJsonc as i, listImports as k, findMarkers as l, childNodes as m, sourceNeedles as n, GLUE as o, afterDirective as p, sourceSpecifiers as r, KEYS_MARKER as s, lastName as t, isIgnored as u, isNode as v, parseModule as w, unwrap as x, keyName as y };
@@ -1,6 +1,6 @@
1
- import { a as table } from "./output-CF9uvk_-.js";
2
- import { a as hasErrors, h as targetLocales, l as ownStatus, m as scan, n as catalogFile, o as loadCatalogs, p as referencedMessages, r as compareText, s as loadProject, u as percent } from "./project-DSzWKU3C.js";
3
- import { r as EXIT } from "./types-Ds_vebja.js";
1
+ import { a as table } from "./output-D5tAt8q4.js";
2
+ import { a as hasErrors, h as targetLocales, l as ownStatus, m as scan, n as catalogFile, o as loadCatalogs, p as referencedMessages, r as compareText, s as loadProject, u as percent } from "./project-B5KIO0q-.js";
3
+ import { r as EXIT } from "./types-xR2exI3L.js";
4
4
  import { dirname, join, relative } from "node:path";
5
5
  import { readFile, stat } from "node:fs/promises";
6
6
  // src/cli/commands/status.ts
@@ -1,9 +1,9 @@
1
- import { n as isDiagnosticError, r as CONFIG_FILE } from "./diagnostics-1onDF6Ua.js";
2
- import { _ as parseIdScheme, a as displayPath, c as mapLimit, i as MISSING, s as isMissing, u as toPosix } from "./validate-zv4-IZyZ.js";
3
- import { C as emptyCatalog, E as entryKey, F as isIncluded, I as listProjectFiles, L as compareText, N as serialized, a as ownedMessages, f as sameCatalogText, n as libraryCoverage, o as catalogLayout, p as serializeCatalog, r as libraryIds, s as catalogPath, x as createEntry, z as dependencyRef } from "./library-BfSOBeBd.js";
4
- import { n as cacheVersion, t as VERSION } from "./version-BFs370Ce.js";
5
- import { i as scanSource, n as WORKER_MARKER, r as scanConfig, t as ABORT_CODES } from "./worker-BjzVqJVO.js";
6
- import { n as mergeDuplicates } from "./duplicates-CsUXRX2J.js";
1
+ import { n as isDiagnosticError, r as CONFIG_FILE } from "./diagnostics-LgIWyeSp.js";
2
+ import { a as MISSING, c as isMissing, d as toPosix, l as mapLimit, o as displayPath, v as parseIdScheme } from "./validate-CgzaDdOY.js";
3
+ import { C as emptyCatalog, E as entryKey, F as isIncluded, I as listProjectFiles, L as compareText, N as serialized, a as ownedMessages, f as sameCatalogText, n as libraryCoverage, o as catalogLayout, p as serializeCatalog, r as libraryIds, s as catalogPath, x as createEntry, z as dependencyRef } from "./library-tp_xqzSY.js";
4
+ import { n as cacheVersion, t as VERSION } from "./version-DC-J5WvV.js";
5
+ import { i as scanSource, n as WORKER_MARKER, r as scanConfig, t as ABORT_CODES } from "./worker-zlhNj4y3.js";
6
+ import { n as mergeDuplicates } from "./duplicates-8cudcHNj.js";
7
7
  import { basename, dirname, join, relative, resolve } from "node:path";
8
8
  import { hash, randomBytes } from "node:crypto";
9
9
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
package/dist/test.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Message, y as Translator } from "./types-BaG1LboH.js";
1
+ import { a as Message, y as Translator } from "./types-B4wNX6PA.js";
2
2
  /** What every message renders as: its translation or source, its id, or pseudo text. */
3
3
  type TestMode = "source" | "ids" | "pseudo";
4
4
  /** One locale's translations from the project's catalogs (`loadCatalog`). */
package/dist/test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { f as subs, n as S, r as changed, s as page, t as textDirection } from "./dir-TGLYuOZb.js";
2
- import { a as ID_LENGTH, o as PSEUDO_LOCALES, r as DEFAULT_CONFIG, t as pseudoLocalize } from "./pseudo-DNbNNVGP.js";
2
+ import { a as ID_LENGTH, o as PSEUDO_LOCALES, r as DEFAULT_CONFIG, t as pseudoLocalize } from "./pseudo-B2DUpoLu.js";
3
3
  import { c as parseICU, i as normalizeSource, n as canonicalize, t as compileMessage } from "./compile-DqkofbiO.js";
4
4
  import { t as createScopedApi } from "./scoped-h3KE8XWW.js";
5
5
  // src/test/catalog.ts
@@ -26,7 +26,7 @@ function loadCatalog(locale, options = {}) {
26
26
  ]);
27
27
  let load = loads.get(key);
28
28
  if (load === void 0) {
29
- load = import("./load-CMwhukZ4.js").then((m) => m.compileCatalog(locale, root, configFile));
29
+ load = import("./load-SSrAeJVB.js").then((m) => m.compileCatalog(locale, root, configFile));
30
30
  loads.set(key, load);
31
31
  load.catch(() => loads.delete(key));
32
32
  }
@@ -58,6 +58,7 @@ function resetTestI18n() {
58
58
  const s = saved;
59
59
  if (s === null) return;
60
60
  saved = null;
61
+ s.untaught?.();
61
62
  page.locale = s.locale;
62
63
  page.messages = s.messages;
63
64
  page.timeZone = s.timeZone;
@@ -82,7 +83,11 @@ function testRegistration(locale) {
82
83
  pseudoLocales: locales.filter((l) => PSEUDO.has(l)),
83
84
  fallbacks: {},
84
85
  routing: {
85
- strategy: ["default"],
86
+ strategy: [
87
+ "cookie",
88
+ "header",
89
+ "default"
90
+ ],
86
91
  routeStrategies: {},
87
92
  url: "no_prefix",
88
93
  redirectRoot: false,
@@ -97,9 +102,36 @@ function testRegistration(locale) {
97
102
  normalizeSpaces: DEFAULT_CONFIG.ssr.normalizeSpaces
98
103
  }
99
104
  },
100
- test: true
105
+ test: true,
106
+ serverCatalogs: Object.fromEntries(locales.map((l) => [l, async () => ({})]))
101
107
  };
102
108
  }
109
+ /**
110
+ * `/server` scopes open in any locale a test names, the pseudo-locales
111
+ * included, but a registration lists only the project's: teach it the
112
+ * others, with an empty catalog (`createTestI18n` supplies their text),
113
+ * and return how to forget them. Done here rather than in `/server`, whose
114
+ * size budget production servers pay.
115
+ */
116
+ function teachPseudo(reg) {
117
+ const undo = [];
118
+ const empty = async () => ({ default: {
119
+ messages: {},
120
+ labels: {}
121
+ } });
122
+ for (const l of PSEUDO_LOCALES) {
123
+ if (!reg.config.locales.includes(l)) {
124
+ reg.config.locales.push(l);
125
+ undo.push(() => reg.config.locales.splice(reg.config.locales.indexOf(l), 1));
126
+ }
127
+ const loaders = reg.serverCatalogs ?? (reg.catalogs ??= {});
128
+ if (!(l in loaders)) {
129
+ loaders[l] = reg.serverCatalogs ? async () => ({}) : empty;
130
+ undo.push(() => delete loaders[l]);
131
+ }
132
+ }
133
+ return () => undo.forEach((f) => f());
134
+ }
103
135
  function memo(cache, key, make) {
104
136
  let value = cache.get(key);
105
137
  if (value === void 0) {
@@ -163,7 +195,7 @@ function createTestI18n(options = {}) {
163
195
  check(base === null || base.config.locales.includes(locale) || PSEUDO.has(locale), `unknown locale ${locale} (${base?.config.locales.join(", ")})`);
164
196
  const h = html();
165
197
  const before = saveOnce(h);
166
- if (base === null) S.register(testRegistration(locale));
198
+ register(base, locale, before);
167
199
  page.locale = locale;
168
200
  page.messages = catalog?.messages ?? before.messages;
169
201
  page.timeZone = timeZone;
@@ -185,6 +217,15 @@ function createTestI18n(options = {}) {
185
217
  reset: resetTestI18n
186
218
  };
187
219
  }
220
+ /**
221
+ * Without the plugin nothing registered: `register` records a test
222
+ * registration (and resets the page's locale, set by the caller after).
223
+ * Either way `/server` is taught the pseudo-locales, once per test file run.
224
+ */
225
+ function register(base, locale, before) {
226
+ if (base === null) S.register(testRegistration(locale));
227
+ before.untaught ??= S.registration?.test ? teachPseudo(S.registration) : null;
228
+ }
188
229
  /** The options with their defaults, each checked; throws a RangeError naming the bad one. */
189
230
  function checkedOptions(options) {
190
231
  const mode = options.mode ?? "source";
@@ -219,23 +260,23 @@ function saveOnce(h) {
219
260
  html: h && {
220
261
  lang: h.lang,
221
262
  dir: h.dir
222
- }
263
+ },
264
+ untaught: null
223
265
  };
224
266
  return saved;
225
267
  }
226
268
  /** The scope's `test` hook: what every message renders as in this mode and locale. */
227
269
  function testHook(input) {
228
270
  const { mode, locale, own, idLength } = input;
229
- const style = locale === "ar-XB" ? "ar-XB" : "en-XA";
230
- return (id, d, text) => {
271
+ return function(id, d, text) {
231
272
  const source = d?.message ?? text;
232
- if (mode === "ids") return d?.id ?? (page.messages.has(id) ? id : generatedId(canonicalOf(source), idLength));
233
- if (mode === "pseudo") return pseudo(source, style);
234
- if (page.locale === locale && own.size > 0) {
273
+ if (mode === "ids") return d?.id ?? (this.messages.has(id) ? id : generatedId(canonicalOf(source), idLength));
274
+ if (mode === "pseudo") return pseudo(source, this.locale === "ar-XB" ? "ar-XB" : "en-XA");
275
+ if (this.locale === locale && own.size > 0) {
235
276
  const m = own.get(id) ?? own.get(canonicalOf(source));
236
277
  if (m !== void 0) return m;
237
278
  }
238
- return page.messages.get(id) ?? d?.ir ?? compiled(source);
279
+ return this.messages.get(id) ?? d?.ir ?? compiled(source);
239
280
  };
240
281
  }
241
282
  // src/test/pseudo.ts
@@ -1,10 +1,10 @@
1
1
  import { t as adaptiveConcurrency } from "./concurrency-Dy2ny50V.js";
2
- import { a as firstRequests, c as runTranslations, i as estimateUsage, n as catalogPersister, o as planTranslations, r as createProvider, s as replayProvider } from "./pipeline-sgl_q_op.js";
3
- import { a as ownedMessages, n as libraryCoverage } from "./library-BfSOBeBd.js";
4
- import { n as isDiagnosticError } from "./diagnostics-1onDF6Ua.js";
5
- import { a as table, r as plural } from "./output-CF9uvk_-.js";
6
- import { a as hasErrors, f as readErrors, g as usageError, h as targetLocales, m as scan, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-DSzWKU3C.js";
7
- import { r as EXIT } from "./types-Ds_vebja.js";
2
+ import { a as firstRequests, c as runTranslations, i as estimateUsage, n as catalogPersister, o as planTranslations, r as createProvider, s as replayProvider } from "./pipeline-BJSkkRYC.js";
3
+ import { a as ownedMessages, n as libraryCoverage } from "./library-tp_xqzSY.js";
4
+ import { n as isDiagnosticError } from "./diagnostics-LgIWyeSp.js";
5
+ import { a as table, r as plural } from "./output-D5tAt8q4.js";
6
+ import { a as hasErrors, f as readErrors, g as usageError, h as targetLocales, m as scan, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-B5KIO0q-.js";
7
+ import { r as EXIT } from "./types-xR2exI3L.js";
8
8
  // src/cli/commands/translate.ts
9
9
  /**
10
10
  * `vi18n translate [--locale l]… [--provider name] [--model id] [--tier t]
@@ -421,9 +421,11 @@ interface Scope {
421
421
  * Set only by `@menapo/vi18n/test` on the page scope (PLAN §5.22): the
422
422
  * message to render for every key, chosen with the descriptor that a
423
423
  * catalog map never sees (ids and pseudo modes, messages keyed by source
424
- * text). Builds never read it (INTERNALS §6 D189).
424
+ * text). Called as a method of the scope it renders for, so one hook
425
+ * serves the page and every `/server` scope. Builds never read it
426
+ * (INTERNALS §6 D189).
425
427
  */
426
- test?: (id: string, descriptor: CompiledDescriptor | undefined, text: string) => Message;
428
+ test?: (this: Scope, id: string, descriptor: CompiledDescriptor | undefined, text: string) => Message;
427
429
  /**
428
430
  * Dev only, set on the page scope by the in-context editor (`devtools`,
429
431
  * INTERNALS §2.18): hears every id the page looks up. Builds fold the
@@ -45,7 +45,7 @@ type Severity = "error" | "warning" | "info";
45
45
  * Every problem vi18n reports has one of these codes. The CLI prints them in
46
46
  * `--json` and as GitHub annotation titles (`vi18n(<code>)`).
47
47
  */
48
- type DiagnosticCode = "icu-syntax" | "icu-missing-other" | "icu-unsupported-type" | "icu-pattern-style" | "icu-pound-nested" | "icu-unknown-skeleton" | "icu-unknown-currency" | "icu-unknown-unit" | "icu-bidi-control" | "icu-unbalanced-isolate" | "icu-argument-mismatch" | "icu-tag-mismatch" | "icu-plural-missing-category" | "icu-plural-unused-category" | "icu-plural-one-literal" | "icu-apostrophe" | "icu-max-length" | "extract-dynamic-message" | "extract-non-literal-option" | "extract-invalid-manual-id" | "extract-module-scope" | "extract-html-sink" | "extract-captured-value" | "extract-wrapper-unused" | "extract-outside-include" | "extract-parse-error" | "extract-missing-compiler" | "extract-empty-root" | "id-collision" | "id-scheme-mismatch" | "catalog-parse" | "catalog-duplicate" | "catalog-wrapped" | "catalog-foreign-context" | "catalog-source-mismatch" | "catalog-fuzzy" | "catalog-invalid-translation" | "catalog-missing-translation" | "catalog-unused-entry" | "catalog-obsolete-dropped" | "catalog-safety-limit" | "catalog-drift" | "catalog-write-conflict" | "keep-missing-entry" | "import-parse" | "import-skipped" | "restore-git" | "merge-conflict" | "config-invalid" | "config-not-found" | "build-guard-skipped" | "build-dead-messages" | "ai-validation-failed" | "ai-identical-output" | "ai-provider-error" | "ai-missing-key" | "ai-cost-limit" | "migrate-dynamic-key" | "migrate-date-placeholder" | "migrate-manual" | "migrate-unconverted";
48
+ type DiagnosticCode = "icu-syntax" | "icu-missing-other" | "icu-unsupported-type" | "icu-pattern-style" | "icu-pound-nested" | "icu-unknown-skeleton" | "icu-unknown-currency" | "icu-unknown-unit" | "icu-bidi-control" | "icu-unbalanced-isolate" | "icu-argument-mismatch" | "icu-tag-mismatch" | "icu-plural-missing-category" | "icu-plural-unused-category" | "icu-plural-one-literal" | "icu-apostrophe" | "icu-max-length" | "extract-dynamic-message" | "extract-non-literal-option" | "extract-invalid-manual-id" | "extract-module-scope" | "extract-html-sink" | "extract-captured-value" | "extract-wrapper-unused" | "extract-outside-include" | "extract-parse-error" | "extract-missing-compiler" | "extract-empty-root" | "extract-repeated-text" | "extract-edited-text" | "id-collision" | "id-scheme-mismatch" | "catalog-parse" | "catalog-duplicate" | "catalog-wrapped" | "catalog-foreign-context" | "catalog-source-mismatch" | "catalog-fuzzy" | "catalog-invalid-translation" | "catalog-missing-translation" | "catalog-unused-entry" | "catalog-obsolete-dropped" | "catalog-safety-limit" | "catalog-drift" | "catalog-write-conflict" | "keep-missing-entry" | "import-parse" | "import-skipped" | "restore-git" | "rename-refused" | "merge-conflict" | "config-invalid" | "config-not-found" | "build-guard-skipped" | "build-dead-messages" | "ai-validation-failed" | "ai-identical-output" | "ai-provider-error" | "ai-missing-key" | "ai-cost-limit" | "migrate-dynamic-key" | "migrate-date-placeholder" | "migrate-manual" | "migrate-unconverted";
49
49
  interface Diagnostic {
50
50
  code: DiagnosticCode;
51
51
  severity: Severity;
@@ -194,6 +194,8 @@ interface MessageOccurrence {
194
194
  context?: string;
195
195
  maxLength?: number;
196
196
  callee: CalleeKind;
197
+ /** Under `vi18n-ignore`: the repeated-text check skips it. Set only when true. */
198
+ ignored?: true;
197
199
  /** Posix path relative to the config root (a `#:` reference). */
198
200
  file: string;
199
201
  /** 1-based position in the original file; 0 when not yet located. */
@@ -388,6 +390,12 @@ interface Vi18nConfig {
388
390
  * (`package.json#vi18n`). Default `[]`.
389
391
  */
390
392
  dependencies?: string[];
393
+ /**
394
+ * `vi18n check` and the language server warn when one literal text is
395
+ * written at this many `t()`/`rich()` call sites or more (at least 2);
396
+ * `false` turns the warning off. Default 3.
397
+ */
398
+ repeatedText?: number | false;
391
399
  };
392
400
  ids?: {
393
401
  /** Base64url characters of every generated id, 8–16. Default 12. Changing it is a re-key. */
@@ -601,6 +609,7 @@ interface ResolvedConfig {
601
609
  globals: string[];
602
610
  keep: string[];
603
611
  dependencies: string[];
612
+ repeatedText: number | false;
604
613
  };
605
614
  ids: {
606
615
  length: number;
@@ -11,6 +11,7 @@ const COMMAND_NAMES = [
11
11
  "export",
12
12
  "import",
13
13
  "restore",
14
+ "rename",
14
15
  "which",
15
16
  "merge-driver",
16
17
  "lsp",
@@ -1,6 +1,6 @@
1
- import { r as resolveDuplicates } from "./duplicates-CsUXRX2J.js";
2
- import { A as usableTranslation, E as entryKey, T as entryCanonical } from "./library-BfSOBeBd.js";
3
- import { p as tryCanonicalize } from "./validate-zv4-IZyZ.js";
1
+ import { r as resolveDuplicates } from "./duplicates-8cudcHNj.js";
2
+ import { A as usableTranslation, E as entryKey, T as entryCanonical } from "./library-tp_xqzSY.js";
3
+ import { m as tryCanonicalize } from "./validate-CgzaDdOY.js";
4
4
  // src/core/exchange/units.ts
5
5
  /**
6
6
  * Catalog exchange (PLAN §4.4, §5.19, INTERNALS §2.6.9): one format-neutral
@@ -1,4 +1,4 @@
1
- import { n as isDiagnosticError, o as ID_LENGTH, t as diagnosticError } from "./diagnostics-1onDF6Ua.js";
1
+ import { n as isDiagnosticError, o as ID_LENGTH, t as diagnosticError } from "./diagnostics-LgIWyeSp.js";
2
2
  import { isAbsolute, relative, sep } from "node:path";
3
3
  import { hash } from "node:crypto";
4
4
  // src/core/icu/skeleton.ts
@@ -2925,4 +2925,4 @@ function positionOf(text, char) {
2925
2925
  function hex(code) {
2926
2926
  return code.toString(16).toUpperCase().padStart(4, "0");
2927
2927
  }
2928
- export { parseIdScheme as _, displayPath as a, parseICU as b, mapLimit as c, withoutQuery as d, createCodec as f, isValidManualId as g, isManualId as h, MISSING as i, modulePath as l, idScheme as m, validateSource as n, hasExtension as o, tryCanonicalize as p, validateTranslation as r, isMissing as s, pluralCategories as t, toPosix as u, normalizeSource as v, quoteStarts as x, printICU as y };
2928
+ export { quoteStarts as S, isValidManualId as _, MISSING as a, printICU as b, isMissing as c, toPosix as d, withoutQuery as f, isManualId as g, idScheme as h, structureOf as i, mapLimit as l, tryCanonicalize as m, validateSource as n, displayPath as o, createCodec as p, validateTranslation as r, hasExtension as s, pluralCategories as t, modulePath as u, parseIdScheme as v, parseICU as x, normalizeSource as y };
@@ -3,7 +3,7 @@ import "node:crypto";
3
3
  import "node:fs";
4
4
  import "node:url";
5
5
  // src/core/version.ts
6
- const VERSION = "0.1.2";
6
+ const VERSION = "0.2.0";
7
7
  let fingerprint;
8
8
  let cacheVersionMemo;
9
9
  /**
@@ -15,7 +15,7 @@ let cacheVersionMemo;
15
15
  */
16
16
  function codeFingerprint() {
17
17
  if (fingerprint !== void 0) return fingerprint;
18
- fingerprint = "QSlL6IybBL_kcdW5";
18
+ fingerprint = "9m8al8863PEIiyMa";
19
19
  return fingerprint;
20
20
  }
21
21
  /** `VERSION` and `codeFingerprint()`: the version every cache key and `configHash` carries. */
@@ -1,11 +1,11 @@
1
- import { c as aggregateOccurrences, o as refMapper } from "./sync-CpL0Qsgw.js";
1
+ import { c as aggregateOccurrences, o as refMapper } from "./sync-BNIAwMhR.js";
2
2
  import { n as setCollector } from "./collect-CYATDjdo.js";
3
- import { I as listProjectFiles } from "./library-BfSOBeBd.js";
4
- import { c as mapLimit, u as toPosix } from "./validate-zv4-IZyZ.js";
5
- import { t as ABORT_CODES } from "./worker-BjzVqJVO.js";
6
- import { o as errorMessage } from "./output-CF9uvk_-.js";
3
+ import { I as listProjectFiles } from "./library-tp_xqzSY.js";
4
+ import { d as toPosix, l as mapLimit } from "./validate-CgzaDdOY.js";
5
+ import { t as ABORT_CODES } from "./worker-zlhNj4y3.js";
6
+ import { o as errorMessage } from "./output-D5tAt8q4.js";
7
7
  import { t as findViteConfig } from "./fs-ezCMZeDV.js";
8
- import { r as compareText } from "./project-DSzWKU3C.js";
8
+ import { r as compareText } from "./project-B5KIO0q-.js";
9
9
  import { createRequire } from "node:module";
10
10
  import { join, relative } from "node:path";
11
11
  import { pathToFileURL } from "node:url";
package/dist/vite.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as OutputOptions } from "./types-Cy2bPdSg.js";
1
+ import { n as OutputOptions } from "./types-_4UdFhR9.js";
2
2
  import { Plugin, Rolldown } from "vite";
3
3
  /** Options of `vi18n()`. Everything else comes from `vi18n.config.ts`. */
4
4
  interface Vi18nPluginOptions {
package/dist/vite.js CHANGED
@@ -1,17 +1,17 @@
1
- import { f as createCodec, r as validateTranslation, u as toPosix } from "./validate-zv4-IZyZ.js";
2
- import { a as writeGenFile, c as aggregateOccurrences, l as configHash, s as scanProject, t as syncCatalog } from "./sync-CpL0Qsgw.js";
3
- import { a as hasRoutes, c as toRuntimeConfig, o as normalizeBase, r as loadConfig, s as pseudoActive } from "./load-BFLLqY8x.js";
4
- import { n as cacheVersion, t as VERSION } from "./version-BFs370Ce.js";
5
- import { a as DEFAULT_IMPORT_SOURCES, n as isDiagnosticError, t as diagnosticError } from "./diagnostics-1onDF6Ua.js";
6
- import { a as compareText, c as assetCatalogsModule, d as hash8, i as bundleJson, l as serverCatalogVersion, n as compileMessage, o as serverCatalogJson, r as STATE_KEY, s as SERVER_FILES, t as compileLocales, u as serverCatalogsDir } from "./locales-DxLDrx-h.js";
7
- import { C as langFromId, D as locateLiteral, O as listImports, S as armRawParsing, T as lineColumn, a as scanModule, c as USE_T, n as sourceNeedles, o as GLUE, s as KEYS_MARKER, t as lastName, w as parseModule } from "./sources-DuOdM02f.js";
1
+ import { d as toPosix, p as createCodec, r as validateTranslation } from "./validate-CgzaDdOY.js";
2
+ import { a as writeGenFile, c as aggregateOccurrences, l as configHash, s as scanProject, t as syncCatalog } from "./sync-BNIAwMhR.js";
3
+ import { a as hasRoutes, c as toRuntimeConfig, o as normalizeBase, r as loadConfig, s as pseudoActive } from "./load-BSIeGJ5v.js";
4
+ import { n as cacheVersion, t as VERSION } from "./version-DC-J5WvV.js";
5
+ import { a as DEFAULT_IMPORT_SOURCES, n as isDiagnosticError, t as diagnosticError } from "./diagnostics-LgIWyeSp.js";
6
+ import { a as compareText, c as assetCatalogsModule, d as hash8, i as bundleJson, l as serverCatalogVersion, n as compileMessage, o as serverCatalogJson, r as STATE_KEY, s as SERVER_FILES, t as compileLocales, u as serverCatalogsDir } from "./locales-D0U-yVRm.js";
7
+ import { C as langFromId, D as locateLiteral, S as armRawParsing, T as lineColumn, a as scanModule, c as USE_T, k as listImports, n as sourceNeedles, o as GLUE, s as KEYS_MARKER, t as lastName, w as parseModule } from "./sources-DNVbYsgs.js";
8
8
  import { a as pathTable, r as localizePath } from "./url-Bpc6wLea.js";
9
- import { A as usableTranslation, E as entryKey, F as isIncluded, L as compareText$2, R as dependenciesOf, T as entryCanonical, b as compareText$1, c as contentHash, h as updateCatalogFile, l as loadCatalogSet, n as libraryCoverage, o as catalogLayout, r as libraryIds, s as catalogPath, t as MESSAGES_FILE, z as dependencyRef } from "./library-BfSOBeBd.js";
10
- import { t as findCollisions } from "./collisions-uMTuq36M.js";
9
+ import { A as usableTranslation, E as entryKey, F as isIncluded, L as compareText$2, R as dependenciesOf, T as entryCanonical, b as compareText$1, c as contentHash, h as updateCatalogFile, l as loadCatalogSet, n as libraryCoverage, o as catalogLayout, r as libraryIds, s as catalogPath, t as MESSAGES_FILE, z as dependencyRef } from "./library-tp_xqzSY.js";
10
+ import { t as findCollisions } from "./collisions-CDSdtLQm.js";
11
11
  import { t as activeCollector } from "./collect-CYATDjdo.js";
12
- import { n as injectHooks, t as findCapturedValues } from "./captured-CTjjDF5o.js";
13
- import { r as resolveDuplicates } from "./duplicates-CsUXRX2J.js";
14
- import { a as expandMacros, o as macroNames } from "./worker-BjzVqJVO.js";
12
+ import { n as injectHooks, t as findCapturedValues } from "./captured-DfLk50Ji.js";
13
+ import { r as resolveDuplicates } from "./duplicates-8cudcHNj.js";
14
+ import { a as expandMacros, o as macroNames } from "./worker-zlhNj4y3.js";
15
15
  import { basename, dirname, isAbsolute, join, posix, relative, resolve } from "node:path";
16
16
  import { hash } from "node:crypto";
17
17
  import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
@@ -5068,7 +5068,7 @@ var SerialDebounce = class {
5068
5068
  /** Quiet period before a run: longer than the writer's, so a burst of edits is one run. */
5069
5069
  const DEV_TRANSLATE_DELAY_MS = 1500;
5070
5070
  const loadAi = async () => ({
5071
- pipeline: await import("./pipeline-B30irGMD.js"),
5071
+ pipeline: await import("./pipeline-BeCc441z.js"),
5072
5072
  limits: await import("./concurrency-BCY_4zcr.js")
5073
5073
  });
5074
5074
  /** The diagnostic a problem carries: a diagnostic error's, or the problem itself when it is one. */
@@ -5383,7 +5383,7 @@ function dockPage() {
5383
5383
  * The persister lives with the AI code and is imported on the first save:
5384
5384
  * a dev server whose page never saves loads none of it.
5385
5385
  */
5386
- const loadPipeline = () => import("./pipeline-B30irGMD.js");
5386
+ const loadPipeline = () => import("./pipeline-BeCc441z.js");
5387
5387
  /** Each locale's catalog entries by key, after the duplicate pick, for one answer. */
5388
5388
  function entriesOf(store, set) {
5389
5389
  const layout = catalogLayout(store.config);
@@ -6840,8 +6840,12 @@ function htmlPlugin(store, outputs) {
6840
6840
  settings.command = env.command;
6841
6841
  html.transformIndexHtml.order = env.command === "serve" ? "pre" : "post";
6842
6842
  },
6843
- configResolved(config) {
6844
- settings.viteConfig = config;
6843
+ configResolved: {
6844
+ order: "pre",
6845
+ handler(config) {
6846
+ settings.viteConfig = config;
6847
+ if (config.plugins.some((p) => p.name?.startsWith("vite-plugin-sveltekit"))) delete html.transformIndexHtml;
6848
+ }
6845
6849
  },
6846
6850
  generateBundle: {
6847
6851
  order: "post",
@@ -1,9 +1,9 @@
1
- import { n as isDiagnosticError } from "./diagnostics-1onDF6Ua.js";
2
- import { w as parseModule } from "./sources-DuOdM02f.js";
3
- import { y as printICU } from "./validate-zv4-IZyZ.js";
4
- import { B as objectProperties, E as identifierName, U as templateKeys, W as unwrap, f as readString, g as skipSpace, h as skipBalanced, o as importLineEdit, p as readTemplate, r as argumentEnd, v as vueRegions, w as childEntries, x as analyzeModule, z as memberParts } from "./migrate-D7TNl6SD.js";
5
- import { b as pushLiteral, m as flattenTree, s as entry, t as MODULE_EXTENSIONS, v as parseJson, x as yamlKeyLines, y as parseYaml } from "./i18next-D66Icz3L.js";
6
- import { t as ModuleBuilder } from "./rewrite-hAcRJwiZ.js";
1
+ import { n as isDiagnosticError } from "./diagnostics-LgIWyeSp.js";
2
+ import { w as parseModule } from "./sources-DNVbYsgs.js";
3
+ import { b as printICU } from "./validate-CgzaDdOY.js";
4
+ import { B as objectProperties, E as identifierName, U as templateKeys, W as unwrap, f as readString, g as skipSpace, h as skipBalanced, o as importLineEdit, p as readTemplate, r as argumentEnd, v as vueRegions, w as childEntries, x as analyzeModule, z as memberParts } from "./migrate-ChDGhlC-.js";
5
+ import { b as pushLiteral, m as flattenTree, s as entry, t as MODULE_EXTENSIONS, v as parseJson, x as yamlKeyLines, y as parseYaml } from "./i18next-COO6o0tX.js";
6
+ import { t as ModuleBuilder } from "./rewrite-BwzXoBiA.js";
7
7
  import { extname } from "node:path";
8
8
  import { readFileSync } from "node:fs";
9
9
  // src/cli/commands/migrate/vue-i18n.ts
@@ -1,11 +1,11 @@
1
- import { r as resolveDuplicates } from "./duplicates-CsUXRX2J.js";
2
- import { p as tryCanonicalize } from "./validate-zv4-IZyZ.js";
3
- import { E as entryKey } from "./library-BfSOBeBd.js";
4
- import { r as entrySource } from "./units-VVLgQ7x7.js";
5
- import { n as sourceContext } from "./exchange-DYG9RZoT.js";
6
- import { m as scan, o as loadCatalogs, r as compareText, s as loadProject, t as CliExit, y as localeOrder } from "./project-DSzWKU3C.js";
7
- import { i as rootRelative, r as plural } from "./output-CF9uvk_-.js";
8
- import { r as EXIT } from "./types-Ds_vebja.js";
1
+ import { r as resolveDuplicates } from "./duplicates-8cudcHNj.js";
2
+ import { m as tryCanonicalize } from "./validate-CgzaDdOY.js";
3
+ import { E as entryKey } from "./library-tp_xqzSY.js";
4
+ import { r as entrySource } from "./units-DPPfCN7j.js";
5
+ import { n as sourceContext } from "./exchange-DjwlrTQ9.js";
6
+ import { m as scan, o as loadCatalogs, r as compareText, s as loadProject, t as CliExit, y as localeOrder } from "./project-B5KIO0q-.js";
7
+ import { i as rootRelative, r as plural } from "./output-D5tAt8q4.js";
8
+ import { r as EXIT } from "./types-xR2exI3L.js";
9
9
  // src/cli/commands/which.ts
10
10
  /**
11
11
  * `vi18n which <id|prefix|text>` (PLAN §4.3, §5.19, INTERNALS §2.14): from
@@ -1,7 +1,7 @@
1
- import { r as libraryIds } from "./library-BfSOBeBd.js";
2
- import { f as createCodec } from "./validate-zv4-IZyZ.js";
3
- import { n as isDiagnosticError, t as diagnosticError } from "./diagnostics-1onDF6Ua.js";
4
- import { C as langFromId, D as locateLiteral, O as listImports, S as armRawParsing, T as lineColumn, _ as insertImport, a as scanModule, f as TYPE_KEYS, g as forEachBindingName, n as sourceNeedles, r as sourceSpecifiers, v as isNode, w as parseModule, x as unwrap, y as keyName } from "./sources-DuOdM02f.js";
1
+ import { r as libraryIds } from "./library-tp_xqzSY.js";
2
+ import { p as createCodec } from "./validate-CgzaDdOY.js";
3
+ import { n as isDiagnosticError, t as diagnosticError } from "./diagnostics-LgIWyeSp.js";
4
+ import { C as langFromId, D as locateLiteral, S as armRawParsing, T as lineColumn, _ as insertImport, a as scanModule, f as TYPE_KEYS, g as forEachBindingName, k as listImports, n as sourceNeedles, r as sourceSpecifiers, v as isNode, w as parseModule, x as unwrap, y as keyName } from "./sources-DNVbYsgs.js";
5
5
  import { createRequire } from "node:module";
6
6
  import { dirname } from "node:path";
7
7
  import { hash } from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@menapo/vi18n",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "i18n toolkit for Vite: source-as-id messages, per-route translation bundles, SSR and in-place locale switching in every framework",
5
5
  "keywords": [
6
6
  "gettext",
@@ -1 +0,0 @@
1
- export { n as createI18nextAdapter } from "./i18next-D66Icz3L.js";
@@ -1 +0,0 @@
1
- export { c as migrate } from "./migrate-D7TNl6SD.js";