@lingui/cli 4.7.0 → 4.8.0-next.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/api/compile.js +14 -1
- package/dist/lingui-compile.js +0 -8
- package/package.json +9 -9
package/dist/api/compile.js
CHANGED
|
@@ -53,7 +53,20 @@ function createCompiledCatalog(locale, messages, options) {
|
|
|
53
53
|
}
|
|
54
54
|
exports.createCompiledCatalog = createCompiledCatalog;
|
|
55
55
|
function buildExportStatement(expression, namespace) {
|
|
56
|
-
if (namespace === "
|
|
56
|
+
if (namespace === "ts") {
|
|
57
|
+
// import type { Messages } from "@lingui/core";
|
|
58
|
+
const importMessagesTypeDeclaration = t.importDeclaration([t.importSpecifier(t.identifier("Messages"), t.identifier("Messages"))], t.stringLiteral("@lingui/core"));
|
|
59
|
+
importMessagesTypeDeclaration.importKind = "type";
|
|
60
|
+
// Create the exported `messages` identifier with a `Messages` TS type annotation
|
|
61
|
+
const messagesIdentifier = t.identifier("messages");
|
|
62
|
+
messagesIdentifier.typeAnnotation = t.tsTypeAnnotation(t.tsTypeReference(t.identifier("Messages")));
|
|
63
|
+
// export const messages:Messages = { message: "Translation" }
|
|
64
|
+
const exportDeclaration = t.exportNamedDeclaration(t.variableDeclaration("const", [
|
|
65
|
+
t.variableDeclarator(messagesIdentifier, expression),
|
|
66
|
+
]));
|
|
67
|
+
return t.program([importMessagesTypeDeclaration, exportDeclaration]);
|
|
68
|
+
}
|
|
69
|
+
else if (namespace === "es") {
|
|
57
70
|
// export const messages = { message: "Translation" }
|
|
58
71
|
return t.exportNamedDeclaration(t.variableDeclaration("const", [
|
|
59
72
|
t.variableDeclarator(t.identifier("messages"), expression),
|
package/dist/lingui-compile.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.command = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
9
|
const commander_1 = require("commander");
|
|
11
10
|
const conf_1 = require("@lingui/conf");
|
|
12
11
|
const compile_1 = require("./api/compile");
|
|
@@ -62,13 +61,6 @@ async function command(config, options) {
|
|
|
62
61
|
compilerBabelOptions: config.compilerBabelOptions,
|
|
63
62
|
});
|
|
64
63
|
let compiledPath = await catalog.writeCompiled(locale, compiledCatalog, namespace);
|
|
65
|
-
if (options.typescript) {
|
|
66
|
-
const typescriptPath = compiledPath.replace(/\.ts?$/, "") + ".d.ts";
|
|
67
|
-
fs_1.default.writeFileSync(typescriptPath, `import type { Messages } from '@lingui/core';
|
|
68
|
-
declare const messages: Messages;
|
|
69
|
-
export { messages };
|
|
70
|
-
`);
|
|
71
|
-
}
|
|
72
64
|
compiledPath = (0, utils_1.normalizeSlashes)(path_1.default.relative(config.rootDir, compiledPath));
|
|
73
65
|
options.verbose &&
|
|
74
66
|
console.error(chalk_1.default.green(`${locale} ⇒ ${compiledPath}`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0-next.0",
|
|
4
4
|
"description": "CLI for working wit message catalogs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@babel/parser": "^7.21.2",
|
|
54
54
|
"@babel/runtime": "^7.21.0",
|
|
55
55
|
"@babel/types": "^7.21.2",
|
|
56
|
-
"@lingui/babel-plugin-extract-messages": "4.
|
|
57
|
-
"@lingui/conf": "4.
|
|
58
|
-
"@lingui/core": "4.
|
|
59
|
-
"@lingui/format-po": "4.
|
|
60
|
-
"@lingui/message-utils": "4.
|
|
56
|
+
"@lingui/babel-plugin-extract-messages": "^4.8.0-next.0",
|
|
57
|
+
"@lingui/conf": "^4.8.0-next.0",
|
|
58
|
+
"@lingui/core": "^4.8.0-next.0",
|
|
59
|
+
"@lingui/format-po": "^4.8.0-next.0",
|
|
60
|
+
"@lingui/message-utils": "^4.8.0-next.0",
|
|
61
61
|
"babel-plugin-macros": "^3.0.1",
|
|
62
62
|
"chalk": "^4.1.0",
|
|
63
63
|
"chokidar": "3.5.1",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"source-map": "^0.8.0-beta.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@lingui/jest-mocks": "
|
|
83
|
-
"@lingui/macro": "4.
|
|
82
|
+
"@lingui/jest-mocks": "^3.0.3",
|
|
83
|
+
"@lingui/macro": "^4.8.0-next.0",
|
|
84
84
|
"@types/convert-source-map": "^2.0.0",
|
|
85
85
|
"@types/glob": "^8.1.0",
|
|
86
86
|
"@types/micromatch": "^4.0.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"mock-fs": "^5.2.0",
|
|
89
89
|
"mockdate": "^3.0.5"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "d085ac65d66ce6c2f866b703b6346e53ff0bf6b3"
|
|
92
92
|
}
|