@fluenti/vue 0.3.4 → 0.4.0-rc.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/dist/components/Plural.d.ts +11 -0
- package/dist/components/Plural.d.ts.map +1 -1
- package/dist/components-entry.cjs +2 -0
- package/dist/components-entry.cjs.map +1 -0
- package/dist/components-entry.d.ts +12 -0
- package/dist/components-entry.d.ts.map +1 -0
- package/dist/components-entry.js +227 -0
- package/dist/components-entry.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +111 -349
- package/dist/index.js.map +1 -1
- package/dist/injection-key.d.ts +5 -0
- package/dist/injection-key.d.ts.map +1 -0
- package/dist/plugin.d.ts +49 -5
- package/dist/plugin.d.ts.map +1 -1
- package/dist/use-i18n-CQQp9bxG.cjs +2 -0
- package/dist/use-i18n-CQQp9bxG.cjs.map +1 -0
- package/dist/use-i18n-DrhdlExQ.js +14 -0
- package/dist/use-i18n-DrhdlExQ.js.map +1 -0
- package/dist/use-i18n.d.ts +18 -0
- package/dist/use-i18n.d.ts.map +1 -1
- package/llms.txt +53 -0
- package/package.json +14 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,10 @@ export { createFluenti, FLUENTI_KEY } from './plugin';
|
|
|
2
2
|
export type { FluentiConfig, FluentiPlugin, FluentiContext } from './plugin';
|
|
3
3
|
export { useI18n } from './use-i18n';
|
|
4
4
|
export { t } from './compile-time-t';
|
|
5
|
-
export {
|
|
5
|
+
export { msg } from './msg';
|
|
6
6
|
export type { FluentiTransProps } from './components/Trans';
|
|
7
|
-
export { Plural } from './components/Plural';
|
|
8
7
|
export type { FluentiPluralProps } from './components/Plural';
|
|
9
|
-
export { Select } from './components/Select';
|
|
10
8
|
export type { FluentiSelectProps } from './components/Select';
|
|
11
|
-
export { DateTime } from './components/DateTime';
|
|
12
9
|
export type { FluentiDateTimeProps } from './components/DateTime';
|
|
13
|
-
export { NumberFormat } from './components/NumberFormat';
|
|
14
10
|
export type { FluentiNumberFormatProps } from './components/NumberFormat';
|
|
15
|
-
export { msg } from './msg';
|
|
16
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACrD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACrD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAI3B,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,420 +1,182 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
//#region src/use-i18n.ts
|
|
5
|
-
function x() {
|
|
6
|
-
let e = i(P);
|
|
7
|
-
if (!e) throw Error("[fluenti] useI18n() requires createFluenti plugin");
|
|
8
|
-
return e;
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/components/rich-text.ts
|
|
12
|
-
function S(n) {
|
|
13
|
-
let r = [], i = "";
|
|
14
|
-
function o(n) {
|
|
15
|
-
if (n == null || typeof n == "boolean") return;
|
|
16
|
-
if (Array.isArray(n)) {
|
|
17
|
-
for (let e of n) o(e);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (typeof n == "string" || typeof n == "number") {
|
|
21
|
-
i += String(n);
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (!a(n) || n.type === e) return;
|
|
25
|
-
if (n.type === t) {
|
|
26
|
-
i += typeof n.children == "string" ? n.children : "";
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
let s = r.length, c = S(n.children);
|
|
30
|
-
r.push(n), r.push(...c.components), i += `<${s}>${y(c.message, s + 1)}</${s}>`;
|
|
31
|
-
}
|
|
32
|
-
return o(n), {
|
|
33
|
-
message: i,
|
|
34
|
-
components: r
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function C(e, t) {
|
|
38
|
-
let n = /<(\d+)>([\s\S]*?)<\/\1>/g, i = [], a = 0, o;
|
|
39
|
-
for (n.lastIndex = 0, o = n.exec(e); o !== null;) {
|
|
40
|
-
o.index > a && i.push(e.slice(a, o.index));
|
|
41
|
-
let s = t[Number(o[1])], c = C(o[2], t);
|
|
42
|
-
s ? i.push(r(s.type, s.props ?? {}, Array.isArray(c) ? c : [c])) : i.push(o[2]), a = n.lastIndex, o = n.exec(e);
|
|
43
|
-
}
|
|
44
|
-
return a < e.length && i.push(e.slice(a)), i.length <= 1 ? i[0] ?? "" : i;
|
|
45
|
-
}
|
|
46
|
-
function w(e, t) {
|
|
47
|
-
let n = {}, r = [];
|
|
48
|
-
for (let i of e) {
|
|
49
|
-
let e = t[i];
|
|
50
|
-
if (e === void 0) continue;
|
|
51
|
-
let a = S(e);
|
|
52
|
-
n[i] = y(a.message, r.length), r.push(...a.components);
|
|
53
|
-
}
|
|
54
|
-
for (let [i, a] of Object.entries(t)) {
|
|
55
|
-
if (e.includes(i) || a === void 0) continue;
|
|
56
|
-
let t = S(a);
|
|
57
|
-
n[i] = y(t.message, r.length), r.push(...t.components);
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
messages: n,
|
|
61
|
-
components: r
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
var T = n({
|
|
65
|
-
name: "Trans",
|
|
66
|
-
props: {
|
|
67
|
-
id: String,
|
|
68
|
-
context: String,
|
|
69
|
-
comment: String,
|
|
70
|
-
tag: {
|
|
71
|
-
type: String,
|
|
72
|
-
default: void 0
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
setup(e, { slots: t }) {
|
|
76
|
-
let { t: n } = x();
|
|
77
|
-
return () => {
|
|
78
|
-
let i = t.default?.();
|
|
79
|
-
if (!i) return null;
|
|
80
|
-
let { message: a, components: o } = S(i), s = n({
|
|
81
|
-
...e.id === void 0 ? {} : { id: e.id },
|
|
82
|
-
message: a,
|
|
83
|
-
...e.context === void 0 ? {} : { context: e.context },
|
|
84
|
-
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
85
|
-
}), c = o.length > 0 ? C(s, o) : s;
|
|
86
|
-
return Array.isArray(c) ? c.length === 1 ? c[0] : e.tag ? r(e.tag, null, c) : c : c;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}), E = n({
|
|
90
|
-
name: "Plural",
|
|
91
|
-
props: {
|
|
92
|
-
value: {
|
|
93
|
-
type: Number,
|
|
94
|
-
required: !0
|
|
95
|
-
},
|
|
96
|
-
id: String,
|
|
97
|
-
context: String,
|
|
98
|
-
comment: String,
|
|
99
|
-
zero: String,
|
|
100
|
-
one: String,
|
|
101
|
-
two: String,
|
|
102
|
-
few: String,
|
|
103
|
-
many: String,
|
|
104
|
-
other: {
|
|
105
|
-
type: String,
|
|
106
|
-
required: !0
|
|
107
|
-
},
|
|
108
|
-
offset: Number,
|
|
109
|
-
tag: {
|
|
110
|
-
type: String,
|
|
111
|
-
default: void 0
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
setup(e, { slots: t }) {
|
|
115
|
-
let { t: n } = x();
|
|
116
|
-
return () => {
|
|
117
|
-
let i = {
|
|
118
|
-
zero: e.zero,
|
|
119
|
-
one: e.one,
|
|
120
|
-
two: e.two,
|
|
121
|
-
few: e.few,
|
|
122
|
-
many: e.many,
|
|
123
|
-
other: e.other
|
|
124
|
-
};
|
|
125
|
-
for (let e of f) {
|
|
126
|
-
let n = t[e];
|
|
127
|
-
n && (i[e] = n({ count: "#" }));
|
|
128
|
-
}
|
|
129
|
-
let { messages: a, components: o } = w(f, i), s = m({
|
|
130
|
-
...a.zero !== void 0 && { zero: a.zero },
|
|
131
|
-
...a.one !== void 0 && { one: a.one },
|
|
132
|
-
...a.two !== void 0 && { two: a.two },
|
|
133
|
-
...a.few !== void 0 && { few: a.few },
|
|
134
|
-
...a.many !== void 0 && { many: a.many },
|
|
135
|
-
other: a.other ?? ""
|
|
136
|
-
}, e.offset), c = n({
|
|
137
|
-
id: e.id ?? (e.context === void 0 ? s : g(s, e.context)),
|
|
138
|
-
message: s,
|
|
139
|
-
...e.context === void 0 ? {} : { context: e.context },
|
|
140
|
-
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
141
|
-
}, { count: e.value }), l = o.length > 0 ? C(c, o) : c;
|
|
142
|
-
return e.tag ? r(e.tag, void 0, l ?? void 0) : l ?? null;
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
}), D = n({
|
|
146
|
-
name: "Select",
|
|
147
|
-
inheritAttrs: !1,
|
|
148
|
-
props: {
|
|
149
|
-
value: {
|
|
150
|
-
type: String,
|
|
151
|
-
required: !0
|
|
152
|
-
},
|
|
153
|
-
id: String,
|
|
154
|
-
context: String,
|
|
155
|
-
comment: String,
|
|
156
|
-
other: {
|
|
157
|
-
type: String,
|
|
158
|
-
required: !0
|
|
159
|
-
},
|
|
160
|
-
options: {
|
|
161
|
-
type: Object,
|
|
162
|
-
default: void 0
|
|
163
|
-
},
|
|
164
|
-
tag: {
|
|
165
|
-
type: String,
|
|
166
|
-
default: void 0
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
setup(e, { attrs: t, slots: n }) {
|
|
170
|
-
let { t: i } = x();
|
|
171
|
-
return () => {
|
|
172
|
-
let a = {};
|
|
173
|
-
if (e.options !== void 0) {
|
|
174
|
-
for (let [t, n] of Object.entries(e.options)) a[t] = n;
|
|
175
|
-
a.other = e.other;
|
|
176
|
-
} else {
|
|
177
|
-
for (let [e, n] of Object.entries(t)) typeof n == "string" && (a[e] = n);
|
|
178
|
-
a.other = e.other;
|
|
179
|
-
}
|
|
180
|
-
for (let [e, t] of Object.entries(n)) e === "default" || !t || (a[e] = t({ value: "{value}" }));
|
|
181
|
-
let o = [...Object.keys(a).filter((e) => e !== "other"), "other"], { messages: s, components: c } = w(o, a), l = v(Object.fromEntries([...o].map((e) => [e, s[e] ?? ""]))), u = h(l.forms), d = i({
|
|
182
|
-
id: e.id ?? (e.context === void 0 ? u : g(u, e.context)),
|
|
183
|
-
message: u,
|
|
184
|
-
...e.context === void 0 ? {} : { context: e.context },
|
|
185
|
-
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
186
|
-
}, { value: l.valueMap[e.value] ?? "other" }), f = c.length > 0 ? C(d, c) : d;
|
|
187
|
-
return e.tag ? r(e.tag, void 0, f ?? void 0) : f ?? null;
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
}), O = n({
|
|
191
|
-
name: "DateTime",
|
|
192
|
-
props: {
|
|
193
|
-
value: {
|
|
194
|
-
type: [Date, Number],
|
|
195
|
-
required: !0
|
|
196
|
-
},
|
|
197
|
-
format: {
|
|
198
|
-
type: String,
|
|
199
|
-
default: void 0
|
|
200
|
-
},
|
|
201
|
-
tag: {
|
|
202
|
-
type: String,
|
|
203
|
-
default: "span"
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
setup(e) {
|
|
207
|
-
let { d: t } = x();
|
|
208
|
-
return () => r(e.tag, t(e.value, e.format));
|
|
209
|
-
}
|
|
210
|
-
}), k = n({
|
|
211
|
-
name: "NumberFormat",
|
|
212
|
-
props: {
|
|
213
|
-
value: {
|
|
214
|
-
type: Number,
|
|
215
|
-
required: !0
|
|
216
|
-
},
|
|
217
|
-
format: {
|
|
218
|
-
type: String,
|
|
219
|
-
default: void 0
|
|
220
|
-
},
|
|
221
|
-
tag: {
|
|
222
|
-
type: String,
|
|
223
|
-
default: "span"
|
|
224
|
-
}
|
|
225
|
-
},
|
|
226
|
-
setup(e) {
|
|
227
|
-
let { n: t } = x();
|
|
228
|
-
return () => r(e.tag, t(e.value, e.format));
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
//#endregion
|
|
1
|
+
import { n as e, t } from "./use-i18n-DrhdlExQ.js";
|
|
2
|
+
import { ref as n, shallowReactive as r } from "vue";
|
|
3
|
+
import { createFluentiCore as i, msg as a } from "@fluenti/core";
|
|
232
4
|
//#region src/plugin.ts
|
|
233
|
-
function
|
|
5
|
+
function o(e) {
|
|
234
6
|
return e.replace(/&/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">");
|
|
235
7
|
}
|
|
236
|
-
var
|
|
237
|
-
function
|
|
238
|
-
let e = globalThis[
|
|
8
|
+
var s = Symbol.for("fluenti.runtime.vue.v1");
|
|
9
|
+
function c() {
|
|
10
|
+
let e = globalThis[s];
|
|
239
11
|
return typeof e == "object" && e ? e : null;
|
|
240
12
|
}
|
|
241
|
-
function
|
|
13
|
+
function l(e) {
|
|
242
14
|
return typeof e == "object" && e && "default" in e ? e.default : e;
|
|
243
15
|
}
|
|
244
|
-
|
|
245
|
-
function F(e, t, n) {
|
|
246
|
-
return typeof e == "function" ? e(t) : _(e, t, n);
|
|
247
|
-
}
|
|
248
|
-
function I(e) {
|
|
16
|
+
function u(e) {
|
|
249
17
|
let t = Object.keys(e).filter((e) => e !== "plural");
|
|
250
18
|
return t.length > 0 ? t[0] : void 0;
|
|
251
19
|
}
|
|
252
|
-
function
|
|
253
|
-
let
|
|
254
|
-
|
|
255
|
-
|
|
20
|
+
function d(t) {
|
|
21
|
+
let a = t.lazyLocaleLoading ?? t.splitting ?? !1, s = {
|
|
22
|
+
locale: t.locale,
|
|
23
|
+
messages: t.messages ?? {}
|
|
24
|
+
};
|
|
25
|
+
t.fallbackLocale !== void 0 && (s.fallbackLocale = t.fallbackLocale), t.fallbackChain !== void 0 && (s.fallbackChain = t.fallbackChain), t.dateFormats !== void 0 && (s.dateFormats = t.dateFormats), t.numberFormats !== void 0 && (s.numberFormats = t.numberFormats), t.missing !== void 0 && (s.missing = t.missing), t.diagnostics !== void 0 && (s.diagnostics = t.diagnostics), t.interpolate !== void 0 && (s.interpolate = t.interpolate);
|
|
26
|
+
let d = i(s), f = n(t.locale), p = r({ ...t.messages }), m = n(!1), h = new Set([t.locale]), g = n(new Set(h));
|
|
27
|
+
function _(e, t) {
|
|
28
|
+
let n = p[e];
|
|
256
29
|
if (n) return n[t];
|
|
257
30
|
}
|
|
258
|
-
function
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (e.fallbackLocale && !u.includes(e.fallbackLocale) && u.push(e.fallbackLocale), e.fallbackChain?.[l]) for (let t of e.fallbackChain[l]) u.includes(t) || u.push(t);
|
|
264
|
-
else if (e.fallbackChain?.["*"]) for (let t of e.fallbackChain["*"]) u.includes(t) || u.push(t);
|
|
265
|
-
for (let e of u) {
|
|
266
|
-
let t = m(e, s);
|
|
267
|
-
if (t !== void 0) return e !== l && n?.fallbackUsed(l, e, s), F(t, o, e);
|
|
268
|
-
}
|
|
269
|
-
if (n?.missingKey(l, s), e.missing) try {
|
|
270
|
-
let t = e.missing(l, s);
|
|
271
|
-
if (t !== void 0) return t;
|
|
272
|
-
} catch {}
|
|
273
|
-
return c ? _(c, o, l) : s.includes("{") ? _(s, o, l) : s;
|
|
31
|
+
function v() {
|
|
32
|
+
d.locale !== f.value && (d.locale = f.value);
|
|
33
|
+
}
|
|
34
|
+
function y(e, ...t) {
|
|
35
|
+
return p[f.value], v(), Array.isArray(e) && "raw" in e ? d.t(e, ...t) : d.t(e, t[0]);
|
|
274
36
|
}
|
|
275
|
-
let
|
|
276
|
-
async function
|
|
277
|
-
if (!
|
|
278
|
-
|
|
37
|
+
let b = 0;
|
|
38
|
+
async function x(e) {
|
|
39
|
+
if (!a || !t.chunkLoader) {
|
|
40
|
+
d.locale = e, f.value = e;
|
|
279
41
|
return;
|
|
280
42
|
}
|
|
281
|
-
let
|
|
282
|
-
if (
|
|
283
|
-
|
|
43
|
+
let n = c();
|
|
44
|
+
if (h.has(e)) {
|
|
45
|
+
n?.__switchLocale && await n.__switchLocale(e), d.locale = e, f.value = e;
|
|
284
46
|
return;
|
|
285
47
|
}
|
|
286
|
-
let
|
|
287
|
-
|
|
48
|
+
let r = ++b;
|
|
49
|
+
m.value = !0;
|
|
288
50
|
try {
|
|
289
|
-
let
|
|
290
|
-
if (
|
|
291
|
-
...
|
|
292
|
-
...
|
|
293
|
-
}, d.add(
|
|
294
|
-
|
|
51
|
+
let i = l(await t.chunkLoader(e));
|
|
52
|
+
if (r !== b || (p[e] = {
|
|
53
|
+
...p[e],
|
|
54
|
+
...i
|
|
55
|
+
}, d.loadMessages(e, i), h.add(e), g.value = new Set(h), n?.__switchLocale && await n.__switchLocale(e), r !== b)) return;
|
|
56
|
+
d.locale = e, f.value = e;
|
|
295
57
|
} finally {
|
|
296
|
-
|
|
58
|
+
r === b && (m.value = !1);
|
|
297
59
|
}
|
|
298
60
|
}
|
|
299
|
-
function
|
|
300
|
-
|
|
301
|
-
...
|
|
61
|
+
function S(e, t) {
|
|
62
|
+
p[e] = {
|
|
63
|
+
...p[e],
|
|
302
64
|
...t
|
|
303
|
-
}, d.add(e),
|
|
304
|
-
}
|
|
305
|
-
let
|
|
306
|
-
function
|
|
307
|
-
if (!
|
|
308
|
-
|
|
309
|
-
let
|
|
310
|
-
|
|
311
|
-
let
|
|
312
|
-
|
|
313
|
-
...
|
|
314
|
-
...
|
|
315
|
-
}, d.add(
|
|
316
|
-
}).catch((
|
|
317
|
-
console.warn("[fluenti] preload failed:",
|
|
65
|
+
}, d.loadMessages(e, t), h.add(e), g.value = new Set(h);
|
|
66
|
+
}
|
|
67
|
+
let C = /* @__PURE__ */ new Set();
|
|
68
|
+
function w(e) {
|
|
69
|
+
if (!a || h.has(e) || !t.chunkLoader || C.has(e)) return;
|
|
70
|
+
C.add(e);
|
|
71
|
+
let n = c();
|
|
72
|
+
t.chunkLoader(e).then(async (t) => {
|
|
73
|
+
let r = l(t);
|
|
74
|
+
p[e] = {
|
|
75
|
+
...p[e],
|
|
76
|
+
...r
|
|
77
|
+
}, d.loadMessages(e, r), h.add(e), g.value = new Set(h), n?.__preloadLocale && await n.__preloadLocale(e);
|
|
78
|
+
}).catch((t) => {
|
|
79
|
+
console.warn("[fluenti] preload failed:", e, t);
|
|
318
80
|
}).finally(() => {
|
|
319
|
-
|
|
81
|
+
C.delete(e);
|
|
320
82
|
});
|
|
321
83
|
}
|
|
322
|
-
function
|
|
323
|
-
return
|
|
84
|
+
function T() {
|
|
85
|
+
return v(), d.getLocales();
|
|
324
86
|
}
|
|
325
|
-
function
|
|
326
|
-
|
|
327
|
-
return l(t, i, n, e.dateFormats);
|
|
87
|
+
function E(e, t) {
|
|
88
|
+
return f.value, v(), d.d(e, t);
|
|
328
89
|
}
|
|
329
|
-
function
|
|
330
|
-
|
|
331
|
-
return u(t, i, n, e.numberFormats);
|
|
90
|
+
function D(e, t) {
|
|
91
|
+
return f.value, v(), d.n(e, t);
|
|
332
92
|
}
|
|
333
|
-
function
|
|
334
|
-
return
|
|
93
|
+
function O(e, t) {
|
|
94
|
+
return f.value, v(), d.format(e, t);
|
|
335
95
|
}
|
|
336
|
-
function
|
|
337
|
-
let r =
|
|
96
|
+
function k(e, t, n) {
|
|
97
|
+
let r = o(n ? y(e, n) : y(e));
|
|
338
98
|
function i(e) {
|
|
339
99
|
if (e.rawAttrs != null && e.rawAttrs !== "") {
|
|
340
100
|
let t = [], n = /([\w:@.!-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'))?/g, r;
|
|
341
101
|
for (; (r = n.exec(e.rawAttrs)) !== null;) {
|
|
342
|
-
let e =
|
|
343
|
-
t.push(n === void 0 ? e : `${e}="${
|
|
102
|
+
let e = o(r[1]), n = r[2] ?? r[3];
|
|
103
|
+
t.push(n === void 0 ? e : `${e}="${o(n)}"`);
|
|
344
104
|
}
|
|
345
105
|
return t.join(" ");
|
|
346
106
|
}
|
|
347
|
-
return e.attrs ? Object.entries(e.attrs).map(([e, t]) => t ? `${
|
|
107
|
+
return e.attrs ? Object.entries(e.attrs).map(([e, t]) => t ? `${o(e)}="${o(t)}"` : o(e)).join(" ") : "";
|
|
348
108
|
}
|
|
349
109
|
let a = r.replace(/<(\d+)\/>/g, (e, n) => {
|
|
350
110
|
let r = t[Number(n)];
|
|
351
111
|
if (!r) return "";
|
|
352
|
-
let a =
|
|
353
|
-
return `<${a}${
|
|
112
|
+
let a = o(r.tag), s = i(r);
|
|
113
|
+
return `<${a}${s ? " " + s : ""} />`;
|
|
354
114
|
});
|
|
355
115
|
return a = a.replace(/<(\d+)>([\s\S]*?)<\/\1>/g, (e, n, r) => {
|
|
356
116
|
let a = t[Number(n)];
|
|
357
117
|
if (!a) return r;
|
|
358
|
-
let
|
|
359
|
-
return `<${
|
|
118
|
+
let s = o(a.tag), c = i(a);
|
|
119
|
+
return `<${s}${c ? " " + c : ""}>${r}</${s}>`;
|
|
360
120
|
}), a;
|
|
361
121
|
}
|
|
362
|
-
function
|
|
363
|
-
return
|
|
364
|
-
}
|
|
365
|
-
function
|
|
366
|
-
return
|
|
367
|
-
}
|
|
368
|
-
let
|
|
369
|
-
t:
|
|
370
|
-
locale:
|
|
371
|
-
setLocale:
|
|
372
|
-
loadMessages:
|
|
373
|
-
getLocales:
|
|
374
|
-
d:
|
|
375
|
-
n:
|
|
376
|
-
format:
|
|
377
|
-
isLoading:
|
|
378
|
-
loadedLocales:
|
|
379
|
-
preloadLocale:
|
|
380
|
-
te:
|
|
381
|
-
tm:
|
|
122
|
+
function A(e, t) {
|
|
123
|
+
return _(t ?? f.value, e) !== void 0;
|
|
124
|
+
}
|
|
125
|
+
function j(e, t) {
|
|
126
|
+
return _(t ?? f.value, e);
|
|
127
|
+
}
|
|
128
|
+
let M = {
|
|
129
|
+
t: y,
|
|
130
|
+
locale: f,
|
|
131
|
+
setLocale: x,
|
|
132
|
+
loadMessages: S,
|
|
133
|
+
getLocales: T,
|
|
134
|
+
d: E,
|
|
135
|
+
n: D,
|
|
136
|
+
format: O,
|
|
137
|
+
isLoading: m,
|
|
138
|
+
loadedLocales: g,
|
|
139
|
+
preloadLocale: w,
|
|
140
|
+
te: A,
|
|
141
|
+
tm: j
|
|
382
142
|
};
|
|
383
143
|
return {
|
|
384
|
-
install(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
144
|
+
install(n) {
|
|
145
|
+
if (n.provide(e, M), t.components) {
|
|
146
|
+
let e = t.componentPrefix ?? "", r = t.components;
|
|
147
|
+
r.Trans && n.component(`${e}Trans`, r.Trans), r.Plural && n.component(`${e}Plural`, r.Plural), r.Select && n.component(`${e}Select`, r.Select), r.DateTime && n.component(`${e}DateTime`, r.DateTime), r.NumberFormat && n.component(`${e}NumberFormat`, r.NumberFormat);
|
|
148
|
+
}
|
|
149
|
+
t.injectGlobalProperties !== !1 && (n.config.globalProperties.$t = y, n.config.globalProperties.$d = E, n.config.globalProperties.$n = D, n.config.globalProperties.$vtRich = k);
|
|
388
150
|
let r = /* @__PURE__ */ new WeakMap();
|
|
389
|
-
|
|
151
|
+
n.directive("t", {
|
|
390
152
|
mounted(e, t) {
|
|
391
|
-
let n =
|
|
153
|
+
let n = u(t.modifiers);
|
|
392
154
|
if (n) {
|
|
393
155
|
let t = e.getAttribute(n) ?? "";
|
|
394
|
-
r.set(e, t), e.setAttribute(n,
|
|
156
|
+
r.set(e, t), e.setAttribute(n, y(t));
|
|
395
157
|
} else {
|
|
396
158
|
let n = t.arg ?? e.textContent ?? "";
|
|
397
|
-
r.set(e, n.trim()), e.textContent =
|
|
159
|
+
r.set(e, n.trim()), e.textContent = y(n.trim(), t.value == null ? void 0 : { ...t.value });
|
|
398
160
|
}
|
|
399
161
|
},
|
|
400
162
|
updated(e, t) {
|
|
401
|
-
let n =
|
|
163
|
+
let n = u(t.modifiers);
|
|
402
164
|
if (n) {
|
|
403
165
|
let t = r.get(e) ?? e.getAttribute(n) ?? "";
|
|
404
|
-
e.setAttribute(n,
|
|
405
|
-
} else e.textContent =
|
|
166
|
+
e.setAttribute(n, y(t));
|
|
167
|
+
} else e.textContent = y((t.arg ?? r.get(e) ?? "").trim(), t.value == null ? void 0 : { ...t.value });
|
|
406
168
|
}
|
|
407
169
|
});
|
|
408
170
|
},
|
|
409
|
-
global:
|
|
171
|
+
global: M
|
|
410
172
|
};
|
|
411
173
|
}
|
|
412
174
|
//#endregion
|
|
413
175
|
//#region src/compile-time-t.ts
|
|
414
|
-
var
|
|
176
|
+
var f = ((...e) => {
|
|
415
177
|
throw Error("[fluenti] `t` imported from '@fluenti/vue' is a compile-time API. Use it only with the Fluenti build transform inside <script setup> or setup(). For runtime lookups, use useI18n().t(...).");
|
|
416
178
|
});
|
|
417
179
|
//#endregion
|
|
418
|
-
export {
|
|
180
|
+
export { e as FLUENTI_KEY, d as createFluenti, a as msg, f as t, t as useI18n };
|
|
419
181
|
|
|
420
182
|
//# sourceMappingURL=index.js.map
|