@lingui/cli 6.6.0 → 6.8.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 +27 -6
- package/dist/api/catalog/extractFromFiles.d.ts +3 -3
- package/dist/api/catalog/extractFromFiles.js +15 -7
- package/dist/api/catalog/getTranslationsForCatalog.d.ts +11 -2
- package/dist/api/catalog/getTranslationsForCatalog.js +61 -28
- package/dist/api/catalog/mergeCatalog.js +3 -1
- package/dist/api/catalog/translations.d.ts +16 -0
- package/dist/api/catalog/translations.js +35 -0
- package/dist/api/catalog.d.ts +0 -1
- package/dist/api/catalog.js +8 -62
- package/dist/api/check/index.d.ts +8 -0
- package/dist/api/check/index.js +39 -0
- package/dist/api/check/missing.d.ts +2 -0
- package/dist/api/check/missing.js +56 -0
- package/dist/api/check/sync.d.ts +2 -0
- package/dist/api/check/sync.js +96 -0
- package/dist/api/check/types.d.ts +62 -0
- package/dist/api/check/types.js +13 -0
- package/dist/api/compile/compileLocale.js +11 -10
- package/dist/api/extractors/index.d.ts +1 -4
- package/dist/api/extractors/index.js +3 -10
- package/dist/api/formats/formatterWrapper.d.ts +1 -0
- package/dist/api/formats/formatterWrapper.js +12 -5
- package/dist/api/index.d.ts +3 -1
- package/dist/api/index.js +1 -1
- package/dist/api/messages.d.ts +8 -2
- package/dist/api/messages.js +29 -2
- package/dist/api/resolveWorkersOptions.js +17 -3
- package/dist/api/runBounded.d.ts +1 -0
- package/dist/api/runBounded.js +13 -0
- package/dist/api/stats.js +3 -2
- package/dist/api/utils.d.ts +5 -0
- package/dist/api/utils.js +7 -0
- package/dist/api/workerPools.d.ts +2 -0
- package/dist/api/workerPools.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/lingui-check.d.ts +6 -0
- package/dist/lingui-check.js +137 -0
- package/dist/lingui-compile.js +6 -6
- package/dist/lingui-extract-experimental.js +1 -1
- package/dist/lingui-extract-template.js +1 -1
- package/dist/lingui-extract.js +1 -1
- package/dist/lingui.js +1 -0
- package/dist/services/translationIO.js +2 -2
- package/dist/workers/missingWorker.d.ts +4 -0
- package/dist/workers/missingWorker.js +23 -0
- package/dist/workers/missingWorkerWrapper.prod.d.ts +3 -0
- package/dist/workers/missingWorkerWrapper.prod.js +2 -0
- package/package.json +10 -10
package/dist/lingui-compile.js
CHANGED
|
@@ -9,6 +9,7 @@ import { createCompileWorkerPool } from "./api/workerPools.js";
|
|
|
9
9
|
import { resolveWorkersOptions, } from "./api/resolveWorkersOptions.js";
|
|
10
10
|
import ms from "ms";
|
|
11
11
|
import { getPathsForCompileWatcher } from "./api/getPathsForCompileWatcher.js";
|
|
12
|
+
import { ProgramExit } from "./api/ProgramExit.js";
|
|
12
13
|
export async function command(config, options) {
|
|
13
14
|
const startTime = Date.now();
|
|
14
15
|
// Check config.compile.merge if catalogs for current locale are to be merged into a single compiled file
|
|
@@ -23,7 +24,7 @@ export async function command(config, options) {
|
|
|
23
24
|
await compileLocale(catalogs, locale, options, config, doMerge, console);
|
|
24
25
|
}
|
|
25
26
|
catch (err) {
|
|
26
|
-
if (err
|
|
27
|
+
if (err instanceof ProgramExit) {
|
|
27
28
|
errored = true;
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
@@ -68,10 +69,10 @@ if (import.meta.main) {
|
|
|
68
69
|
program
|
|
69
70
|
.description("Compile message catalogs to compiled bundle.")
|
|
70
71
|
.option("--config <path>", "Path to the config file")
|
|
71
|
-
.option("--strict", "
|
|
72
|
+
.option("--strict", "Fail if translations are missing after applying fallbackLocales, or if compilation errors occur")
|
|
72
73
|
.option("--verbose", "Verbose output")
|
|
73
74
|
.option("--typescript", "Create Typescript definition for compiled bundle")
|
|
74
|
-
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
75
|
+
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8; on 1-2 core machines, all cores). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
75
76
|
.option("--namespace <namespace>", "Specify namespace for compiled bundle. Ex: cjs(default) -> module.exports, es -> export, window.test -> window.test")
|
|
76
77
|
.option("--watch", "Enables Watch Mode")
|
|
77
78
|
.option("--debounce <delay>", "Debounces compilation for given amount of milliseconds")
|
|
@@ -81,9 +82,8 @@ if (import.meta.main) {
|
|
|
81
82
|
console.log(" # Compile translations and use defaults or message IDs for missing translations");
|
|
82
83
|
console.log(` $ ${helpRun("compile")}`);
|
|
83
84
|
console.log("");
|
|
84
|
-
console.log(" # Compile translations but fail when
|
|
85
|
-
console.log(" #
|
|
86
|
-
console.log(" # default messages or message IDs)");
|
|
85
|
+
console.log(" # Compile translations but fail when resolved output");
|
|
86
|
+
console.log(" # still has missing translations or compilation errors");
|
|
87
87
|
console.log(` $ ${helpRun("compile --strict")}`);
|
|
88
88
|
})
|
|
89
89
|
.parse(process.argv);
|
|
@@ -183,7 +183,7 @@ if (import.meta.main) {
|
|
|
183
183
|
.option("--clean", "Remove obsolete translations")
|
|
184
184
|
.option("--locale <locale, [...]>", "Only extract the specified locales")
|
|
185
185
|
.option("--verbose", "Verbose output")
|
|
186
|
-
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
186
|
+
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8; on 1-2 core machines, all cores). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
187
187
|
.parse(process.argv);
|
|
188
188
|
const options = program.opts();
|
|
189
189
|
const config = getConfig({
|
|
@@ -45,7 +45,7 @@ if (import.meta.main) {
|
|
|
45
45
|
program
|
|
46
46
|
.option("--config <path>", "Path to the config file")
|
|
47
47
|
.option("--verbose", "Verbose output")
|
|
48
|
-
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
48
|
+
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8; on 1-2 core machines, all cores). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
49
49
|
.parse(process.argv);
|
|
50
50
|
const options = program.opts();
|
|
51
51
|
const config = getConfig({
|
package/dist/lingui-extract.js
CHANGED
|
@@ -97,7 +97,7 @@ if (import.meta.main) {
|
|
|
97
97
|
.map((s) => s.trim())
|
|
98
98
|
.filter(Boolean);
|
|
99
99
|
})
|
|
100
|
-
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
100
|
+
.option("--workers <n>", "Number of worker threads to use (default: CPU count - 1, capped at 8; on 1-2 core machines, all cores). Pass `--workers 1` to disable worker threads and run everything in a single process")
|
|
101
101
|
.option("--overwrite", "Overwrite translations for source locale")
|
|
102
102
|
.option("--clean", "Remove obsolete translations")
|
|
103
103
|
.option("--debounce <delay>", "Debounces extraction for given amount of milliseconds")
|
package/dist/lingui.js
CHANGED
|
@@ -8,5 +8,6 @@ program
|
|
|
8
8
|
.command("extract [files...]", "Extracts messages from source files")
|
|
9
9
|
.command("extract-experimental", "Extracts messages from source files traversing dependency tree")
|
|
10
10
|
.command("extract-template", "Extracts messages from source files to a .pot template")
|
|
11
|
+
.command("check", "Checks message catalogs")
|
|
11
12
|
.command("compile", "Compile message catalogs")
|
|
12
13
|
.parse(process.argv);
|
|
@@ -7,8 +7,8 @@ import { readFileSync } from "node:fs";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
const getTargetLocales = (config) => {
|
|
9
9
|
const sourceLocale = config.sourceLocale || "en";
|
|
10
|
-
const
|
|
11
|
-
return config.locales.filter((value) => value != sourceLocale && value
|
|
10
|
+
const pseudoLocales = new Set(config.pseudoLocale.map((item) => item.locale));
|
|
11
|
+
return config.locales.filter((value) => value != sourceLocale && !pseudoLocales.has(value));
|
|
12
12
|
};
|
|
13
13
|
// Main sync method, call "Init" or "Sync" depending on the project context
|
|
14
14
|
export default async function syncProcess(config, options, extractionResult) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MissingTranslationFinding } from "../api/catalog/translations.js";
|
|
2
|
+
import type { MissingBehavior } from "../api/catalog/getTranslationsForCatalog.js";
|
|
3
|
+
export type MissingWorkerFunction = typeof missingWorker;
|
|
4
|
+
export declare const missingWorker: (catalogPath: string, locale: string, missingBehavior: MissingBehavior, linguiConfigPath: string) => Promise<MissingTranslationFinding[]>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getConfig } from "@lingui/conf";
|
|
2
|
+
import { getCatalogs } from "../api/catalog/getCatalogs.js";
|
|
3
|
+
import { getMissingTranslationFindings, } from "../api/catalog/translations.js";
|
|
4
|
+
let linguiConfig;
|
|
5
|
+
let catalogs;
|
|
6
|
+
export const missingWorker = async (catalogPath, locale, missingBehavior, linguiConfigPath) => {
|
|
7
|
+
if (!linguiConfig) {
|
|
8
|
+
// initialize config once per worker, speed up workers follow execution
|
|
9
|
+
linguiConfig = getConfig({
|
|
10
|
+
configPath: linguiConfigPath,
|
|
11
|
+
skipValidation: true,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (!catalogs) {
|
|
15
|
+
// catalogs depend only on the config, so initialize them once per worker
|
|
16
|
+
catalogs = await getCatalogs(linguiConfig);
|
|
17
|
+
}
|
|
18
|
+
const catalog = catalogs.find((catalog) => catalog.path === catalogPath);
|
|
19
|
+
if (!catalog) {
|
|
20
|
+
throw new Error(`Unable to find catalog at path ${catalogPath}.`);
|
|
21
|
+
}
|
|
22
|
+
return getMissingTranslationFindings(catalog, locale, missingBehavior);
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/cli",
|
|
3
|
-
"version": "6.
|
|
4
|
-
"description": "Lingui CLI
|
|
3
|
+
"version": "6.8.0",
|
|
4
|
+
"description": "Lingui CLI: extracts i18n messages from source code into catalogs and compiles the translated catalogs for the runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"lingui",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"@babel/generator": "^7.28.5",
|
|
55
55
|
"@babel/parser": "^7.22.0",
|
|
56
56
|
"@babel/types": "^7.21.2",
|
|
57
|
-
"@lingui/babel-plugin-extract-messages": "6.
|
|
58
|
-
"@lingui/babel-plugin-lingui-macro": "6.
|
|
59
|
-
"@lingui/conf": "6.
|
|
60
|
-
"@lingui/core": "6.
|
|
61
|
-
"@lingui/format-po": "6.
|
|
62
|
-
"@lingui/message-utils": "6.
|
|
57
|
+
"@lingui/babel-plugin-extract-messages": "6.8.0",
|
|
58
|
+
"@lingui/babel-plugin-lingui-macro": "6.8.0",
|
|
59
|
+
"@lingui/conf": "6.8.0",
|
|
60
|
+
"@lingui/core": "6.8.0",
|
|
61
|
+
"@lingui/format-po": "6.8.0",
|
|
62
|
+
"@lingui/message-utils": "6.8.0",
|
|
63
63
|
"chokidar": "5.0.0",
|
|
64
64
|
"cli-table3": "^0.6.5",
|
|
65
65
|
"commander": "^14.0.2",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"ms": "^2.1.3",
|
|
69
69
|
"normalize-path": "^3.0.0",
|
|
70
70
|
"ora": "^9.1.0",
|
|
71
|
-
"pseudolocale": "^
|
|
71
|
+
"pseudolocale": "^3.1.0",
|
|
72
72
|
"source-map": "^0.7.6",
|
|
73
73
|
"tinypool": "^2.1.0"
|
|
74
74
|
},
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"rolldown": "^1.1.1",
|
|
98
98
|
"vitest": "catalog:"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "8c0f1ba378076cc49b320cccd2e06c60afe94963"
|
|
101
101
|
}
|