@vielzeug/lingua 2.4.1 → 26.10.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 (83) hide show
  1. package/README.md +9 -28
  2. package/dist/_bounded-cache.cjs +1 -1
  3. package/dist/_bounded-cache.cjs.map +1 -1
  4. package/dist/_bounded-cache.js +1 -9
  5. package/dist/_bounded-cache.js.map +1 -1
  6. package/dist/_catalog.cjs +1 -1
  7. package/dist/_catalog.cjs.map +1 -1
  8. package/dist/_catalog.js +1 -49
  9. package/dist/_catalog.js.map +1 -1
  10. package/dist/_dev.cjs +1 -1
  11. package/dist/_dev.cjs.map +1 -1
  12. package/dist/_dev.d.ts +1 -1
  13. package/dist/_dev.d.ts.map +1 -1
  14. package/dist/_dev.js +1 -6
  15. package/dist/_dev.js.map +1 -1
  16. package/dist/_locale.cjs +1 -1
  17. package/dist/_locale.cjs.map +1 -1
  18. package/dist/_locale.js +1 -25
  19. package/dist/_locale.js.map +1 -1
  20. package/dist/_resources.cjs +1 -1
  21. package/dist/_resources.cjs.map +1 -1
  22. package/dist/_resources.d.ts +9 -3
  23. package/dist/_resources.d.ts.map +1 -1
  24. package/dist/_resources.js +1 -50
  25. package/dist/_resources.js.map +1 -1
  26. package/dist/_template.cjs +1 -1
  27. package/dist/_template.cjs.map +1 -1
  28. package/dist/_template.d.ts +2 -1
  29. package/dist/_template.d.ts.map +1 -1
  30. package/dist/_template.js +1 -31
  31. package/dist/_template.js.map +1 -1
  32. package/dist/catalog.cjs +1 -1
  33. package/dist/catalog.cjs.map +1 -1
  34. package/dist/catalog.d.ts +10 -10
  35. package/dist/catalog.d.ts.map +1 -1
  36. package/dist/catalog.js +1 -9
  37. package/dist/catalog.js.map +1 -1
  38. package/dist/errors.cjs +1 -1
  39. package/dist/errors.cjs.map +1 -1
  40. package/dist/errors.d.ts +4 -0
  41. package/dist/errors.d.ts.map +1 -1
  42. package/dist/errors.js +1 -13
  43. package/dist/errors.js.map +1 -1
  44. package/dist/format.cjs +1 -1
  45. package/dist/format.cjs.map +1 -1
  46. package/dist/format.d.ts.map +1 -1
  47. package/dist/format.js +1 -84
  48. package/dist/format.js.map +1 -1
  49. package/dist/i18n.cjs +1 -1
  50. package/dist/i18n.cjs.map +1 -1
  51. package/dist/i18n.d.ts +11 -7
  52. package/dist/i18n.d.ts.map +1 -1
  53. package/dist/i18n.js +1 -90
  54. package/dist/i18n.js.map +1 -1
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.d.ts +4 -4
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +1 -5
  59. package/dist/lingua.cjs +1 -1
  60. package/dist/lingua.cjs.map +1 -1
  61. package/dist/lingua.iife.js +1 -1
  62. package/dist/lingua.iife.js.map +1 -1
  63. package/dist/lingua.js +1 -1
  64. package/dist/lingua.js.map +1 -1
  65. package/dist/ripple.cjs +2 -0
  66. package/dist/ripple.cjs.map +1 -0
  67. package/dist/ripple.d.ts +24 -0
  68. package/dist/ripple.d.ts.map +1 -0
  69. package/dist/ripple.js +2 -0
  70. package/dist/ripple.js.map +1 -0
  71. package/dist/translator.cjs +1 -1
  72. package/dist/translator.cjs.map +1 -1
  73. package/dist/translator.d.ts +15 -10
  74. package/dist/translator.d.ts.map +1 -1
  75. package/dist/translator.js +1 -67
  76. package/dist/translator.js.map +1 -1
  77. package/dist/types.d.ts +38 -14
  78. package/dist/types.d.ts.map +1 -1
  79. package/dist/validate.cjs +1 -1
  80. package/dist/validate.cjs.map +1 -1
  81. package/dist/validate.js +1 -45
  82. package/dist/validate.js.map +1 -1
  83. package/package.json +25 -8
