@lingui/cli 4.6.0 → 4.7.1
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/catalog/getCatalogs.js +4 -1
- package/dist/api/compile.js +14 -1
- package/dist/api/utils.d.ts +0 -2
- package/dist/api/utils.js +3 -10
- package/dist/lingui-compile.js +0 -8
- package/package.json +8 -8
|
@@ -93,7 +93,10 @@ function getCatalogForFile(file, catalogs) {
|
|
|
93
93
|
for (const catalog of catalogs) {
|
|
94
94
|
const catalogFile = `${catalog.path}${catalog.format.getCatalogExtension()}`;
|
|
95
95
|
const catalogGlob = (0, utils_1.replacePlaceholders)(catalogFile, { locale: "*" });
|
|
96
|
-
const
|
|
96
|
+
const matchPattern = (0, utils_1.normalizeRelativePath)(path_1.default.relative(catalog.config.rootDir, catalogGlob))
|
|
97
|
+
.replace("(", "\\(")
|
|
98
|
+
.replace(")", "\\)");
|
|
99
|
+
const match = micromatch_1.default.capture(matchPattern, (0, utils_1.normalizeRelativePath)(file));
|
|
97
100
|
if (match) {
|
|
98
101
|
return {
|
|
99
102
|
locale: match[0],
|
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/api/utils.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export declare const PATHSEP = "/";
|
|
2
2
|
export declare function prettyOrigin(origins: [filename: string, line?: number][]): string;
|
|
3
3
|
export declare function replacePlaceholders(input: string, values: Record<string, string>): string;
|
|
4
|
-
export declare const splitOrigin: (origin: string) => [file: string, line: number];
|
|
5
|
-
export declare const joinOrigin: (origin: [file: string, line?: number]) => string;
|
|
6
4
|
export declare function readFile(fileName: string): Promise<string | undefined>;
|
|
7
5
|
export declare function isDirectory(filePath: string): boolean;
|
|
8
6
|
export declare function writeFile(fileName: string, content: string): Promise<void>;
|
package/dist/api/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeRelativePath = exports.normalizeSlashes = exports.makeInstall = exports.hasYarn = exports.writeFileIfChanged = exports.writeFile = exports.isDirectory = exports.readFile = exports.
|
|
6
|
+
exports.normalizeRelativePath = exports.normalizeSlashes = exports.makeInstall = exports.hasYarn = exports.writeFileIfChanged = exports.writeFile = exports.isDirectory = exports.readFile = exports.replacePlaceholders = exports.prettyOrigin = exports.PATHSEP = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
@@ -24,16 +24,9 @@ function replacePlaceholders(input, values) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
exports.replacePlaceholders = replacePlaceholders;
|
|
27
|
-
const splitOrigin = (origin) => {
|
|
28
|
-
const [file, line] = origin.split(":");
|
|
29
|
-
return [file, line ? Number(line) : null];
|
|
30
|
-
};
|
|
31
|
-
exports.splitOrigin = splitOrigin;
|
|
32
|
-
const joinOrigin = (origin) => origin.join(":");
|
|
33
|
-
exports.joinOrigin = joinOrigin;
|
|
34
27
|
async function readFile(fileName) {
|
|
35
28
|
try {
|
|
36
|
-
return (await fs_1.default.promises.readFile(fileName)).toString();
|
|
29
|
+
return (await fs_1.default.promises.readFile(fileName, "utf-8")).toString();
|
|
37
30
|
}
|
|
38
31
|
catch (err) {
|
|
39
32
|
if (err.code != "ENOENT") {
|
|
@@ -67,7 +60,7 @@ function isDirectory(filePath) {
|
|
|
67
60
|
exports.isDirectory = isDirectory;
|
|
68
61
|
async function writeFile(fileName, content) {
|
|
69
62
|
await mkdirp(path_1.default.dirname(fileName));
|
|
70
|
-
await fs_1.default.promises.writeFile(fileName, content);
|
|
63
|
+
await fs_1.default.promises.writeFile(fileName, content, "utf-8");
|
|
71
64
|
}
|
|
72
65
|
exports.writeFile = writeFile;
|
|
73
66
|
async function writeFileIfChanged(filename, newContent) {
|
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.7.1",
|
|
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.7.1",
|
|
57
|
+
"@lingui/conf": "4.7.1",
|
|
58
|
+
"@lingui/core": "4.7.1",
|
|
59
|
+
"@lingui/format-po": "4.7.1",
|
|
60
|
+
"@lingui/message-utils": "4.7.1",
|
|
61
61
|
"babel-plugin-macros": "^3.0.1",
|
|
62
62
|
"chalk": "^4.1.0",
|
|
63
63
|
"chokidar": "3.5.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@lingui/jest-mocks": "*",
|
|
83
|
-
"@lingui/macro": "4.
|
|
83
|
+
"@lingui/macro": "4.7.1",
|
|
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": "49647102dbbd7046a2c318ba0525c1392e370076"
|
|
92
92
|
}
|