@menapo/vi18n 0.1.1 → 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.
- package/README.md +19 -0
- package/dist/{apply-Bre-lY9J.js → apply-Bg-3rB2m.js} +69 -89
- package/dist/{captured-Bj8bO6vd.js → captured-DfLk50Ji.js} +196 -217
- package/dist/{check-BIKEuu6B.js → check-CunekuYs.js} +76 -85
- package/dist/cli.js +2 -3
- package/dist/{collect-Cx4_SKOe.js → collect-CYATDjdo.js} +1 -2
- package/dist/collisions-CDSdtLQm.js +215 -0
- package/dist/{compile-Cc97JaW2.js → compile-DqkofbiO.js} +376 -331
- package/dist/compile-hva0qjhZ.js +240 -0
- package/dist/concurrency-BCY_4zcr.js +1 -0
- package/dist/concurrency-Dy2ny50V.js +107 -0
- package/dist/config.d.ts +1 -5
- package/dist/config.js +4 -5
- package/dist/{types-D3QGM8XO.js → diagnostics-LgIWyeSp.js} +28 -27
- package/dist/{dir-zw6bGMKQ.js → dir-TGLYuOZb.js} +34 -37
- package/dist/{duplicates-yuRljQ6h.js → duplicates-8cudcHNj.js} +10 -27
- package/dist/engine-ecRD8-IE.js +556 -0
- package/dist/engine.d.ts +1 -5
- package/dist/engine.js +297 -168
- package/dist/exchange-DjwlrTQ9.js +41 -0
- package/dist/{exclude-Du-Zd_qI.js → exclude-BFETmvde.js} +2 -3
- package/dist/{export-C9Sy6UWv.js → export-D2tsqWIr.js} +17 -38
- package/dist/{extract-C3S8btx0.js → extract-BxYchVmY.js} +114 -82
- package/dist/{formats-9unqj_fZ.js → formats-BaryZ2N7.js} +352 -276
- package/dist/fs-ezCMZeDV.js +52 -0
- package/dist/i18next-COO6o0tX.js +1907 -0
- package/dist/i18next-Dr7DCQlQ.js +1 -0
- package/dist/{import-nANvQutw.js → import-vSC29Cn4.js} +81 -75
- package/dist/index.d.ts +1 -13
- package/dist/index.js +14 -16
- package/dist/{init-C2ScuW6a.js → init-Cc7A-8VX.js} +466 -501
- package/dist/{library-D5CWvTQs.js → library-tp_xqzSY.js} +975 -451
- package/dist/lingui-BnnlqGXT.js +902 -0
- package/dist/lint.d.ts +0 -4
- package/dist/lint.js +70 -82
- package/dist/{load-gW-oJt1Q.js → load-BSIeGJ5v.js} +275 -148
- package/dist/{load-CQRz4PpM.js → load-SSrAeJVB.js} +1214 -1116
- package/dist/{locales-DX4MOBFE.js → locales-D0U-yVRm.js} +271 -237
- package/dist/{lsp-RMMMc88P.js → lsp-DvC11pBZ.js} +4 -5
- package/dist/{match-BGr8EXB3.js → match-BLDcj610.js} +11 -4
- package/dist/{mcp-CHVwBoRP.js → mcp-D2zzOTBy.js} +4 -5
- package/dist/{merge-driver-BTX87aVm.js → merge-driver-BLI8OtAc.js} +138 -122
- package/dist/migrate-1r43OBfe.js +1 -0
- package/dist/migrate-ChDGhlC-.js +2169 -0
- package/dist/{openai-CTaMDcl-.js → openai-CLn4puY8.js} +128 -87
- package/dist/{output-DWE3SIUA.js → output-D5tAt8q4.js} +15 -9
- package/dist/parse.d.ts +1 -3
- package/dist/parse.js +7 -8
- package/dist/{pipeline-C9Dbotkh.js → pipeline-BJSkkRYC.js} +387 -359
- package/dist/{pipeline-DbX6rlo5.js → pipeline-BeCc441z.js} +1 -1
- package/dist/project-B5KIO0q-.js +544 -0
- package/dist/{pseudo-DRv30iN5.js → pseudo-B2DUpoLu.js} +126 -3
- package/dist/{raw-C4Y6vyGY.js → raw-YsYZMS9n.js} +52 -29
- package/dist/react-intl-C8JehBBL.js +634 -0
- package/dist/rename-ZVGq9ZG1.js +577 -0
- package/dist/repeated-uuI1tUGg.js +85 -0
- package/dist/restore-xlBIrtRt.js +199 -0
- package/dist/rewrite-BwzXoBiA.js +415 -0
- package/dist/{rich-DCUKl5HM.js → rich-ApY1Dm4S.js} +35 -28
- package/dist/rolldown-runtime-C1I3wEg2.js +43 -0
- package/dist/{rolldown-runtime-D7D4PA-g.js → rolldown-runtime-D8jQpDG7.js} +1 -2
- package/dist/run-CQ9pDLSa.js +674 -0
- package/dist/scan-worker.d.ts +2 -4
- package/dist/scan-worker.js +1 -1
- package/dist/{scoped-BMYpSthj.js → scoped-h3KE8XWW.js} +3 -4
- package/dist/{server-Da1Ot9IN.js → server-Br8tAuG2.js} +312 -386
- package/dist/{server-deBOq2vq.js → server-DJRpUQVZ.js} +1059 -333
- package/dist/server.d.ts +1 -17
- package/dist/server.js +419 -379
- package/dist/{sitemap-DJXzKoza.js → sitemap-CSAkm6oi.js} +21 -33
- package/dist/{sources-D19czDSA.js → sources-DNVbYsgs.js} +713 -373
- package/dist/{status-zr4jY59Y.js → status-q6M3rBrh.js} +30 -30
- package/dist/{stdio-FPOKQAgu.js → stdio-D9kTzyqB.js} +2 -4
- package/dist/{stdio-CVaJfxA7.js → stdio-FWIVU3P4.js} +1 -2
- package/dist/sync-BNIAwMhR.js +1352 -0
- package/dist/{t-DC-c9zE5.js → t-gvEXx25s.js} +76 -53
- package/dist/test.d.ts +5 -16
- package/dist/test.js +126 -56
- package/dist/translate-BP4iVhOR.js +336 -0
- package/dist/{ts-BaU5yOf0.js → ts-BX6kwig5.js} +25 -14
- package/dist/{types-DtvQ7UdD.js → types-3kwyaCAm.js} +1 -2
- package/dist/{types-DsdWBG0b.d.ts → types-B4wNX6PA.d.ts} +6 -8
- package/dist/{types-CgUCkFU1.d.ts → types-_4UdFhR9.d.ts} +24 -21
- package/dist/types-xR2exI3L.js +42 -0
- package/dist/{units-CQ5Q99RC.js → units-DPPfCN7j.js} +7 -16
- package/dist/{url-CRfCOhUI.js → url-Bpc6wLea.js} +24 -11
- package/dist/{url-CsBkRaJy.js → url-D2_VlEeH.js} +25 -12
- package/dist/{validate-BxpupdAf.js → validate-CgzaDdOY.js} +690 -377
- package/dist/{validate-D6DJepZv.js → validate-PGgMsasz.js} +3 -5
- package/dist/{version-Byqi2guX.js → version-DC-J5WvV.js} +3 -5
- package/dist/{vite-scan-CT_vsp4g.js → vite-scan-kM8Ta3rO.js} +87 -92
- package/dist/vite.d.ts +2 -6
- package/dist/vite.js +6500 -6032
- package/dist/vue-i18n-_uIXlFVh.js +806 -0
- package/dist/{which-BOemZ5Q8.js → which-DFWk_KwN.js} +44 -37
- package/dist/{worker-84U6uYB3.js → worker-zlhNj4y3.js} +454 -608
- package/package.json +5 -5
- package/dist/check-HsmmpJZg.js +0 -1
- package/dist/codec-DuvU2VQy.js +0 -207
- package/dist/collisions-CfpZU8e4.js +0 -217
- package/dist/compile-BaDh0cHG.js +0 -245
- package/dist/concurrency-C9UUWuDC.js +0 -96
- package/dist/concurrency-DONL7t4V.js +0 -1
- package/dist/engine-C2ENBRJe.js +0 -531
- package/dist/i18next-9HAoxwUI.js +0 -1
- package/dist/i18next-BEJgv_S8.js +0 -1596
- package/dist/lingui-zUiCl9Um.js +0 -833
- package/dist/messages-BfjIExyB.js +0 -166
- package/dist/migrate-IpLDMXmq.js +0 -1484
- package/dist/migrate-rCQuOGsf.js +0 -1
- package/dist/project-Bw9UPIdx.js +0 -1046
- package/dist/project-C4GpaN-n.js +0 -381
- package/dist/react-intl-BP0u-D5m.js +0 -519
- package/dist/restore-CiYv-jxS.js +0 -175
- package/dist/rewrite-EsIw_lsq.js +0 -803
- package/dist/run-BEcnBbu-.js +0 -694
- package/dist/runtime-DTMmliT1.js +0 -64
- package/dist/sync-B9V2KFwb.js +0 -658
- package/dist/translate-CQnJfLjO.js +0 -299
- package/dist/types-wSh9fCBY.js +0 -11
- package/dist/vue-i18n-g0iGy6CZ.js +0 -651
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as createI18nextAdapter } from "./i18next-COO6o0tX.js";
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { t as readImport } from "./formats-9unqj_fZ.js";
|
|
8
|
-
import { t as applyImport } from "./apply-Bre-lY9J.js";
|
|
1
|
+
import { t as applyImport } from "./apply-Bg-3rB2m.js";
|
|
2
|
+
import { t as readImport } from "./formats-BaryZ2N7.js";
|
|
3
|
+
import { i as rootRelative, o as errorMessage, r as plural } from "./output-D5tAt8q4.js";
|
|
4
|
+
import { n as sourceContext, t as applyToCatalog } from "./exchange-DjwlrTQ9.js";
|
|
5
|
+
import { f as readErrors, o as loadCatalogs, s as loadProject, t as CliExit } from "./project-B5KIO0q-.js";
|
|
6
|
+
import { r as EXIT } from "./types-xR2exI3L.js";
|
|
9
7
|
import { basename, extname, resolve } from "node:path";
|
|
10
8
|
import { readFile } from "node:fs/promises";
|
|
11
|
-
|
|
9
|
+
// src/cli/commands/import.ts
|
|
12
10
|
/**
|
|
13
11
|
* `vi18n import [--format f] [--locale l] [--dry-run] <file>…` (PLAN §4.4,
|
|
14
12
|
* §5.19, INTERNALS §2.6.9): translations from exchange files into the
|
|
@@ -40,15 +38,10 @@ const WHY = {
|
|
|
40
38
|
const UTF8 = new TextDecoder("utf-8", { fatal: true });
|
|
41
39
|
async function importCatalogs(ctx, flags) {
|
|
42
40
|
const project = await loadProject(ctx);
|
|
43
|
-
const { config, codec, layout } = project;
|
|
44
41
|
const loaded = await loadCatalogs(project);
|
|
45
42
|
const unreadable = readErrors(loaded.diagnostics);
|
|
46
43
|
if (unreadable.length > 0) throw new CliExit(EXIT.failure, unreadable);
|
|
47
|
-
const context =
|
|
48
|
-
layout,
|
|
49
|
-
codec,
|
|
50
|
-
sourceIndex: sourceIndexOf(loaded.set.get(config.sourceLocale)?.catalog ?? null, layout, codec)
|
|
51
|
-
};
|
|
44
|
+
const context = sourceContext(project, loaded.set);
|
|
52
45
|
const data = {
|
|
53
46
|
dryRun: flags.dryRun,
|
|
54
47
|
files: [],
|
|
@@ -58,7 +51,6 @@ async function importCatalogs(ctx, flags) {
|
|
|
58
51
|
let failed = false;
|
|
59
52
|
for (const name of flags.files) {
|
|
60
53
|
const path = resolve(ctx.global.cwd, name);
|
|
61
|
-
const shown = rootRelative(config.root, path);
|
|
62
54
|
const problem = (message, line = 0) => {
|
|
63
55
|
failed = true;
|
|
64
56
|
const diagnostic = {
|
|
@@ -70,76 +62,32 @@ async function importCatalogs(ctx, flags) {
|
|
|
70
62
|
if (line > 0) diagnostic.line = line;
|
|
71
63
|
ctx.out.report([diagnostic]);
|
|
72
64
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} catch (error) {
|
|
77
|
-
const code = error.code;
|
|
78
|
-
problem(code === "ENOENT" ? "no such file" : error instanceof TypeError ? "the file is not valid UTF-8; export it as UTF-8" : `cannot read it: ${error instanceof Error ? error.message : String(error)}`);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const format = flags.format ?? inferFormat(path, text);
|
|
82
|
-
if (format === null) {
|
|
83
|
-
problem(`cannot tell the format from the extension ${JSON.stringify(extname(path))}; pass --format`);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const read = readImport(format, text, { msgid: config.catalogs.msgid });
|
|
87
|
-
if (read.error !== null) {
|
|
88
|
-
problem(`not a ${format} file vi18n can read: ${read.error.message}`, read.error.line);
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
if (read.srcLang != null && read.srcLang !== config.sourceLocale) {
|
|
92
|
-
problem(`its source language is ${read.srcLang}, but sourceLocale is ${config.sourceLocale}`);
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
const fromName = basename(path, extname(path));
|
|
96
|
-
const named = read.locale ?? (config.locales.includes(fromName) ? fromName : null);
|
|
97
|
-
if (flags.locale !== null && named !== null && read.locale !== null && flags.locale !== named) {
|
|
98
|
-
problem(`the file is for ${named}, not --locale ${flags.locale}`);
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
const locale = flags.locale ?? named;
|
|
102
|
-
if (locale === null) {
|
|
103
|
-
problem("the file does not name its locale; pass --locale");
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
if (locale === config.sourceLocale) {
|
|
107
|
-
problem(`${locale} is the source locale, which is compiled from code and takes no translations`);
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (!config.locales.includes(locale)) {
|
|
111
|
-
problem(`${locale} is not in locales (${config.locales.join(", ")})`);
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
65
|
+
const file = await readExchangeFile(project, flags, path, problem);
|
|
66
|
+
if (file === null) continue;
|
|
67
|
+
const { format, read, locale } = file;
|
|
114
68
|
const target = loaded.set.get(locale);
|
|
115
|
-
const apply = (catalog) => applyImport({
|
|
116
|
-
catalog,
|
|
117
|
-
records: read.records,
|
|
118
|
-
context,
|
|
119
|
-
locale
|
|
120
|
-
});
|
|
121
|
-
let outcome = null;
|
|
122
69
|
if (target === void 0 || target.catalog === null) {
|
|
123
70
|
problem(`${locale} has no catalog yet; run vi18n extract first`);
|
|
124
71
|
continue;
|
|
125
72
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
outcome = apply(current);
|
|
130
|
-
return outcome.catalog === current ? null : outcome.catalog;
|
|
73
|
+
const outcome = await applyToCatalog(project, {
|
|
74
|
+
...target,
|
|
75
|
+
catalog: target.catalog
|
|
131
76
|
}, {
|
|
132
77
|
locale,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
78
|
+
dryRun: flags.dryRun
|
|
79
|
+
}, (catalog) => applyImport({
|
|
80
|
+
catalog,
|
|
81
|
+
records: read.records,
|
|
82
|
+
context,
|
|
83
|
+
locale
|
|
84
|
+
}));
|
|
137
85
|
if (outcome === null) {
|
|
138
86
|
problem(`${locale}'s catalog disappeared while importing; run vi18n extract`);
|
|
139
87
|
continue;
|
|
140
88
|
}
|
|
141
89
|
report(ctx, data, {
|
|
142
|
-
file:
|
|
90
|
+
file: rootRelative(project.config.root, path),
|
|
143
91
|
format,
|
|
144
92
|
locale,
|
|
145
93
|
outcome,
|
|
@@ -151,6 +99,65 @@ async function importCatalogs(ctx, flags) {
|
|
|
151
99
|
data
|
|
152
100
|
};
|
|
153
101
|
}
|
|
102
|
+
/** An exchange file read with its format and target locale; null when it cannot be imported (reported). */
|
|
103
|
+
async function readExchangeFile(project, flags, path, problem) {
|
|
104
|
+
const { config } = project;
|
|
105
|
+
const text = await readUtf8(path, problem);
|
|
106
|
+
if (text === null) return null;
|
|
107
|
+
const format = flags.format ?? inferFormat(path, text);
|
|
108
|
+
if (format === null) {
|
|
109
|
+
problem(`cannot tell the format from the extension ${JSON.stringify(extname(path))}; pass --format`);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const read = readImport(format, text, { msgid: config.catalogs.msgid });
|
|
113
|
+
if (read.error !== null) {
|
|
114
|
+
problem(`not a ${format} file vi18n can read: ${read.error.message}`, read.error.line);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
if (read.srcLang != null && read.srcLang !== config.sourceLocale) {
|
|
118
|
+
problem(`its source language is ${read.srcLang}, but sourceLocale is ${config.sourceLocale}`);
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
const locale = importLocale(config, flags.locale, path, read.locale, problem);
|
|
122
|
+
return locale === null ? null : {
|
|
123
|
+
format,
|
|
124
|
+
read,
|
|
125
|
+
locale
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function readUtf8(path, problem) {
|
|
129
|
+
try {
|
|
130
|
+
return UTF8.decode(await readFile(path));
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (error.code === "ENOENT") problem("no such file");
|
|
133
|
+
else if (error instanceof TypeError) problem("the file is not valid UTF-8; export it as UTF-8");
|
|
134
|
+
else problem(`cannot read it: ${errorMessage(error)}`);
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** The locale a file imports into: `--locale`, the file's own, or its name; null when none fits (reported). */
|
|
139
|
+
function importLocale(config, requested, path, own, problem) {
|
|
140
|
+
const fromName = basename(path, extname(path));
|
|
141
|
+
const named = own ?? (config.locales.includes(fromName) ? fromName : null);
|
|
142
|
+
if (requested !== null && named !== null && own !== null && requested !== named) {
|
|
143
|
+
problem(`the file is for ${named}, not --locale ${requested}`);
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const locale = requested ?? named;
|
|
147
|
+
if (locale === null) {
|
|
148
|
+
problem("the file does not name its locale; pass --locale");
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
if (locale === config.sourceLocale) {
|
|
152
|
+
problem(`${locale} is the source locale, which is compiled from code and takes no translations`);
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
if (!config.locales.includes(locale)) {
|
|
156
|
+
problem(`${locale} is not in locales (${config.locales.join(", ")})`);
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
return locale;
|
|
160
|
+
}
|
|
154
161
|
function report(ctx, data, input) {
|
|
155
162
|
const { file, format, locale, outcome, path } = input;
|
|
156
163
|
const counts = {};
|
|
@@ -221,5 +228,4 @@ function inferFormat(path, text) {
|
|
|
221
228
|
default: return null;
|
|
222
229
|
}
|
|
223
230
|
}
|
|
224
|
-
//#endregion
|
|
225
231
|
export { importCatalogs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { C as Locale, D as ValuesOf, E as RichValuesOf, S as LibraryMessages, T as RichPartsValuesOf, _ as TagHandler, a as Message, b as Values, c as MissingHandler, d as RichHtmlFunction, f as RichPart, g as TFunction, i as HtmlTagHandler, l as MissingInfo, n as Descriptor, o as MessageKey, p as RichPartsFunction, r as Fmt, s as MessageRef, t as DateInput, u as RichFunction, v as TemporalInput, w as Register, x as DefaultTags, y as Translator } from "./types-
|
|
2
|
-
//#region src/runtime/t.d.ts
|
|
1
|
+
import { C as Locale, D as ValuesOf, E as RichValuesOf, S as LibraryMessages, T as RichPartsValuesOf, _ as TagHandler, a as Message, b as Values, c as MissingHandler, d as RichHtmlFunction, f as RichPart, g as TFunction, i as HtmlTagHandler, l as MissingInfo, n as Descriptor, o as MessageKey, p as RichPartsFunction, r as Fmt, s as MessageRef, t as DateInput, u as RichFunction, v as TemporalInput, w as Register, x as DefaultTags, y as Translator } from "./types-B4wNX6PA.js";
|
|
3
2
|
export declare const t: TFunction;
|
|
4
3
|
/**
|
|
5
4
|
* Declares a message without rendering it; the build turns the call into its
|
|
@@ -11,8 +10,6 @@ export declare function msg<const D extends Descriptor>(descriptor: D): MessageR
|
|
|
11
10
|
export declare function msg<const K extends Extract<keyof LibraryMessages, string>>(descriptor: {
|
|
12
11
|
readonly id: K;
|
|
13
12
|
}): MessageRef<ValuesOf<LibraryMessages[K]>>;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/runtime/rich.d.ts
|
|
16
13
|
/**
|
|
17
14
|
* Tag handlers come from `values` and receive `(children, key)`; React and
|
|
18
15
|
* Preact glue keys their results, and nodes passed as values, through
|
|
@@ -21,8 +18,6 @@ export declare function msg<const K extends Extract<keyof LibraryMessages, strin
|
|
|
21
18
|
export declare const rich: RichFunction;
|
|
22
19
|
export declare const richHtml: RichHtmlFunction;
|
|
23
20
|
export declare const richParts: RichPartsFunction;
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/runtime/macro.d.ts
|
|
26
21
|
/**
|
|
27
22
|
* The JSX `<T>` macro's runtime face (PLAN §4.1, INTERNALS §6 D215): the
|
|
28
23
|
* plugin's `vi18n:macro` pass replaces every `<T>…</T>` with a `rich()` call
|
|
@@ -63,8 +58,6 @@ declare const duration: Fmt["duration"];
|
|
|
63
58
|
declare const compare: Fmt["compare"];
|
|
64
59
|
declare const collator: Fmt["collator"];
|
|
65
60
|
declare const segment: Fmt["segment"];
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/runtime/name.d.ts
|
|
68
61
|
/**
|
|
69
62
|
* `localeName(locale)` (PLAN §4.1, §4.16): what a locale picker shows for a
|
|
70
63
|
* locale, its language's own name, and the `lang` of the text it shows, so
|
|
@@ -85,8 +78,6 @@ interface LocaleName {
|
|
|
85
78
|
}
|
|
86
79
|
type LocaleNameOptions = Pick<Intl.DisplayNamesOptions, "style" | "languageDisplay">;
|
|
87
80
|
export declare function localeName(locale: string, options?: LocaleNameOptions): LocaleName;
|
|
88
|
-
//#endregion
|
|
89
|
-
//#region src/runtime/zod.d.ts
|
|
90
81
|
/**
|
|
91
82
|
* `vi18nZod()` (PLAN §4.1, INTERNALS §6 D206): a zod 4 `customError` that
|
|
92
83
|
* words issues through vi18n messages in the current locale, so
|
|
@@ -116,8 +107,6 @@ interface ZodIssueLike {
|
|
|
116
107
|
/** What `vi18nZod()` returns: zod 4's error-map shape. */
|
|
117
108
|
type ZodErrorMap = (issue: ZodIssueLike) => string | undefined;
|
|
118
109
|
export declare const vi18nZod: () => ZodErrorMap;
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/runtime/locale.d.ts
|
|
121
110
|
/** The active scope's locale: the request's on the server, the page's in the browser. */
|
|
122
111
|
export declare const getLocale: () => Locale;
|
|
123
112
|
/** Switches the page in place (or by document navigation, §2.11.7). Client only. */
|
|
@@ -152,5 +141,4 @@ export declare const delocalizeUrl: (url: URL | string) => URL;
|
|
|
152
141
|
* returned unchanged.
|
|
153
142
|
*/
|
|
154
143
|
export declare function localizeHref(href: string, locale?: Locale): string;
|
|
155
|
-
//#endregion
|
|
156
144
|
export { type DateInput, type DefaultTags, type Descriptor, type Fmt, type HtmlTagHandler, type Locale, type LocaleName, type LocaleNameOptions, type Message, type MessageKey, type MessageRef, type MissingHandler, type MissingInfo, type Register, type RichPart, type RichPartsValuesOf, type RichValuesOf, type TFunction, type TProps, type TagHandler, type TemporalInput, type Translator, type Values, type ValuesOf, type ZodErrorMap, type ZodIssueLike, fmt_d_exports as fmt };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import { b as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { i as
|
|
6
|
-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
|
+
import { C as fSegment, S as fRelative, T as fUnit, _ as fDisplayName, b as fNumber, d as fCompact, f as fCompare, g as fDateRange, h as fDate, m as fCurrencyMinor, n as msg, p as fCurrency, r as t, u as fCollator, v as fDuration, w as fTime, x as fPercent, y as fList } from "./t-gvEXx25s.js";
|
|
3
|
+
import { i as richParts, n as richHtml, t as rich } from "./rich-ApY1Dm4S.js";
|
|
4
|
+
import { n as S, t as textDirection, u as resolved, y as trim } from "./dir-TGLYuOZb.js";
|
|
5
|
+
import { i as awayHref, l as localizePath, n as atHome, p as splitLocalePath, r as atHost, s as hostLocale, t as ROUTES } from "./url-D2_VlEeH.js";
|
|
6
|
+
// src/runtime/macro.ts
|
|
7
7
|
function T(props) {
|
|
8
8
|
throw new Error("vi18n: <T> is a compile-time macro and was not compiled: add vi18n() to the plugins of this Vite or Vitest config");
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
//#region src/runtime/fmt.ts
|
|
10
|
+
// src/runtime/fmt.ts
|
|
12
11
|
/**
|
|
13
12
|
* The `fmt` namespace (PLAN §5.17): exactly the members of `Fmt`, each in the
|
|
14
13
|
* active scope's locale, zone and `now`. Separate exports, so unused members
|
|
@@ -53,8 +52,7 @@ const duration = (d, o) => fDuration(scope(), d, o);
|
|
|
53
52
|
const compare = (a, b, o) => fCompare(scope(), a, b, o);
|
|
54
53
|
const collator = (o) => fCollator(scope(), o);
|
|
55
54
|
const segment = (text, o) => fSegment(scope(), text, o);
|
|
56
|
-
|
|
57
|
-
//#region src/runtime/name.ts
|
|
55
|
+
// src/runtime/name.ts
|
|
58
56
|
/**
|
|
59
57
|
* `localeName(locale)` (PLAN §4.1, §4.16): what a locale picker shows for a
|
|
60
58
|
* locale, its language's own name, and the `lang` of the text it shows, so
|
|
@@ -90,8 +88,7 @@ function localeName(locale, options) {
|
|
|
90
88
|
}
|
|
91
89
|
return n;
|
|
92
90
|
}
|
|
93
|
-
|
|
94
|
-
//#region src/runtime/zod.ts
|
|
91
|
+
// src/runtime/zod.ts
|
|
95
92
|
/**
|
|
96
93
|
* `vi18nZod()` (PLAN §4.1, INTERNALS §6 D206): a zod 4 `customError` that
|
|
97
94
|
* words issues through vi18n messages in the current locale, so
|
|
@@ -147,8 +144,7 @@ const vi18nZod = ((...m) => (issue) => {
|
|
|
147
144
|
}
|
|
148
145
|
return t(m[i], values) || void 0;
|
|
149
146
|
});
|
|
150
|
-
|
|
151
|
-
//#region src/runtime/locale.ts
|
|
147
|
+
// src/runtime/locale.ts
|
|
152
148
|
/**
|
|
153
149
|
* The public locale API (PLAN §5.12, §5.14, §5.15). Every function goes
|
|
154
150
|
* through the global state, so a duplicate runtime copy acts on the same page.
|
|
@@ -193,7 +189,10 @@ function edit(url, f) {
|
|
|
193
189
|
*/
|
|
194
190
|
function routedUrl(url, l) {
|
|
195
191
|
let away = null;
|
|
196
|
-
const u = edit(url, (p, c) =>
|
|
192
|
+
const u = edit(url, (p, c) => {
|
|
193
|
+
away = awayHref(splitLocalePath(p, c).path, l, c);
|
|
194
|
+
return away ?? localizePath(p, l, c);
|
|
195
|
+
});
|
|
197
196
|
if (away === null) return u;
|
|
198
197
|
const to = new URL(away);
|
|
199
198
|
to.search = u.search;
|
|
@@ -235,5 +234,4 @@ function localizeHref(href, locale) {
|
|
|
235
234
|
} catch {}
|
|
236
235
|
return href;
|
|
237
236
|
}
|
|
238
|
-
//#endregion
|
|
239
237
|
export { T, delocalizeUrl, dir, fmt_exports as fmt, getLocale, localeName, locales, localizeHref, localizeUrl, msg, onMissing, preload, ready, rich, richHtml, richParts, setLocale, setNavigator, subscribe, t, vi18nZod };
|