package/dist/validate.js CHANGED
@@ -1,46 +1,2 @@
1
- import { compileCatalog as e, isPluralMessage as t } from "./_catalog.js";
2
- import { canonicalLocale as n } from "./_locale.js";
3
- //#region src/validate.ts
4
- function r(r, i) {
5
- e(r);
6
- let a = n(i), o = new Intl.PluralRules(a).resolvedOptions().pluralCategories, s = [], c = (e, n) => {
7
- if (typeof e != "string") {
8
- if (t(e)) {
9
- for (let t of o) Object.hasOwn(e.plural, t) || s.push({
10
- key: n,
11
- locale: a,
12
- missing: t
13
- });
14
- return;
15
- }
16
- for (let [t, r] of Object.entries(e)) c(r, n ? `${n}.${t}` : t);
17
- }
18
- };
19
- for (let [e, t] of Object.entries(r)) c(t, e);
20
- return s;
21
- }
22
- function i(t) {
23
- let n = Object.keys(t), r = /* @__PURE__ */ new Map(), i = [], a = [];
24
- for (let i of n) r.set(i, new Set(e(t[i]).keys()));
25
- let o = n[0], s = r.get(o);
26
- for (let e of n) {
27
- if (e === o) continue;
28
- let t = r.get(e);
29
- for (let n of s) t.has(n) || i.push({
30
- key: n,
31
- locale: e
32
- });
33
- for (let n of t) s.has(n) || a.push({
34
- key: n,
35
- locale: e
36
- });
37
- }
38
- return {
39
- extra: a,
40
- missing: i
41
- };
42
- }
43
- //#endregion
44
- export { i as compareCatalogs, r as validateCatalog };
45
-
1
+ import{compileCatalog as e,isPluralMessage as t}from"./_catalog.js";import{canonicalLocale as n}from"./_locale.js";function validateCatalog(r,i){e(r);let a=n(i),o=new Intl.PluralRules(a).resolvedOptions().pluralCategories,s=[],visit=(e,n)=>{if(typeof e!=`string`){if(t(e)){for(let t of o)Object.hasOwn(e.plural,t)||s.push({key:n,locale:a,missing:t});return}for(let[t,r]of Object.entries(e))visit(r,n?`${n}.${t}`:t)}};for(let[e,t]of Object.entries(r))visit(t,e);return s}function compareCatalogs(t){let n=Object.keys(t),r=new Map,i=[],a=[];for(let i of n)r.set(i,new Set(e(t[i]).keys()));let o=n[0],s=r.get(o);for(let e of n){if(e===o)continue;let t=r.get(e);for(let n of s)t.has(n)||i.push({key:n,locale:e});for(let n of t)s.has(n)||a.push({key:n,locale:e})}return{extra:a,missing:i}}export{compareCatalogs,validateCatalog};
46
2
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { compileCatalog, isPluralMessage } from './_catalog';\nimport { canonicalLocale } from './_locale';\nimport type { Catalog, CatalogNode, Catalogs, Locale } from './types';\n\nexport type ValidationIssue = {\n key: string;\n locale: Locale;\n missing: Intl.LDMLPluralRule;\n};\n\nexport type CatalogComparison = {\n readonly missing: ReadonlyArray<{ key: string; locale: Locale }>;\n readonly extra: ReadonlyArray<{ key: string; locale: Locale }>;\n};\n\n/** Explicit tooling API. Runtime never loads validation code or emits asynchronous catalog warnings. */\nexport function validateCatalog(catalog: Catalog, locale: Locale): ValidationIssue[] {\n compileCatalog(catalog);\n\n const canonical = canonicalLocale(locale);\n const categories = new Intl.PluralRules(canonical).resolvedOptions().pluralCategories;\n const issues: ValidationIssue[] = [];\n\n const visit = (node: CatalogNode, key: string): void => {\n if (typeof node === 'string') return;\n\n if (isPluralMessage(node)) {\n for (const missing of categories) {\n if (!Object.hasOwn(node.plural, missing)) issues.push({ key, locale: canonical, missing });\n }\n\n return;\n }\n\n for (const [childKey, child] of Object.entries(node)) visit(child, key ? `${key}.${childKey}` : childKey);\n };\n\n for (const [key, node] of Object.entries(catalog)) visit(node, key);\n\n return issues;\n}\n\n/** Compares catalog key sets across locales. Reports keys missing in each target locale and keys present in targets but absent from the base. */\nexport function compareCatalogs<C extends Catalog>(catalogs: Catalogs<C>): CatalogComparison {\n const locales = Object.keys(catalogs);\n const keySets = new Map<Locale, Set<string>>();\n const missing: Array<{ key: string; locale: Locale }> = [];\n const extra: Array<{ key: string; locale: Locale }> = [];\n\n for (const locale of locales) {\n keySets.set(locale, new Set(compileCatalog(catalogs[locale]).keys()));\n }\n\n const base = locales[0];\n const baseKeys = keySets.get(base)!;\n\n for (const locale of locales) {\n if (locale === base) continue;\n const targetKeys = keySets.get(locale)!;\n\n for (const key of baseKeys) {\n if (!targetKeys.has(key)) missing.push({ key, locale });\n }\n\n for (const key of targetKeys) {\n if (!baseKeys.has(key)) extra.push({ key, locale });\n }\n }\n\n return { extra, missing };\n}\n"],"mappings":";;;AAgBA,SAAgB,EAAgB,GAA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":3,"file":"validate.js","names":[],"sources":["../src/validate.ts"],"sourcesContent":["import { compileCatalog, isPluralMessage } from './_catalog';\nimport { canonicalLocale } from './_locale';\nimport type { Catalog, CatalogNode, Catalogs, Locale } from './types';\n\nexport type ValidationIssue = {\n key: string;\n locale: Locale;\n missing: Intl.LDMLPluralRule;\n};\n\nexport type CatalogComparison = {\n readonly missing: ReadonlyArray<{ key: string; locale: Locale }>;\n readonly extra: ReadonlyArray<{ key: string; locale: Locale }>;\n};\n\n/** Explicit tooling API. Runtime never loads validation code or emits asynchronous catalog warnings. */\nexport function validateCatalog(catalog: Catalog, locale: Locale): ValidationIssue[] {\n compileCatalog(catalog);\n\n const canonical = canonicalLocale(locale);\n const categories = new Intl.PluralRules(canonical).resolvedOptions().pluralCategories;\n const issues: ValidationIssue[] = [];\n\n const visit = (node: CatalogNode, key: string): void => {\n if (typeof node === 'string') return;\n\n if (isPluralMessage(node)) {\n for (const missing of categories) {\n if (!Object.hasOwn(node.plural, missing)) issues.push({ key, locale: canonical, missing });\n }\n\n return;\n }\n\n for (const [childKey, child] of Object.entries(node)) visit(child, key ? `${key}.${childKey}` : childKey);\n };\n\n for (const [key, node] of Object.entries(catalog)) visit(node, key);\n\n return issues;\n}\n\n/** Compares catalog key sets across locales. Reports keys missing in each target locale and keys present in targets but absent from the base. */\nexport function compareCatalogs<C extends Catalog>(catalogs: Catalogs<C>): CatalogComparison {\n const locales = Object.keys(catalogs);\n const keySets = new Map<Locale, Set<string>>();\n const missing: Array<{ key: string; locale: Locale }> = [];\n const extra: Array<{ key: string; locale: Locale }> = [];\n\n for (const locale of locales) {\n keySets.set(locale, new Set(compileCatalog(catalogs[locale]).keys()));\n }\n\n const base = locales[0];\n const baseKeys = keySets.get(base)!;\n\n for (const locale of locales) {\n if (locale === base) continue;\n const targetKeys = keySets.get(locale)!;\n\n for (const key of baseKeys) {\n if (!targetKeys.has(key)) missing.push({ key, locale });\n }\n\n for (const key of targetKeys) {\n if (!baseKeys.has(key)) extra.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,MAAO,CAAE,QAAO,SAAQ,CAC1B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vielzeug/lingua",
3
- "version": "2.4.1",
4
- "description": "Explicit typed localization with pluralization, lazy locale catalogs, and SSR hydration",
3
+ "version": "26.10.0",
4
+ "description": "Typed i18n with pluralization and lazy locale loading",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/helmuthdu/vielzeug",
@@ -28,6 +28,11 @@
28
28
  "require": "./dist/format.cjs",
29
29
  "types": "./dist/format.d.ts"
30
30
  },
31
+ "./ripple": {
32
+ "import": "./dist/ripple.js",
33
+ "require": "./dist/ripple.cjs",
34
+ "types": "./dist/ripple.d.ts"
35
+ },
31
36
  "./validate": {
32
37
  "import": "./dist/validate.js",
33
38
  "require": "./dist/validate.cjs",
@@ -39,6 +44,9 @@
39
44
  "format": [
40
45
  "dist/format.d.ts"
41
46
  ],
47
+ "ripple": [
48
+ "dist/ripple.d.ts"
49
+ ],
42
50
  "validate": [
43
51
  "dist/validate.d.ts"
44
52
  ]
@@ -50,21 +58,30 @@
50
58
  "registry": "https://registry.npmjs.org/"
51
59
  },
52
60
  "scripts": {
53
- "build": "pnpm run typecheck && vite build && pnpm run build:bundle && pnpm run build:types && pnpm run verify:exports",
61
+ "build": "pnpm --silent run typecheck && vite build && pnpm --silent run build:bundle && pnpm --silent run build:types && pnpm --silent run verify:exports",
54
62
  "build:bundle": "vite build --config vite.bundle.config.ts",
55
63
  "build:types": "tsc -p tsconfig.declarations.json",
56
64
  "fix": "biome check --write src",
57
65
  "lint": "biome ci src",
58
- "prepublishOnly": "pnpm run build",
66
+ "prepublishOnly": "pnpm --silent run build",
59
67
  "preview": "vite preview",
60
- "test": "pnpm run typecheck && vitest",
68
+ "test": "pnpm --silent run typecheck && vitest",
61
69
  "typecheck": "tsc -p tsconfig.json --noEmit",
62
70
  "verify:exports": "node ./scripts/verify-exports.mjs"
63
71
  },
72
+ "peerDependencies": {
73
+ "@vielzeug/ripple": "^26.10.0"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "@vielzeug/ripple": {
77
+ "optional": true
78
+ }
79
+ },
64
80
  "devDependencies": {
65
- "@types/node": "^26.2.0",
81
+ "@types/node": "^26.6.2",
82
+ "@vielzeug/ripple": "26.10.0",
66
83
  "typescript": "^6.0.3",
67
- "vite": "^8.2.1",
68
- "vitest": "^4.1.10"
84
+ "vite": "^8.3.0",
85
+ "vitest": "^5.0.1"
69
86
  }
70
87
  }