@let-value/translate-extract 1.0.12 → 1.0.14
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/bin/cli.cjs +24 -18
- package/dist/bin/cli.d.cts +1 -2
- package/dist/bin/cli.d.ts +1 -2
- package/dist/bin/cli.js +21 -17
- package/dist/bin/cli.js.map +1 -1
- package/dist/{run-Dl-tr2kf.js → run-C_k3ujlk.js} +45 -20
- package/dist/run-C_k3ujlk.js.map +1 -0
- package/dist/{run-XkKxn8kJ.cjs → run-DpRfSHSy.cjs} +45 -20
- package/dist/src/index.cjs +51 -53
- package/dist/src/index.d.cts +11 -8
- package/dist/src/index.d.cts.map +1 -1
- package/dist/src/index.d.ts +11 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +51 -53
- package/dist/src/index.js.map +1 -1
- package/package.json +10 -9
- package/dist/run-Dl-tr2kf.js.map +0 -1
package/dist/src/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_run = require('../run-
|
|
1
|
+
const require_run = require('../run-DpRfSHSy.cjs');
|
|
2
2
|
let node_path = require("node:path");
|
|
3
3
|
node_path = require_run.__toESM(node_path);
|
|
4
4
|
let node_fs_promises = require("node:fs/promises");
|
|
@@ -19,43 +19,52 @@ let plural_forms = require("plural-forms");
|
|
|
19
19
|
plural_forms = require_run.__toESM(plural_forms);
|
|
20
20
|
|
|
21
21
|
//#region src/plugins/cleanup/cleanup.ts
|
|
22
|
+
const namespace$2 = "cleanup";
|
|
22
23
|
function cleanup() {
|
|
23
24
|
return {
|
|
24
25
|
name: "cleanup",
|
|
25
26
|
setup(build) {
|
|
26
27
|
build.context.logger?.debug("cleanup plugin initialized");
|
|
27
|
-
const
|
|
28
|
+
const processed = /* @__PURE__ */ new Set();
|
|
28
29
|
const generated = /* @__PURE__ */ new Set();
|
|
30
|
+
const dirs = /* @__PURE__ */ new Set();
|
|
31
|
+
let dispatched = false;
|
|
29
32
|
build.onResolve({
|
|
30
|
-
namespace:
|
|
33
|
+
namespace: namespace$2,
|
|
31
34
|
filter: /.*/
|
|
32
|
-
}, (
|
|
33
|
-
generated.add(
|
|
34
|
-
|
|
35
|
+
}, ({ path: path$1 }) => {
|
|
36
|
+
generated.add(path$1);
|
|
37
|
+
dirs.add((0, node_path.dirname)(path$1));
|
|
38
|
+
Promise.all([build.defer("source"), build.defer("translate")]).then(() => {
|
|
39
|
+
if (dispatched) return;
|
|
40
|
+
dispatched = true;
|
|
41
|
+
for (const path$2 of dirs.values()) build.process({
|
|
42
|
+
entrypoint: path$2,
|
|
43
|
+
path: path$2,
|
|
44
|
+
namespace: namespace$2,
|
|
45
|
+
data: void 0
|
|
46
|
+
});
|
|
47
|
+
});
|
|
35
48
|
});
|
|
36
49
|
build.onProcess({
|
|
37
|
-
namespace:
|
|
50
|
+
namespace: namespace$2,
|
|
38
51
|
filter: /.*/
|
|
39
52
|
}, async ({ path: path$1 }) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
processedDirs.add(dir);
|
|
44
|
-
const files = await node_fs_promises.default.readdir(dir).catch(() => []);
|
|
53
|
+
if (processed.has(path$1)) return;
|
|
54
|
+
processed.add(path$1);
|
|
55
|
+
const files = await node_fs_promises.default.readdir(path$1).catch(() => []);
|
|
45
56
|
for (const f of files.filter((p) => p.endsWith(".po"))) {
|
|
46
|
-
const full = (0, node_path.join)(
|
|
57
|
+
const full = (0, node_path.join)(path$1, f);
|
|
47
58
|
if (generated.has(full)) continue;
|
|
48
59
|
const contents = await node_fs_promises.default.readFile(full).catch(() => void 0);
|
|
49
60
|
if (!contents) continue;
|
|
50
61
|
const parsed = gettext_parser.po.parse(contents);
|
|
51
|
-
|
|
52
|
-
if (hasTranslations) build.context.logger?.warn({ path: full }, "stray translation file");
|
|
62
|
+
if (Object.entries(parsed.translations || {}).some(([ctx, msgs]) => Object.keys(msgs).some((id) => !(ctx === "" && id === "")))) build.context.logger?.warn({ path: full }, "stray translation file");
|
|
53
63
|
else {
|
|
54
64
|
await node_fs_promises.default.unlink(full);
|
|
55
65
|
build.context.logger?.info({ path: full }, "removed empty translation file");
|
|
56
66
|
}
|
|
57
67
|
}
|
|
58
|
-
return void 0;
|
|
59
68
|
});
|
|
60
69
|
}
|
|
61
70
|
};
|
|
@@ -65,8 +74,7 @@ function cleanup() {
|
|
|
65
74
|
//#region src/plugins/core/queries/comment.ts
|
|
66
75
|
function getReference(node, { path: path$1 }) {
|
|
67
76
|
const line = node.startPosition.row + 1;
|
|
68
|
-
|
|
69
|
-
return `${rel}:${line}`;
|
|
77
|
+
return `${(0, node_path.relative)(process.cwd(), path$1).replace(/\\+/g, "/")}:${line}`;
|
|
70
78
|
}
|
|
71
79
|
function getComment(node) {
|
|
72
80
|
const text = node.text;
|
|
@@ -118,8 +126,7 @@ const importQuery = {
|
|
|
118
126
|
]
|
|
119
127
|
`,
|
|
120
128
|
extract(match) {
|
|
121
|
-
|
|
122
|
-
return node?.text;
|
|
129
|
+
return (match.captures.find((c) => c.name === "import")?.node)?.text;
|
|
123
130
|
}
|
|
124
131
|
};
|
|
125
132
|
|
|
@@ -161,7 +168,7 @@ const notInPlural = (query) => ({
|
|
|
161
168
|
"ngettext",
|
|
162
169
|
"pgettext",
|
|
163
170
|
"npgettext"
|
|
164
|
-
].includes(fn.childForFieldName("property")?.text ?? "")) return
|
|
171
|
+
].includes(fn.childForFieldName("property")?.text ?? "")) return;
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
174
|
return result;
|
|
@@ -189,7 +196,7 @@ const messageArg = `[
|
|
|
189
196
|
const messageArgs = `[ (arguments ${messageArg}) (template_string) @tpl ]`;
|
|
190
197
|
const extractMessage = (name) => (match) => {
|
|
191
198
|
const node = match.captures.find((c) => c.name === "call")?.node;
|
|
192
|
-
if (!node) return
|
|
199
|
+
if (!node) return;
|
|
193
200
|
const msgid = match.captures.find((c) => c.name === "msgid")?.node.text;
|
|
194
201
|
if (msgid) return {
|
|
195
202
|
node,
|
|
@@ -220,13 +227,12 @@ const extractMessage = (name) => (match) => {
|
|
|
220
227
|
const id = match.captures.find((c) => c.name === "id")?.node.text;
|
|
221
228
|
const message = match.captures.find((c) => c.name === "message")?.node.text;
|
|
222
229
|
const msgId = id ?? message;
|
|
223
|
-
if (!msgId) return
|
|
224
|
-
const msgstr = message ?? id ?? "";
|
|
230
|
+
if (!msgId) return;
|
|
225
231
|
return {
|
|
226
232
|
node,
|
|
227
233
|
translation: {
|
|
228
234
|
id: msgId,
|
|
229
|
-
message: [
|
|
235
|
+
message: [message ?? id ?? ""]
|
|
230
236
|
}
|
|
231
237
|
};
|
|
232
238
|
};
|
|
@@ -244,8 +250,8 @@ const messageInvalidQuery = notInPlural({
|
|
|
244
250
|
extract(match) {
|
|
245
251
|
const call = match.captures.find((c) => c.name === "call")?.node;
|
|
246
252
|
const node = match.captures.find((c) => c.name === "arg")?.node;
|
|
247
|
-
if (!call || !node) return
|
|
248
|
-
if (allowed$1.has(node.type)) return
|
|
253
|
+
if (!call || !node) return;
|
|
254
|
+
if (allowed$1.has(node.type)) return;
|
|
249
255
|
return {
|
|
250
256
|
node,
|
|
251
257
|
error: "message() argument must be a string literal, object literal, or template literal"
|
|
@@ -258,7 +264,7 @@ const messageInvalidQuery = notInPlural({
|
|
|
258
264
|
const extractPluralForms = (name) => (match) => {
|
|
259
265
|
const call = match.captures.find((c) => c.name === "call")?.node;
|
|
260
266
|
const n = match.captures.find((c) => c.name === "n")?.node;
|
|
261
|
-
if (!call || !n || n.nextNamedSibling) return
|
|
267
|
+
if (!call || !n || n.nextNamedSibling) return;
|
|
262
268
|
const msgctxt = match.captures.find((c) => c.name === "msgctxt")?.node?.text;
|
|
263
269
|
const msgNodes = match.captures.filter((c) => c.name === "msg").map((c) => c.node);
|
|
264
270
|
const ids = [];
|
|
@@ -288,7 +294,7 @@ const extractPluralForms = (name) => (match) => {
|
|
|
288
294
|
strs.push(result.translation.message[0] ?? "");
|
|
289
295
|
}
|
|
290
296
|
}
|
|
291
|
-
if (ids.length === 0) return
|
|
297
|
+
if (ids.length === 0) return;
|
|
292
298
|
const translation = {
|
|
293
299
|
id: ids[0],
|
|
294
300
|
plural: ids[1],
|
|
@@ -349,12 +355,12 @@ const contextInvalidQuery = withComment({
|
|
|
349
355
|
pattern: ctxCall,
|
|
350
356
|
extract(match) {
|
|
351
357
|
const call = match.captures.find((c) => c.name === "ctx")?.node;
|
|
352
|
-
if (!call) return
|
|
358
|
+
if (!call) return;
|
|
353
359
|
const parent = call.parent;
|
|
354
360
|
if (parent && parent.type === "member_expression" && parent.childForFieldName("object")?.id === call.id) {
|
|
355
361
|
const property = parent.childForFieldName("property")?.text;
|
|
356
362
|
const grandparent = parent.parent;
|
|
357
|
-
if (grandparent && grandparent.type === "call_expression" && grandparent.childForFieldName("function")?.id === parent.id && (property === "message" || property === "plural")) return
|
|
363
|
+
if (grandparent && grandparent.type === "call_expression" && grandparent.childForFieldName("function")?.id === parent.id && (property === "message" || property === "plural")) return;
|
|
358
364
|
}
|
|
359
365
|
return {
|
|
360
366
|
node: call,
|
|
@@ -381,8 +387,8 @@ const gettextInvalidQuery = {
|
|
|
381
387
|
extract(match) {
|
|
382
388
|
const call = match.captures.find((c) => c.name === "call")?.node;
|
|
383
389
|
const node = match.captures.find((c) => c.name === "arg")?.node;
|
|
384
|
-
if (!call || !node) return
|
|
385
|
-
if (allowed.has(node.type)) return
|
|
390
|
+
if (!call || !node) return;
|
|
391
|
+
if (allowed.has(node.type)) return;
|
|
386
392
|
return {
|
|
387
393
|
node,
|
|
388
394
|
error: "gettext() argument must be a string literal, object literal, or template literal"
|
|
@@ -550,7 +556,7 @@ function findTsconfig(dir) {
|
|
|
550
556
|
const config = node_path.default.join(current, "tsconfig.json");
|
|
551
557
|
if (node_fs.default.existsSync(config)) return config;
|
|
552
558
|
const parent = node_path.default.dirname(current);
|
|
553
|
-
if (parent === current) return
|
|
559
|
+
if (parent === current) return;
|
|
554
560
|
current = parent;
|
|
555
561
|
}
|
|
556
562
|
}
|
|
@@ -643,7 +649,6 @@ function core() {
|
|
|
643
649
|
namespace: "translate",
|
|
644
650
|
data: translations
|
|
645
651
|
});
|
|
646
|
-
return void 0;
|
|
647
652
|
});
|
|
648
653
|
}
|
|
649
654
|
};
|
|
@@ -789,7 +794,7 @@ function po() {
|
|
|
789
794
|
filter: /.*/,
|
|
790
795
|
namespace
|
|
791
796
|
}, async ({ entrypoint, path: path$1, data }) => {
|
|
792
|
-
if (!data || !Array.isArray(data)) return
|
|
797
|
+
if (!data || !Array.isArray(data)) return;
|
|
793
798
|
for (const locale of build.context.config.locales) {
|
|
794
799
|
const destination = build.context.config.destination({
|
|
795
800
|
entrypoint,
|
|
@@ -811,7 +816,6 @@ function po() {
|
|
|
811
816
|
namespace
|
|
812
817
|
});
|
|
813
818
|
});
|
|
814
|
-
return void 0;
|
|
815
819
|
});
|
|
816
820
|
build.onLoad({
|
|
817
821
|
filter: /.*\.po$/,
|
|
@@ -832,7 +836,7 @@ function po() {
|
|
|
832
836
|
const collected = collections.get(path$1);
|
|
833
837
|
if (!collected) {
|
|
834
838
|
build.context.logger?.warn({ path: path$1 }, "no translations collected for this path");
|
|
835
|
-
return
|
|
839
|
+
return;
|
|
836
840
|
}
|
|
837
841
|
const { locale, translations } = collected;
|
|
838
842
|
const record = collect(translations, locale);
|
|
@@ -889,8 +893,7 @@ function resolvePlugins(user) {
|
|
|
889
893
|
function defineConfig(config) {
|
|
890
894
|
const defaultLocale = config.defaultLocale ?? "en";
|
|
891
895
|
const plugins = resolvePlugins(config.plugins);
|
|
892
|
-
const
|
|
893
|
-
const entrypoints = raw.map(resolveEntrypoint);
|
|
896
|
+
const entrypoints = (Array.isArray(config.entrypoints) ? config.entrypoints : [config.entrypoints]).map(resolveEntrypoint);
|
|
894
897
|
return {
|
|
895
898
|
plugins,
|
|
896
899
|
entrypoints,
|
|
@@ -945,8 +948,7 @@ function buildTemplate(node) {
|
|
|
945
948
|
raw: false
|
|
946
949
|
});
|
|
947
950
|
else if (expr.type === "template_string") {
|
|
948
|
-
|
|
949
|
-
if (hasSubstitutions) return {
|
|
951
|
+
if (expr.children.some((c) => c.type === "template_substitution")) return {
|
|
950
952
|
text: "",
|
|
951
953
|
error: "JSX expressions with template substitutions are not supported"
|
|
952
954
|
};
|
|
@@ -968,8 +970,7 @@ function buildTemplate(node) {
|
|
|
968
970
|
raw: false
|
|
969
971
|
});
|
|
970
972
|
segmentStart = child.endIndex;
|
|
971
|
-
} else if (child.type === "jsx_text" || child.type === "html_character_reference" || child.isError)
|
|
972
|
-
else return {
|
|
973
|
+
} else if (child.type === "jsx_text" || child.type === "html_character_reference" || child.isError) {} else return {
|
|
973
974
|
text: "",
|
|
974
975
|
error: "Unsupported JSX child"
|
|
975
976
|
};
|
|
@@ -1017,13 +1018,11 @@ function buildAttrValue(node) {
|
|
|
1017
1018
|
if (expr.type === "identifier") return { text: `\${${expr.text}}` };
|
|
1018
1019
|
else if (expr.type === "string") return { text: expr.text.slice(1, -1) };
|
|
1019
1020
|
else if (expr.type === "template_string") {
|
|
1020
|
-
|
|
1021
|
-
if (hasSubstitutions) return {
|
|
1021
|
+
if (expr.children.some((c) => c.type === "template_substitution")) return {
|
|
1022
1022
|
text: "",
|
|
1023
1023
|
error: "JSX expressions with template substitutions are not supported"
|
|
1024
1024
|
};
|
|
1025
|
-
|
|
1026
|
-
return { text: content };
|
|
1025
|
+
return { text: expr.text.slice(1, -1) };
|
|
1027
1026
|
} else return {
|
|
1028
1027
|
text: "",
|
|
1029
1028
|
error: "JSX expressions must be simple identifiers, strings, or template literals"
|
|
@@ -1213,22 +1212,22 @@ function react() {
|
|
|
1213
1212
|
build.onResolve({
|
|
1214
1213
|
filter: /.*/,
|
|
1215
1214
|
namespace: "source"
|
|
1216
|
-
}, ({ entrypoint, path: path$1, namespace: namespace$
|
|
1215
|
+
}, ({ entrypoint, path: path$1, namespace: namespace$3 }) => {
|
|
1217
1216
|
return {
|
|
1218
1217
|
entrypoint,
|
|
1219
|
-
namespace: namespace$
|
|
1218
|
+
namespace: namespace$3,
|
|
1220
1219
|
path: (0, node_path.resolve)(path$1)
|
|
1221
1220
|
};
|
|
1222
1221
|
});
|
|
1223
1222
|
build.onLoad({
|
|
1224
1223
|
filter,
|
|
1225
1224
|
namespace: "source"
|
|
1226
|
-
}, async ({ entrypoint, path: path$1, namespace: namespace$
|
|
1225
|
+
}, async ({ entrypoint, path: path$1, namespace: namespace$3 }) => {
|
|
1227
1226
|
const data = await (0, node_fs_promises.readFile)(path$1, "utf8");
|
|
1228
1227
|
return {
|
|
1229
1228
|
entrypoint,
|
|
1230
1229
|
path: path$1,
|
|
1231
|
-
namespace: namespace$
|
|
1230
|
+
namespace: namespace$3,
|
|
1232
1231
|
data
|
|
1233
1232
|
};
|
|
1234
1233
|
});
|
|
@@ -1244,7 +1243,6 @@ function react() {
|
|
|
1244
1243
|
namespace: "translate",
|
|
1245
1244
|
data: translations
|
|
1246
1245
|
});
|
|
1247
|
-
return void 0;
|
|
1248
1246
|
});
|
|
1249
1247
|
}
|
|
1250
1248
|
};
|
package/dist/src/index.d.cts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PluralFormsLocale } from "@let-value/translate";
|
|
2
|
+
import { LogLevelNames, Logger } from "loglevel";
|
|
3
3
|
import { GetTextTranslationRecord } from "gettext-parser";
|
|
4
4
|
|
|
5
|
+
//#region src/logger.d.ts
|
|
6
|
+
type LogLevel = LogLevelNames;
|
|
7
|
+
//#endregion
|
|
5
8
|
//#region src/plugin.d.ts
|
|
6
9
|
type MaybePromise<T> = T | Promise<T>;
|
|
7
10
|
interface Context {
|
|
@@ -133,15 +136,15 @@ interface UserConfig {
|
|
|
133
136
|
/**
|
|
134
137
|
* Default locale to use as the base for extraction
|
|
135
138
|
* @default "en"
|
|
136
|
-
* @see {@link
|
|
139
|
+
* @see {@link PluralFormsLocale} for available locales
|
|
137
140
|
*/
|
|
138
|
-
defaultLocale?:
|
|
141
|
+
defaultLocale?: PluralFormsLocale;
|
|
139
142
|
/**
|
|
140
143
|
* Array of locales to extract translations for
|
|
141
144
|
* @default [defaultLocale]
|
|
142
|
-
* @see {@link
|
|
145
|
+
* @see {@link PluralFormsLocale} for available locales
|
|
143
146
|
*/
|
|
144
|
-
locales?:
|
|
147
|
+
locales?: PluralFormsLocale[];
|
|
145
148
|
/**
|
|
146
149
|
* Array of plugins to use or a function to override the default plugins
|
|
147
150
|
* @default DefaultPlugins
|
|
@@ -186,7 +189,7 @@ interface UserConfig {
|
|
|
186
189
|
* Log level for the extraction process
|
|
187
190
|
* @default "info"
|
|
188
191
|
*/
|
|
189
|
-
logLevel?:
|
|
192
|
+
logLevel?: LogLevel;
|
|
190
193
|
}
|
|
191
194
|
interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
|
|
192
195
|
exclude?: Exclude[];
|
|
@@ -199,7 +202,7 @@ interface ResolvedConfig {
|
|
|
199
202
|
destination: DestinationFn;
|
|
200
203
|
obsolete: ObsoleteStrategy;
|
|
201
204
|
walk: boolean;
|
|
202
|
-
logLevel:
|
|
205
|
+
logLevel: LogLevel;
|
|
203
206
|
exclude: Exclude[];
|
|
204
207
|
}
|
|
205
208
|
/**
|
package/dist/src/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/logger.ts","../../src/plugin.ts","../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/types.ts","../../src/plugins/core/core.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/react.ts","../../src/run.ts"],"sourcesContent":[],"mappings":";;;;;KAIY,QAAA,GAAW;;;KCDlB,kBAAkB,IAAI,QAAQ;UAElB,OAAA;UACL;EDFA,WAAQ,ECGH,IDHG;WCIP;;UAGI;EARZ,UAAA,EAAA,MAAY;EAAA,I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vB,CAAA;;;;;;;aAEA,CAAA,EKNnB,aLMmB;EAAW;AAGhD;;;;;EAEsB,QAAA,CAAA,EKJP,gBLIO;;;;AClEtB;;;;ACPA;AAQA;;;YGyEc,UAAU;EFxER;;;;EAAc,QAAA,CAAA,EE6Ef,QF7Ee;;UEgFb,kBAAA,SAA2B,KAAK;YACnC;ADjFd;AAIgB,UCgFC,cAAA,CDhFgB;EAcjB,OAAA,ECmEH,MDnEU,EAAA;EAAA,WAAA,ECoEN,kBDpEM,EAAA;eAAS,EAAA,MAAA;SAAiC,EAAA,MAAA,EAAA;EAAwB,WAAA,ECuExE,aDvEwE;EA6CzE,QAAK,EC2BP,gBD3BO;EAAA,IAAA,EAAA,OAAA;UACR,EC4BC,QD5BD;SACU,EC4BV,OD5BU,EAAA;;;;AAyGvB;;iBCtCgB,YAAA,SAAqB,aAAa;;;iBCtIlC,KAAA,CAAA,GAAS,eAAe;;;KCO5B,IAAA;;ERZA,IAAA,EQeI,WRfI;;;QQmBJ;APtB0B,CAAA,GAErC;EAAY,IAAA,EAAA,SAAA;MAAM,EOwBP,WPxBO;;AAAI,iBO2BL,GAAA,CP3BK,UAAA,EO4BX,kBP5BW,EAAA;EAAA,MAAA;EAAA;CAAA,EAAA;EAAO,MAAA,EO6BA,cP7BA;EAEjB,MAAA,CAAA,EO2B0C,MP3BnC;CAAA,CAAA,EO2B2C,OP3B3C,CAAA,IAAA,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import log, { LogLevelNames, Logger } from "loglevel";
|
|
2
2
|
import { GetTextTranslationRecord } from "gettext-parser";
|
|
3
3
|
import Parser from "tree-sitter";
|
|
4
|
-
import {
|
|
4
|
+
import { PluralFormsLocale } from "@let-value/translate";
|
|
5
5
|
|
|
6
|
+
//#region src/logger.d.ts
|
|
7
|
+
type LogLevel = LogLevelNames;
|
|
8
|
+
//#endregion
|
|
6
9
|
//#region src/plugin.d.ts
|
|
7
10
|
type MaybePromise<T> = T | Promise<T>;
|
|
8
11
|
interface Context {
|
|
@@ -134,15 +137,15 @@ interface UserConfig {
|
|
|
134
137
|
/**
|
|
135
138
|
* Default locale to use as the base for extraction
|
|
136
139
|
* @default "en"
|
|
137
|
-
* @see {@link
|
|
140
|
+
* @see {@link PluralFormsLocale} for available locales
|
|
138
141
|
*/
|
|
139
|
-
defaultLocale?:
|
|
142
|
+
defaultLocale?: PluralFormsLocale;
|
|
140
143
|
/**
|
|
141
144
|
* Array of locales to extract translations for
|
|
142
145
|
* @default [defaultLocale]
|
|
143
|
-
* @see {@link
|
|
146
|
+
* @see {@link PluralFormsLocale} for available locales
|
|
144
147
|
*/
|
|
145
|
-
locales?:
|
|
148
|
+
locales?: PluralFormsLocale[];
|
|
146
149
|
/**
|
|
147
150
|
* Array of plugins to use or a function to override the default plugins
|
|
148
151
|
* @default DefaultPlugins
|
|
@@ -187,7 +190,7 @@ interface UserConfig {
|
|
|
187
190
|
* Log level for the extraction process
|
|
188
191
|
* @default "info"
|
|
189
192
|
*/
|
|
190
|
-
logLevel?:
|
|
193
|
+
logLevel?: LogLevel;
|
|
191
194
|
}
|
|
192
195
|
interface ResolvedEntrypoint extends Omit<EntrypointConfig, "exclude"> {
|
|
193
196
|
exclude?: Exclude[];
|
|
@@ -200,7 +203,7 @@ interface ResolvedConfig {
|
|
|
200
203
|
destination: DestinationFn;
|
|
201
204
|
obsolete: ObsoleteStrategy;
|
|
202
205
|
walk: boolean;
|
|
203
|
-
logLevel:
|
|
206
|
+
logLevel: LogLevel;
|
|
204
207
|
exclude: Exclude[];
|
|
205
208
|
}
|
|
206
209
|
/**
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/logger.ts","../../src/plugin.ts","../../src/plugins/cleanup/cleanup.ts","../../src/plugins/core/queries/types.ts","../../src/plugins/core/core.ts","../../src/plugins/po/po.ts","../../src/configuration.ts","../../src/plugins/react/react.ts","../../src/run.ts"],"sourcesContent":[],"mappings":";;;;;;KAIY,QAAA,GAAW;;;KCDlB,kBAAkB,IAAI,QAAQ;UAElB,OAAA;UACL;eACK;EDHL,MAAA,CAAA,ECIC,MDJO;;UCOH;;EARZ,IAAA,EAAA,MAAA;EAAY,SAAA,EAAA,MAAA;MAAM,CAAA,EAYZ,MAZY;;AAAI,UAeV,aAfU,CAAA,SAAA,OAAA,CAAA,CAAA;EAAO,UAAA,EAAA,MAAA;EAEjB,IAAA,EAAA,MAAO;EAAA,SAAA,EAAA,MAAA;MACZ,CAAA,EAgBD,MAhBC;;AAEC,UAiBI,QAjBJ,CAAA,SAAA,OAAA,CAAA,CAAA;EAAM,UAAA,EAAA,MAAA;EAGF,IAAA,EAAA,MAAA;EAOA,SAAA,EAAA,MAAa;EAOb,IAAA,CAAA,EAIN,MAJc;AAOzB;AAOiB,UAPA,UAOW,CAAA,SAIZ,OAAA,CAAA,CAAA;EAGC,UAAA,EAAA,MAAa;EAOlB,IAAA,EAAA,MAAM;EACN,SAAA,EAAA,MAAW;EAAA,IAAA,EAlBb,MAkBa;;AACb,UAhBO,WAgBP,CAAA,SAAA,OAAA,CAAA,CAAA;YACsB,EAAA,MAAA;MAAd,EAAA,MAAA;WAAb,EAAA,MAAA;EAAY,IAAA,EAbP,MAaO;AACjB;AAAoB,UAXH,aAWG,CAAA,UAAA,OAAA,CAAA,CAAA;YAAqC,EAAA,MAAA;MAAT,EAAA,MAAA;WAA6C,EAAA,MAAA;MAAX,EAPxE,OAOwE;;AAAD,KAJrE,MAAA,GAIqE;EACrE,MAAA,EALmB,MAKR;EAAA,SAAA,CAAA,EAAA,MAAA;;AACb,KALE,WAKF,CAAA,SAAA,OAAA,CAAA,GAAA,CAAA,IAAA,EAJA,WAIA,CAJY,MAIZ,CAAA,EAAA,GAHL,YAGK,CAHQ,aAGR,CAHsB,MAGtB,C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