@lingui/cli 5.6.1 → 5.7.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.
|
@@ -62,6 +62,7 @@ async function compileAndWrite(locale, config, options, writePath, messages, log
|
|
|
62
62
|
const { source: compiledCatalog, errors } = (0, compile_1.createCompiledCatalog)(locale, messages, {
|
|
63
63
|
strict: false,
|
|
64
64
|
namespace,
|
|
65
|
+
outputPrefix: options.outputPrefix,
|
|
65
66
|
pseudoLocale: config.pseudoLocale,
|
|
66
67
|
compilerBabelOptions: config.compilerBabelOptions,
|
|
67
68
|
});
|
package/dist/api/compile.d.ts
CHANGED
package/dist/api/compile.js
CHANGED
|
@@ -43,7 +43,7 @@ const generator_1 = __importDefault(require("@babel/generator"));
|
|
|
43
43
|
const compileMessage_1 = require("@lingui/message-utils/compileMessage");
|
|
44
44
|
const pseudoLocalize_1 = __importDefault(require("./pseudoLocalize"));
|
|
45
45
|
function createCompiledCatalog(locale, messages, options) {
|
|
46
|
-
const { strict = false, namespace = "cjs", pseudoLocale, compilerBabelOptions = {}, } = options;
|
|
46
|
+
const { strict = false, namespace = "cjs", pseudoLocale, compilerBabelOptions = {}, outputPrefix = "/*eslint-disable*/", } = options;
|
|
47
47
|
const shouldPseudolocalize = locale === pseudoLocale;
|
|
48
48
|
const errors = [];
|
|
49
49
|
const compiledMessages = Object.keys(messages)
|
|
@@ -72,7 +72,7 @@ function createCompiledCatalog(locale, messages, options) {
|
|
|
72
72
|
const code = (0, generator_1.default)(ast, Object.assign({ minified: true, jsescOption: {
|
|
73
73
|
minimal: true,
|
|
74
74
|
} }, compilerBabelOptions)).code;
|
|
75
|
-
return { source:
|
|
75
|
+
return { source: `${outputPrefix}` + code, errors };
|
|
76
76
|
}
|
|
77
77
|
function buildExportStatement(expression, namespace) {
|
|
78
78
|
if (namespace === "ts") {
|
package/dist/lingui-compile.d.ts
CHANGED
package/dist/lingui-compile.js
CHANGED
|
@@ -80,6 +80,7 @@ if (require.main === module) {
|
|
|
80
80
|
.option("--namespace <namespace>", "Specify namespace for compiled bundle. Ex: cjs(default) -> module.exports, es -> export, window.test -> window.test")
|
|
81
81
|
.option("--watch", "Enables Watch Mode")
|
|
82
82
|
.option("--debounce <delay>", "Debounces compilation for given amount of milliseconds")
|
|
83
|
+
.option("--output-prefix <prefix>", "Add a custom string to the beginning of compiled files (header/prefix). Useful for tools like linters or coverage directives. Defaults to '/*eslint-disable*/'")
|
|
83
84
|
.on("--help", function () {
|
|
84
85
|
console.log("\n Examples:\n");
|
|
85
86
|
console.log(" # Compile translations and use defaults or message IDs for missing translations");
|
|
@@ -102,6 +103,7 @@ if (require.main === module) {
|
|
|
102
103
|
workersOptions: (0, resolveWorkersOptions_1.resolveWorkersOptions)(options),
|
|
103
104
|
typescript: options.typescript || config.compileNamespace === "ts" || false,
|
|
104
105
|
namespace: options.namespace, // we want this to be undefined if user does not specify so default can be used
|
|
106
|
+
outputPrefix: options.outputPrefix,
|
|
105
107
|
}));
|
|
106
108
|
return previousRun;
|
|
107
109
|
};
|
|
@@ -25,9 +25,15 @@ const getTargetLocales = (config) => {
|
|
|
25
25
|
const pseudoLocale = config.pseudoLocale || "pseudo";
|
|
26
26
|
return config.locales.filter((value) => value != sourceLocale && value != pseudoLocale);
|
|
27
27
|
};
|
|
28
|
+
const validCatalogFormat = (config) => {
|
|
29
|
+
if (typeof config.format === "string") {
|
|
30
|
+
return config.format === "po";
|
|
31
|
+
}
|
|
32
|
+
return config.format.catalogExtension === ".po";
|
|
33
|
+
};
|
|
28
34
|
// Main sync method, call "Init" or "Sync" depending on the project context
|
|
29
35
|
async function syncProcess(config, options) {
|
|
30
|
-
if (config
|
|
36
|
+
if (!validCatalogFormat(config)) {
|
|
31
37
|
console.error(`\n----------\nTranslation.io service is only compatible with the "po" format. Please update your Lingui configuration accordingly.\n----------`);
|
|
32
38
|
process.exit(1);
|
|
33
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.0",
|
|
4
4
|
"description": "CLI for working wit message catalogs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -62,12 +62,12 @@
|
|
|
62
62
|
"@babel/parser": "^7.22.0",
|
|
63
63
|
"@babel/runtime": "^7.21.0",
|
|
64
64
|
"@babel/types": "^7.21.2",
|
|
65
|
-
"@lingui/babel-plugin-extract-messages": "5.
|
|
66
|
-
"@lingui/babel-plugin-lingui-macro": "5.
|
|
67
|
-
"@lingui/conf": "5.
|
|
68
|
-
"@lingui/core": "5.
|
|
69
|
-
"@lingui/format-po": "5.
|
|
70
|
-
"@lingui/message-utils": "5.
|
|
65
|
+
"@lingui/babel-plugin-extract-messages": "5.7.0",
|
|
66
|
+
"@lingui/babel-plugin-lingui-macro": "5.7.0",
|
|
67
|
+
"@lingui/conf": "5.7.0",
|
|
68
|
+
"@lingui/core": "5.7.0",
|
|
69
|
+
"@lingui/format-po": "5.7.0",
|
|
70
|
+
"@lingui/message-utils": "5.7.0",
|
|
71
71
|
"chokidar": "3.5.1",
|
|
72
72
|
"cli-table": "^0.3.11",
|
|
73
73
|
"commander": "^10.0.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"picocolors": "^1.1.1",
|
|
83
83
|
"pofile": "^1.1.4",
|
|
84
84
|
"pseudolocale": "^2.0.0",
|
|
85
|
-
"source-map": "^0.
|
|
85
|
+
"source-map": "^0.7.6",
|
|
86
86
|
"threads": "^1.7.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"mockdate": "^3.0.5",
|
|
96
96
|
"ts-node": "^10.9.2"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "e8c42d548af8fae7365094e58249148fa6a6019f"
|
|
99
99
|
}
|