@lingui/cli 5.1.1 → 5.2.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/catalog/extractFromFiles.d.ts +1 -3
- package/dist/api/catalog/extractFromFiles.js +2 -3
- package/dist/api/catalog/getCatalogDependentFiles.js +18 -9
- package/dist/api/catalog/getCatalogs.js +3 -4
- package/dist/api/catalog/getFallbackListForLocale.js +1 -2
- package/dist/api/catalog/getTranslationsForCatalog.js +6 -8
- package/dist/api/catalog/mergeCatalog.js +28 -39
- package/dist/api/catalog.d.ts +6 -11
- package/dist/api/catalog.js +21 -40
- package/dist/api/compile.js +19 -10
- package/dist/api/extractors/babel.js +6 -6
- package/dist/api/extractors/index.js +2 -2
- package/dist/api/formats/index.js +2 -2
- package/dist/api/help.js +4 -3
- package/dist/api/pseudoLocalize.js +4 -4
- package/dist/api/stats.js +3 -3
- package/dist/api/utils.js +11 -11
- package/dist/extract-experimental/bundleSource.js +1 -2
- package/dist/extract-experimental/getEntryPoints.js +1 -2
- package/dist/extract-experimental/getExperimentalCatalogs.js +1 -2
- package/dist/extract-experimental/resolveCatalogPath.js +2 -3
- package/dist/extract-experimental/resolveTemplatePath.js +1 -2
- package/dist/extract-experimental/writeCatalogs.js +3 -4
- package/dist/lingui-compile.js +4 -3
- package/dist/lingui-extract-experimental.js +1 -1
- package/dist/lingui-extract-template.js +1 -1
- package/dist/lingui-extract.js +4 -4
- package/dist/services/translationIO.js +2 -2
- package/package.json +8 -9
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { LinguiConfigNormalized } from "@lingui/conf";
|
|
2
2
|
import { ExtractedCatalogType } from "../types";
|
|
3
|
-
export declare function extractFromFiles(paths: string[], config: LinguiConfigNormalized): Promise<ExtractedCatalogType
|
|
4
|
-
[x: string]: unknown;
|
|
5
|
-
}>>;
|
|
3
|
+
export declare function extractFromFiles(paths: string[], config: LinguiConfigNormalized): Promise<ExtractedCatalogType>;
|
|
@@ -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.extractFromFiles =
|
|
6
|
+
exports.extractFromFiles = extractFromFiles;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const extractors_1 = __importDefault(require("../extractors"));
|
|
@@ -23,7 +23,7 @@ function mergePlaceholders(prev, next) {
|
|
|
23
23
|
async function extractFromFiles(paths, config) {
|
|
24
24
|
const messages = {};
|
|
25
25
|
let catalogSuccess = true;
|
|
26
|
-
for (
|
|
26
|
+
for (const filename of paths) {
|
|
27
27
|
const fileSuccess = await (0, extractors_1.default)(filename, (next) => {
|
|
28
28
|
var _a;
|
|
29
29
|
if (!messages[next.id]) {
|
|
@@ -58,4 +58,3 @@ async function extractFromFiles(paths, config) {
|
|
|
58
58
|
return undefined;
|
|
59
59
|
return messages;
|
|
60
60
|
}
|
|
61
|
-
exports.extractFromFiles = extractFromFiles;
|
|
@@ -15,18 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getCatalogDependentFiles =
|
|
39
|
+
exports.getCatalogDependentFiles = getCatalogDependentFiles;
|
|
30
40
|
const getFallbackListForLocale_1 = require("./getFallbackListForLocale");
|
|
31
41
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
32
42
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -52,4 +62,3 @@ async function getCatalogDependentFiles(catalog, locale) {
|
|
|
52
62
|
}
|
|
53
63
|
return out;
|
|
54
64
|
}
|
|
55
|
-
exports.getCatalogDependentFiles = getCatalogDependentFiles;
|
|
@@ -3,7 +3,9 @@ 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.
|
|
6
|
+
exports.getCatalogs = getCatalogs;
|
|
7
|
+
exports.getCatalogForMerge = getCatalogForMerge;
|
|
8
|
+
exports.getCatalogForFile = getCatalogForFile;
|
|
7
9
|
const glob_1 = require("glob");
|
|
8
10
|
const path_1 = __importDefault(require("path"));
|
|
9
11
|
const catalog_1 = require("../catalog");
|
|
@@ -65,7 +67,6 @@ async function getCatalogs(config) {
|
|
|
65
67
|
}
|
|
66
68
|
return catalogs;
|
|
67
69
|
}
|
|
68
|
-
exports.getCatalogs = getCatalogs;
|
|
69
70
|
/**
|
|
70
71
|
* Ensure that value is always array. If not, turn it into an array of one element.
|
|
71
72
|
*/
|
|
@@ -88,7 +89,6 @@ async function getCatalogForMerge(config) {
|
|
|
88
89
|
format,
|
|
89
90
|
}, config);
|
|
90
91
|
}
|
|
91
|
-
exports.getCatalogForMerge = getCatalogForMerge;
|
|
92
92
|
function getCatalogForFile(file, catalogs) {
|
|
93
93
|
for (const catalog of catalogs) {
|
|
94
94
|
const catalogFile = `${catalog.path}${catalog.format.getCatalogExtension()}`;
|
|
@@ -104,7 +104,6 @@ function getCatalogForFile(file, catalogs) {
|
|
|
104
104
|
}
|
|
105
105
|
return null;
|
|
106
106
|
}
|
|
107
|
-
exports.getCatalogForFile = getCatalogForFile;
|
|
108
107
|
/**
|
|
109
108
|
* Validate that `catalogPath` doesn't end with trailing slash
|
|
110
109
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFallbackListForLocale =
|
|
3
|
+
exports.getFallbackListForLocale = getFallbackListForLocale;
|
|
4
4
|
function getFallbackListForLocale(fallbackLocales, locale) {
|
|
5
5
|
const fL = [];
|
|
6
6
|
if (fallbackLocales === null || fallbackLocales === void 0 ? void 0 : fallbackLocales[locale]) {
|
|
@@ -12,4 +12,3 @@ function getFallbackListForLocale(fallbackLocales, locale) {
|
|
|
12
12
|
}
|
|
13
13
|
return fL;
|
|
14
14
|
}
|
|
15
|
-
exports.getFallbackListForLocale = getFallbackListForLocale;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTranslationsForCatalog =
|
|
3
|
+
exports.getTranslationsForCatalog = getTranslationsForCatalog;
|
|
4
4
|
const getFallbackListForLocale_1 = require("./getFallbackListForLocale");
|
|
5
5
|
async function getTranslationsForCatalog(catalog, locale, options) {
|
|
6
6
|
const [catalogs, template] = await Promise.all([
|
|
@@ -14,7 +14,6 @@ async function getTranslationsForCatalog(catalog, locale, options) {
|
|
|
14
14
|
return acc;
|
|
15
15
|
}, {});
|
|
16
16
|
}
|
|
17
|
-
exports.getTranslationsForCatalog = getTranslationsForCatalog;
|
|
18
17
|
function sourceLocaleFallback(catalog, key) {
|
|
19
18
|
if (!(catalog === null || catalog === void 0 ? void 0 : catalog[key])) {
|
|
20
19
|
return null;
|
|
@@ -44,7 +43,7 @@ function getTranslation(catalogs, msg, locale, key, options) {
|
|
|
44
43
|
// -> template message
|
|
45
44
|
// ** last resort **
|
|
46
45
|
// -> id
|
|
47
|
-
|
|
46
|
+
const translation =
|
|
48
47
|
// Get translation in target locale
|
|
49
48
|
getTranslation(locale) ||
|
|
50
49
|
// We search in fallbackLocales as dependent of each locale
|
|
@@ -53,11 +52,10 @@ function getTranslation(catalogs, msg, locale, key, options) {
|
|
|
53
52
|
sourceLocale === locale &&
|
|
54
53
|
sourceLocaleFallback(catalogs[sourceLocale], key));
|
|
55
54
|
if (!translation) {
|
|
56
|
-
onMissing
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
55
|
+
onMissing === null || onMissing === void 0 ? void 0 : onMissing({
|
|
56
|
+
id: key,
|
|
57
|
+
source: msg.message || sourceLocaleFallback(catalogs[sourceLocale], key),
|
|
58
|
+
});
|
|
61
59
|
}
|
|
62
60
|
return (translation ||
|
|
63
61
|
(sourceLocale && sourceLocaleFallback(catalogs[sourceLocale], key)) ||
|
|
@@ -1,55 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
24
12
|
};
|
|
25
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.mergeCatalog =
|
|
27
|
-
const R = __importStar(require("ramda"));
|
|
14
|
+
exports.mergeCatalog = mergeCatalog;
|
|
28
15
|
function mergeCatalog(prevCatalog, nextCatalog, forSourceLocale, options) {
|
|
29
16
|
const nextKeys = Object.keys(nextCatalog);
|
|
30
|
-
const prevKeys =
|
|
31
|
-
const newKeys =
|
|
32
|
-
const mergeKeys =
|
|
33
|
-
const obsoleteKeys =
|
|
17
|
+
const prevKeys = Object.keys(prevCatalog || {});
|
|
18
|
+
const newKeys = nextKeys.filter((key) => !prevKeys.includes(key));
|
|
19
|
+
const mergeKeys = nextKeys.filter((key) => prevKeys.includes(key));
|
|
20
|
+
const obsoleteKeys = prevKeys.filter((key) => !nextKeys.includes(key));
|
|
34
21
|
// Initialize new catalog with new keys
|
|
35
|
-
const newMessages =
|
|
22
|
+
const newMessages = Object.fromEntries(newKeys.map((key) => [
|
|
23
|
+
key,
|
|
24
|
+
Object.assign({ translation: forSourceLocale ? nextCatalog[key].message || key : "" }, nextCatalog[key]),
|
|
25
|
+
]));
|
|
36
26
|
// Merge translations from previous catalog
|
|
37
|
-
const mergedMessages = mergeKeys.map((key) => {
|
|
27
|
+
const mergedMessages = Object.fromEntries(mergeKeys.map((key) => {
|
|
38
28
|
const updateFromDefaults = forSourceLocale &&
|
|
39
29
|
(prevCatalog[key].translation === prevCatalog[key].message ||
|
|
40
30
|
options.overwrite);
|
|
41
31
|
const translation = updateFromDefaults
|
|
42
32
|
? nextCatalog[key].message || key
|
|
43
33
|
: prevCatalog[key].translation;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
34
|
+
const _a = nextCatalog[key], { obsolete } = _a, rest = __rest(_a, ["obsolete"]);
|
|
35
|
+
return [key, Object.assign(Object.assign({}, rest), { translation })];
|
|
36
|
+
}));
|
|
48
37
|
// Mark all remaining translations as obsolete
|
|
49
38
|
// Only if *options.files* is not provided
|
|
50
|
-
const obsoleteMessages = obsoleteKeys.map((key) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
const obsoleteMessages = Object.fromEntries(obsoleteKeys.map((key) => [
|
|
40
|
+
key,
|
|
41
|
+
Object.assign(Object.assign({}, prevCatalog[key]), (options.files ? {} : { obsolete: true })),
|
|
42
|
+
]));
|
|
43
|
+
return Object.assign(Object.assign(Object.assign({}, newMessages), mergedMessages), obsoleteMessages);
|
|
54
44
|
}
|
|
55
|
-
exports.mergeCatalog = mergeCatalog;
|
package/dist/api/catalog.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
1
|
import { LinguiConfigNormalized, OrderBy } from "@lingui/conf";
|
|
3
2
|
import { FormatterWrapper } from "./formats";
|
|
4
3
|
import { CliExtractOptions } from "../lingui-extract";
|
|
5
4
|
import { CliExtractTemplateOptions } from "../lingui-extract-template";
|
|
6
5
|
import { CompiledCatalogNamespace } from "./compile";
|
|
7
6
|
import { GetTranslationsOptions } from "./catalog/getTranslationsForCatalog";
|
|
8
|
-
import { AllCatalogsType, CatalogType, ExtractedCatalogType
|
|
7
|
+
import { AllCatalogsType, CatalogType, ExtractedCatalogType } from "./types";
|
|
9
8
|
export type MakeOptions = CliExtractOptions & {
|
|
10
9
|
orderBy?: OrderBy;
|
|
11
10
|
};
|
|
@@ -42,9 +41,9 @@ export declare class Catalog {
|
|
|
42
41
|
collect(options?: {
|
|
43
42
|
files?: string[];
|
|
44
43
|
}): Promise<ExtractedCatalogType | undefined>;
|
|
45
|
-
merge(prevCatalogs: AllCatalogsType, nextCatalog: ExtractedCatalogType, options: MergeOptions):
|
|
46
|
-
[
|
|
47
|
-
}
|
|
44
|
+
merge(prevCatalogs: AllCatalogsType, nextCatalog: ExtractedCatalogType, options: MergeOptions): {
|
|
45
|
+
[k: string]: CatalogType;
|
|
46
|
+
};
|
|
48
47
|
getTranslations(locale: string, options: GetTranslationsOptions): Promise<{
|
|
49
48
|
[id: string]: string;
|
|
50
49
|
}>;
|
|
@@ -58,10 +57,6 @@ export declare class Catalog {
|
|
|
58
57
|
get localeDir(): string;
|
|
59
58
|
get locales(): string[];
|
|
60
59
|
}
|
|
61
|
-
export declare
|
|
62
|
-
|
|
63
|
-
}>[] | R.Dictionary<ExtractedMessageType<{
|
|
64
|
-
[x: string]: unknown;
|
|
65
|
-
}>>>(source: K) => K extends (infer U)[] ? U[] : K extends R.Dictionary<infer U_1> ? R.Dictionary<U_1> : never;
|
|
66
|
-
export declare function order<T extends ExtractedCatalogType>(by: OrderBy): (catalog: T) => T;
|
|
60
|
+
export declare function cleanObsolete<T extends ExtractedCatalogType>(messages: T): T;
|
|
61
|
+
export declare function order<T extends ExtractedCatalogType>(by: OrderBy, catalog: T): T;
|
|
67
62
|
export declare function orderByMessage<T extends ExtractedCatalogType>(messages: T): T;
|
package/dist/api/catalog.js
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
6
|
+
exports.Catalog = void 0;
|
|
7
|
+
exports.cleanObsolete = cleanObsolete;
|
|
8
|
+
exports.order = order;
|
|
9
|
+
exports.orderByMessage = orderByMessage;
|
|
30
10
|
const fs_1 = __importDefault(require("fs"));
|
|
31
11
|
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const R = __importStar(require("ramda"));
|
|
33
12
|
const glob_1 = require("glob");
|
|
34
13
|
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
35
14
|
const getTranslationsForCatalog_1 = require("./catalog/getTranslationsForCatalog");
|
|
@@ -64,12 +43,13 @@ class Catalog {
|
|
|
64
43
|
files: options.files,
|
|
65
44
|
});
|
|
66
45
|
// Map over all locales and post-process each catalog
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
46
|
+
const sortedCatalogs = Object.fromEntries(Object.entries(catalogs).map(([locale, catalog]) => {
|
|
47
|
+
if (options.clean) {
|
|
48
|
+
catalog = cleanObsolete(catalog);
|
|
49
|
+
}
|
|
50
|
+
catalog = order(options.orderBy, catalog);
|
|
51
|
+
return [locale, catalog];
|
|
52
|
+
}));
|
|
73
53
|
const locales = options.locale ? options.locale : this.locales;
|
|
74
54
|
await Promise.all(locales.map((locale) => this.write(locale, sortedCatalogs[locale])));
|
|
75
55
|
return sortedCatalogs;
|
|
@@ -78,7 +58,7 @@ class Catalog {
|
|
|
78
58
|
const catalog = await this.collect({ files: options.files });
|
|
79
59
|
if (!catalog)
|
|
80
60
|
return false;
|
|
81
|
-
const sorted = order(options.orderBy
|
|
61
|
+
const sorted = order(options.orderBy, catalog);
|
|
82
62
|
await this.writeTemplate(sorted);
|
|
83
63
|
return sorted;
|
|
84
64
|
}
|
|
@@ -115,9 +95,10 @@ class Catalog {
|
|
|
115
95
|
* - all other languages: translation is kept empty
|
|
116
96
|
*/
|
|
117
97
|
merge(prevCatalogs, nextCatalog, options) {
|
|
118
|
-
return
|
|
119
|
-
|
|
120
|
-
|
|
98
|
+
return Object.fromEntries(Object.entries(prevCatalogs).map(([locale, prevCatalog]) => [
|
|
99
|
+
locale,
|
|
100
|
+
(0, mergeCatalog_1.mergeCatalog)(prevCatalog, nextCatalog, this.config.sourceLocale === locale, options),
|
|
101
|
+
]));
|
|
121
102
|
}
|
|
122
103
|
async getTranslations(locale, options) {
|
|
123
104
|
return await (0, getTranslationsForCatalog_1.getTranslationsForCatalog)(this, locale, options);
|
|
@@ -194,15 +175,16 @@ exports.Catalog = Catalog;
|
|
|
194
175
|
function getTemplatePath(ext, path) {
|
|
195
176
|
return path.replace(LOCALE_SUFFIX_RE, "messages" + ext);
|
|
196
177
|
}
|
|
197
|
-
|
|
198
|
-
|
|
178
|
+
function cleanObsolete(messages) {
|
|
179
|
+
return Object.fromEntries(Object.entries(messages).filter(([, message]) => !message.obsolete));
|
|
180
|
+
}
|
|
181
|
+
function order(by, catalog) {
|
|
199
182
|
return {
|
|
200
183
|
messageId: orderByMessageId,
|
|
201
184
|
message: orderByMessage,
|
|
202
185
|
origin: orderByOrigin,
|
|
203
|
-
}[by];
|
|
186
|
+
}[by](catalog);
|
|
204
187
|
}
|
|
205
|
-
exports.order = order;
|
|
206
188
|
/**
|
|
207
189
|
* Object keys are in the same order as they were created
|
|
208
190
|
* https://stackoverflow.com/a/31102605/1535540
|
|
@@ -263,4 +245,3 @@ function orderByMessage(messages) {
|
|
|
263
245
|
return acc;
|
|
264
246
|
}, {});
|
|
265
247
|
}
|
|
266
|
-
exports.orderByMessage = orderByMessage;
|
package/dist/api/compile.js
CHANGED
|
@@ -15,18 +15,29 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
39
|
+
exports.createCompiledCatalog = createCompiledCatalog;
|
|
40
|
+
exports.compile = compile;
|
|
30
41
|
const t = __importStar(require("@babel/types"));
|
|
31
42
|
const generator_1 = __importDefault(require("@babel/generator"));
|
|
32
43
|
const compileMessage_1 = require("@lingui/message-utils/compileMessage");
|
|
@@ -51,7 +62,6 @@ function createCompiledCatalog(locale, messages, options) {
|
|
|
51
62
|
} }, compilerBabelOptions)).code;
|
|
52
63
|
return "/*eslint-disable*/" + code;
|
|
53
64
|
}
|
|
54
|
-
exports.createCompiledCatalog = createCompiledCatalog;
|
|
55
65
|
function buildExportStatement(expression, namespace) {
|
|
56
66
|
if (namespace === "ts") {
|
|
57
67
|
// import type { Messages } from "@lingui/core";
|
|
@@ -97,4 +107,3 @@ function buildExportStatement(expression, namespace) {
|
|
|
97
107
|
function compile(message, shouldPseudolocalize = false) {
|
|
98
108
|
return (0, compileMessage_1.compileMessage)(message, (value) => shouldPseudolocalize ? (0, pseudoLocalize_1.default)(value) : value);
|
|
99
109
|
}
|
|
100
|
-
exports.compile = compile;
|
|
@@ -3,7 +3,9 @@ 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.
|
|
6
|
+
exports.babelRe = void 0;
|
|
7
|
+
exports.extractFromFileWithBabel = extractFromFileWithBabel;
|
|
8
|
+
exports.getBabelParserOptions = getBabelParserOptions;
|
|
7
9
|
const core_1 = require("@babel/core");
|
|
8
10
|
const babel_plugin_extract_messages_1 = __importDefault(require("@lingui/babel-plugin-extract-messages"));
|
|
9
11
|
const babel_plugin_lingui_macro_1 = __importDefault(require("@lingui/babel-plugin-lingui-macro"));
|
|
@@ -12,7 +14,7 @@ exports.babelRe = new RegExp("\\.(" +
|
|
|
12
14
|
.map((ext) => ext.slice(1))
|
|
13
15
|
.join("|") +
|
|
14
16
|
")$", "i");
|
|
15
|
-
const inlineSourceMapsRE = new RegExp(/\/[
|
|
17
|
+
const inlineSourceMapsRE = new RegExp(/\/[/*][#@]\s+sourceMappingURL=data:application\/json;(?:charset:utf-8;)?base64,/i);
|
|
16
18
|
/**
|
|
17
19
|
* Create a source mapper which could read original positions
|
|
18
20
|
* from either inline sourcemaps or from external passed as `sourceMaps` argument.
|
|
@@ -112,12 +114,11 @@ async function extractFromFileWithBabel(filename, code, onMessageExtracted, ctx,
|
|
|
112
114
|
});
|
|
113
115
|
mapper.destroy();
|
|
114
116
|
}
|
|
115
|
-
exports.extractFromFileWithBabel = extractFromFileWithBabel;
|
|
116
117
|
function getBabelParserOptions(filename, parserOptions) {
|
|
117
118
|
// https://babeljs.io/docs/en/babel-parser#latest-ecmascript-features
|
|
118
119
|
const parserPlugins = [
|
|
119
|
-
"importAttributes",
|
|
120
|
-
"explicitResourceManagement",
|
|
120
|
+
"importAttributes", // stage3
|
|
121
|
+
"explicitResourceManagement", // stage3,
|
|
121
122
|
"decoratorAutoAccessors", // stage3,
|
|
122
123
|
];
|
|
123
124
|
if ([/\.ts$/, /\.mts$/, /\.cts$/, /\.tsx$/].some((r) => filename.match(r))) {
|
|
@@ -140,7 +141,6 @@ function getBabelParserOptions(filename, parserOptions) {
|
|
|
140
141
|
}
|
|
141
142
|
return parserPlugins;
|
|
142
143
|
}
|
|
143
|
-
exports.getBabelParserOptions = getBabelParserOptions;
|
|
144
144
|
const extractor = {
|
|
145
145
|
match(filename) {
|
|
146
146
|
return exports.babelRe.test(filename);
|
|
@@ -3,13 +3,14 @@ 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.default = extract;
|
|
6
7
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
7
8
|
const babel_1 = __importDefault(require("./babel"));
|
|
8
9
|
const DEFAULT_EXTRACTORS = [babel_1.default];
|
|
9
10
|
async function extract(filename, onMessageExtracted, linguiConfig, options) {
|
|
10
11
|
var _a;
|
|
11
12
|
const extractorsToExtract = (_a = options.extractors) !== null && _a !== void 0 ? _a : DEFAULT_EXTRACTORS;
|
|
12
|
-
for (
|
|
13
|
+
for (const ext of extractorsToExtract) {
|
|
13
14
|
if (!ext.match(filename))
|
|
14
15
|
continue;
|
|
15
16
|
try {
|
|
@@ -27,4 +28,3 @@ async function extract(filename, onMessageExtracted, linguiConfig, options) {
|
|
|
27
28
|
}
|
|
28
29
|
return true;
|
|
29
30
|
}
|
|
30
|
-
exports.default = extract;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FormatterWrapper = void 0;
|
|
4
|
+
exports.getFormat = getFormat;
|
|
4
5
|
const formatterWrapper_1 = require("./formatterWrapper");
|
|
5
6
|
Object.defineProperty(exports, "FormatterWrapper", { enumerable: true, get: function () { return formatterWrapper_1.FormatterWrapper; } });
|
|
6
7
|
const utils_1 = require("../utils");
|
|
@@ -44,4 +45,3 @@ async function getFormat(_format, options, sourceLocale) {
|
|
|
44
45
|
}
|
|
45
46
|
return new formatterWrapper_1.FormatterWrapper((await format())(options), sourceLocale);
|
|
46
47
|
}
|
|
47
|
-
exports.getFormat = getFormat;
|
package/dist/api/help.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.helpRun =
|
|
3
|
+
exports.helpRun = helpRun;
|
|
4
4
|
/**
|
|
5
5
|
* Detect where is the command lingui extract or lingui compile
|
|
6
6
|
* and how is being run (npm, yarn, pnpm) and construct help
|
|
@@ -29,7 +29,9 @@ function helpRun(command) {
|
|
|
29
29
|
try {
|
|
30
30
|
findRootPkgJson = require((0, path_1.resolve)((0, path_1.join)(process.cwd(), "package.json")));
|
|
31
31
|
}
|
|
32
|
-
catch (error) {
|
|
32
|
+
catch (error) {
|
|
33
|
+
// noting
|
|
34
|
+
}
|
|
33
35
|
if (findRootPkgJson === null || findRootPkgJson === void 0 ? void 0 : findRootPkgJson.scripts) {
|
|
34
36
|
const res = Object.entries(findRootPkgJson.scripts).find(([_, value]) => value.includes(`lingui ${command}`));
|
|
35
37
|
if (res) {
|
|
@@ -39,7 +41,6 @@ function helpRun(command) {
|
|
|
39
41
|
const runCommand = runCommandFrom(process.env.npm_config_user_agent);
|
|
40
42
|
return `${runCommand} ${command}`;
|
|
41
43
|
}
|
|
42
|
-
exports.helpRun = helpRun;
|
|
43
44
|
function runCommandFrom(userAgent) {
|
|
44
45
|
const defaultRunCommand = "npm run";
|
|
45
46
|
if (!userAgent) {
|
|
@@ -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
|
-
|
|
6
|
+
exports.default = default_1;
|
|
7
7
|
const pseudolocale_1 = __importDefault(require("pseudolocale"));
|
|
8
8
|
const delimiter = "%&&&%";
|
|
9
9
|
/**
|
|
@@ -40,12 +40,13 @@ function addDelimitersVariables(message) {
|
|
|
40
40
|
return `${delimiter}${matchedString}${delimiter}`;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
const addDelimiters = ramda_1.default.compose(addDelimitersVariables, addDelimitersMacro, addDelimitersHTMLTags);
|
|
44
43
|
function removeDelimiters(message) {
|
|
45
44
|
return message.replace(new RegExp(delimiter, "g"), "");
|
|
46
45
|
}
|
|
47
46
|
function default_1(message) {
|
|
48
|
-
message =
|
|
47
|
+
message = addDelimitersHTMLTags(message);
|
|
48
|
+
message = addDelimitersMacro(message);
|
|
49
|
+
message = addDelimitersVariables(message);
|
|
49
50
|
message = (0, pseudolocale_1.default)(message, {
|
|
50
51
|
delimiter,
|
|
51
52
|
prepend: "",
|
|
@@ -53,4 +54,3 @@ function default_1(message) {
|
|
|
53
54
|
});
|
|
54
55
|
return removeDelimiters(message);
|
|
55
56
|
}
|
|
56
|
-
exports.default = default_1;
|
package/dist/api/stats.js
CHANGED
|
@@ -3,7 +3,9 @@ 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.
|
|
6
|
+
exports.getStats = getStats;
|
|
7
|
+
exports.printStats = printStats;
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
9
|
// @ts-ignore
|
|
8
10
|
const cli_table_1 = __importDefault(require("cli-table"));
|
|
9
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -13,7 +15,6 @@ function getStats(catalog) {
|
|
|
13
15
|
Object.keys(catalog).filter((key) => !catalog[key].translation).length,
|
|
14
16
|
];
|
|
15
17
|
}
|
|
16
|
-
exports.getStats = getStats;
|
|
17
18
|
function printStats(config, catalogs) {
|
|
18
19
|
const table = new cli_table_1.default({
|
|
19
20
|
head: ["Language", "Total count", "Missing"],
|
|
@@ -40,4 +41,3 @@ function printStats(config, catalogs) {
|
|
|
40
41
|
});
|
|
41
42
|
return table;
|
|
42
43
|
}
|
|
43
|
-
exports.printStats = printStats;
|
package/dist/api/utils.js
CHANGED
|
@@ -3,7 +3,17 @@ 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.
|
|
6
|
+
exports.PATHSEP = void 0;
|
|
7
|
+
exports.prettyOrigin = prettyOrigin;
|
|
8
|
+
exports.replacePlaceholders = replacePlaceholders;
|
|
9
|
+
exports.readFile = readFile;
|
|
10
|
+
exports.isDirectory = isDirectory;
|
|
11
|
+
exports.writeFile = writeFile;
|
|
12
|
+
exports.writeFileIfChanged = writeFileIfChanged;
|
|
13
|
+
exports.hasYarn = hasYarn;
|
|
14
|
+
exports.makeInstall = makeInstall;
|
|
15
|
+
exports.normalizeRelativePath = normalizeRelativePath;
|
|
16
|
+
exports.makePathRegexSafe = makePathRegexSafe;
|
|
7
17
|
const fs_1 = __importDefault(require("fs"));
|
|
8
18
|
const path_1 = __importDefault(require("path"));
|
|
9
19
|
const normalize_path_1 = __importDefault(require("normalize-path"));
|
|
@@ -16,14 +26,12 @@ function prettyOrigin(origins) {
|
|
|
16
26
|
return "";
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
|
-
exports.prettyOrigin = prettyOrigin;
|
|
20
29
|
function replacePlaceholders(input, values) {
|
|
21
30
|
return input.replace(/\{([^}]+)}/g, (m, placeholder) => {
|
|
22
31
|
var _a;
|
|
23
32
|
return (_a = values[placeholder]) !== null && _a !== void 0 ? _a : m;
|
|
24
33
|
});
|
|
25
34
|
}
|
|
26
|
-
exports.replacePlaceholders = replacePlaceholders;
|
|
27
35
|
async function readFile(fileName) {
|
|
28
36
|
try {
|
|
29
37
|
return (await fs_1.default.promises.readFile(fileName, "utf-8")).toString();
|
|
@@ -34,7 +42,6 @@ async function readFile(fileName) {
|
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
|
-
exports.readFile = readFile;
|
|
38
45
|
async function mkdirp(dir) {
|
|
39
46
|
try {
|
|
40
47
|
await fs_1.default.promises.mkdir(dir, {
|
|
@@ -57,12 +64,10 @@ function isDirectory(filePath) {
|
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
|
-
exports.isDirectory = isDirectory;
|
|
61
67
|
async function writeFile(fileName, content) {
|
|
62
68
|
await mkdirp(path_1.default.dirname(fileName));
|
|
63
69
|
await fs_1.default.promises.writeFile(fileName, content, "utf-8");
|
|
64
70
|
}
|
|
65
|
-
exports.writeFile = writeFile;
|
|
66
71
|
async function writeFileIfChanged(filename, newContent) {
|
|
67
72
|
const raw = await readFile(filename);
|
|
68
73
|
if (raw) {
|
|
@@ -74,18 +79,15 @@ async function writeFileIfChanged(filename, newContent) {
|
|
|
74
79
|
await writeFile(filename, newContent);
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
|
-
exports.writeFileIfChanged = writeFileIfChanged;
|
|
78
82
|
function hasYarn() {
|
|
79
83
|
return fs_1.default.existsSync(path_1.default.resolve("yarn.lock"));
|
|
80
84
|
}
|
|
81
|
-
exports.hasYarn = hasYarn;
|
|
82
85
|
function makeInstall(packageName, dev = false) {
|
|
83
86
|
const withYarn = hasYarn();
|
|
84
87
|
return withYarn
|
|
85
88
|
? `yarn add ${dev ? "--dev " : ""}${packageName}`
|
|
86
89
|
: `npm install ${dev ? "--save-dev" : "--save"} ${packageName}`;
|
|
87
90
|
}
|
|
88
|
-
exports.makeInstall = makeInstall;
|
|
89
91
|
/**
|
|
90
92
|
* Remove ./ at the beginning: ./relative => relative
|
|
91
93
|
* relative => relative
|
|
@@ -102,11 +104,9 @@ function normalizeRelativePath(sourcePath) {
|
|
|
102
104
|
return ((0, normalize_path_1.default)(path_1.default.relative(process.cwd(), sourcePath), false) +
|
|
103
105
|
(isDir ? "/" : ""));
|
|
104
106
|
}
|
|
105
|
-
exports.normalizeRelativePath = normalizeRelativePath;
|
|
106
107
|
/**
|
|
107
108
|
* Escape special regex characters used in file-based routing systems
|
|
108
109
|
*/
|
|
109
110
|
function makePathRegexSafe(path) {
|
|
110
111
|
return path.replace(/[(){}[\]^$+]/g, "\\$&");
|
|
111
112
|
}
|
|
112
|
-
exports.makePathRegexSafe = makePathRegexSafe;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bundleSource =
|
|
3
|
+
exports.bundleSource = bundleSource;
|
|
4
4
|
const linguiEsbuildPlugin_1 = require("./linguiEsbuildPlugin");
|
|
5
5
|
function createExtRegExp(extensions) {
|
|
6
6
|
return new RegExp("\\.(?:" + extensions.join("|") + ")(?:\\?.*)?$");
|
|
@@ -59,4 +59,3 @@ async function bundleSource(linguiConfig, entryPoints, outDir, rootDir) {
|
|
|
59
59
|
? config.resolveEsbuildOptions(esbuildOptions)
|
|
60
60
|
: esbuildOptions);
|
|
61
61
|
}
|
|
62
|
-
exports.bundleSource = bundleSource;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEntryPoints =
|
|
3
|
+
exports.getEntryPoints = getEntryPoints;
|
|
4
4
|
const glob_1 = require("glob");
|
|
5
5
|
function getEntryPoints(entries) {
|
|
6
6
|
return (0, glob_1.globSync)(entries, { mark: true });
|
|
7
7
|
}
|
|
8
|
-
exports.getEntryPoints = getEntryPoints;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExperimentalCatalogs =
|
|
3
|
+
exports.getExperimentalCatalogs = getExperimentalCatalogs;
|
|
4
4
|
const getEntryPoints_1 = require("./getEntryPoints");
|
|
5
5
|
const resolveCatalogPath_1 = require("./resolveCatalogPath");
|
|
6
6
|
const catalog_1 = require("../api/catalog");
|
|
@@ -23,4 +23,3 @@ async function getExperimentalCatalogs(linguiConfig) {
|
|
|
23
23
|
}, linguiConfig);
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
exports.getExperimentalCatalogs = getExperimentalCatalogs;
|
|
@@ -3,7 +3,8 @@ 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.
|
|
6
|
+
exports.resolveCatalogPath = resolveCatalogPath;
|
|
7
|
+
exports.getEntryName = getEntryName;
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
const utils_1 = require("../api/utils");
|
|
9
10
|
function resolveCatalogPath(configOutput, entryPath, rootDir, locale, extension) {
|
|
@@ -15,9 +16,7 @@ function resolveCatalogPath(configOutput, entryPath, rootDir, locale, extension)
|
|
|
15
16
|
locale,
|
|
16
17
|
}) + extension);
|
|
17
18
|
}
|
|
18
|
-
exports.resolveCatalogPath = resolveCatalogPath;
|
|
19
19
|
function getEntryName(entryPath) {
|
|
20
20
|
const parsedPath = path_1.default.parse(entryPath);
|
|
21
21
|
return parsedPath.name.replace(parsedPath.ext, "");
|
|
22
22
|
}
|
|
23
|
-
exports.getEntryName = getEntryName;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveTemplatePath =
|
|
3
|
+
exports.resolveTemplatePath = resolveTemplatePath;
|
|
4
4
|
const resolveCatalogPath_1 = require("./resolveCatalogPath");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
function resolveTemplatePath(entryPoint, output, rootDir, catalogExtension) {
|
|
@@ -13,4 +13,3 @@ function resolveTemplatePath(entryPoint, output, rootDir, catalogExtension) {
|
|
|
13
13
|
}
|
|
14
14
|
return (0, resolveCatalogPath_1.resolveCatalogPath)(output, entryPoint, rootDir, templateName, catalogExtension);
|
|
15
15
|
}
|
|
16
|
-
exports.resolveTemplatePath = resolveTemplatePath;
|
|
@@ -3,7 +3,8 @@ 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.
|
|
6
|
+
exports.writeCatalogs = writeCatalogs;
|
|
7
|
+
exports.writeTemplate = writeTemplate;
|
|
7
8
|
const resolveTemplatePath_1 = require("./resolveTemplatePath");
|
|
8
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
9
10
|
const resolveCatalogPath_1 = require("./resolveCatalogPath");
|
|
@@ -14,7 +15,7 @@ function cleanAndSort(catalog, clean, orderBy) {
|
|
|
14
15
|
if (clean) {
|
|
15
16
|
catalog = (0, catalog_1.cleanObsolete)(catalog);
|
|
16
17
|
}
|
|
17
|
-
return (0, catalog_1.order)(orderBy
|
|
18
|
+
return (0, catalog_1.order)(orderBy, catalog);
|
|
18
19
|
}
|
|
19
20
|
async function writeCatalogs(params) {
|
|
20
21
|
const { entryPoint, outputPattern, linguiConfig, locales, overwrite, format, clean, messages, } = params;
|
|
@@ -29,7 +30,6 @@ async function writeCatalogs(params) {
|
|
|
29
30
|
statMessage: (0, stats_1.printStats)(linguiConfig, stat).toString(),
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
exports.writeCatalogs = writeCatalogs;
|
|
33
33
|
async function writeTemplate(params) {
|
|
34
34
|
const { entryPoint, outputPattern, linguiConfig, format, clean, messages } = params;
|
|
35
35
|
const catalogOutput = (0, resolveTemplatePath_1.resolveTemplatePath)(entryPoint, outputPattern, linguiConfig.rootDir, format.getTemplateExtension());
|
|
@@ -38,4 +38,3 @@ async function writeTemplate(params) {
|
|
|
38
38
|
statMessage: `${chalk_1.default.bold(Object.keys(messages).length)} message(s) extracted`,
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
exports.writeTemplate = writeTemplate;
|
package/dist/lingui-compile.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.command =
|
|
6
|
+
exports.command = command;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
9
9
|
const commander_1 = require("commander");
|
|
@@ -30,7 +30,9 @@ async function command(config, options) {
|
|
|
30
30
|
missingMessages.push(missing);
|
|
31
31
|
},
|
|
32
32
|
});
|
|
33
|
-
if (!options.allowEmpty &&
|
|
33
|
+
if (!options.allowEmpty &&
|
|
34
|
+
locale !== config.pseudoLocale &&
|
|
35
|
+
missingMessages.length > 0) {
|
|
34
36
|
console.error(chalk_1.default.red(`Error: Failed to compile catalog for locale ${chalk_1.default.bold(locale)}!`));
|
|
35
37
|
if (options.verbose) {
|
|
36
38
|
console.error(chalk_1.default.red("Missing translations:"));
|
|
@@ -82,7 +84,6 @@ async function command(config, options) {
|
|
|
82
84
|
}
|
|
83
85
|
return true;
|
|
84
86
|
}
|
|
85
|
-
exports.command = command;
|
|
86
87
|
if (require.main === module) {
|
|
87
88
|
commander_1.program
|
|
88
89
|
.description("Add compile message catalogs and add language data (plurals) to compiled bundle.")
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.default = command;
|
|
7
8
|
const commander_1 = require("commander");
|
|
8
9
|
const conf_1 = require("@lingui/conf");
|
|
9
10
|
const path_1 = __importDefault(require("path"));
|
|
@@ -98,7 +99,6 @@ async function command(linguiConfig, options) {
|
|
|
98
99
|
});
|
|
99
100
|
return commandSuccess;
|
|
100
101
|
}
|
|
101
|
-
exports.default = command;
|
|
102
102
|
if (require.main === module) {
|
|
103
103
|
commander_1.program
|
|
104
104
|
.option("--config <path>", "Path to the config file")
|
|
@@ -3,6 +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.default = command;
|
|
6
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
const commander_1 = require("commander");
|
|
8
9
|
const conf_1 = require("@lingui/conf");
|
|
@@ -27,7 +28,6 @@ async function command(config, options) {
|
|
|
27
28
|
});
|
|
28
29
|
return commandSuccess;
|
|
29
30
|
}
|
|
30
|
-
exports.default = command;
|
|
31
31
|
if (require.main === module) {
|
|
32
32
|
commander_1.program
|
|
33
33
|
.option("--config <path>", "Path to the config file")
|
package/dist/lingui-extract.js
CHANGED
|
@@ -3,6 +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.default = command;
|
|
6
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
7
8
|
const chokidar_1 = __importDefault(require("chokidar"));
|
|
8
9
|
const commander_1 = require("commander");
|
|
@@ -19,7 +20,7 @@ async function command(config, options) {
|
|
|
19
20
|
const catalogStats = {};
|
|
20
21
|
let commandSuccess = true;
|
|
21
22
|
const spinner = (0, ora_1.default)().start();
|
|
22
|
-
for (
|
|
23
|
+
for (const catalog of catalogs) {
|
|
23
24
|
const result = await catalog.make(Object.assign(Object.assign({}, options), { orderBy: config.orderBy }));
|
|
24
25
|
catalogStats[(0, normalize_path_1.default)(path_1.default.relative(config.rootDir, catalog.path))] = result || {};
|
|
25
26
|
commandSuccess && (commandSuccess = Boolean(result));
|
|
@@ -57,7 +58,6 @@ async function command(config, options) {
|
|
|
57
58
|
}
|
|
58
59
|
return commandSuccess;
|
|
59
60
|
}
|
|
60
|
-
exports.default = command;
|
|
61
61
|
if (require.main === module) {
|
|
62
62
|
commander_1.program
|
|
63
63
|
.option("--config <path>", "Path to the config file")
|
|
@@ -135,8 +135,8 @@ if (require.main === module) {
|
|
|
135
135
|
console.info(chalk_1.default.bold("Initializing Watch Mode..."));
|
|
136
136
|
(async function initWatch() {
|
|
137
137
|
const catalogs = await (0, api_1.getCatalogs)(config);
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
const paths = [];
|
|
139
|
+
const ignored = [];
|
|
140
140
|
catalogs.forEach((catalog) => {
|
|
141
141
|
paths.push(...catalog.include);
|
|
142
142
|
ignored.push(...catalog.exclude);
|
|
@@ -3,6 +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.default = syncProcess;
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
8
|
const path_1 = require("path");
|
|
8
9
|
const pofile_1 = __importDefault(require("pofile"));
|
|
@@ -48,7 +49,6 @@ async function syncProcess(config, options) {
|
|
|
48
49
|
});
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
|
-
exports.default = syncProcess;
|
|
52
52
|
// Initialize project with source and existing translations (only first time!)
|
|
53
53
|
// Cf. https://translation.io/docs/create-library#initialization
|
|
54
54
|
function init(config, options, successCallback, failCallback) {
|
|
@@ -146,7 +146,7 @@ function createSegmentFromPoItem(item) {
|
|
|
146
146
|
const itemHasExplicitId = item.extractedComments.includes(EXPLICIT_ID_FLAG);
|
|
147
147
|
const itemHasContext = item.msgctxt != null;
|
|
148
148
|
const segment = {
|
|
149
|
-
type: "source",
|
|
149
|
+
type: "source", // No way to edit text for source language (inside code), so not using "key" here
|
|
150
150
|
source: "",
|
|
151
151
|
context: "",
|
|
152
152
|
references: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "CLI for working wit message catalogs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"@babel/parser": "^7.22.0",
|
|
58
58
|
"@babel/runtime": "^7.21.0",
|
|
59
59
|
"@babel/types": "^7.21.2",
|
|
60
|
-
"@lingui/babel-plugin-extract-messages": "5.
|
|
61
|
-
"@lingui/babel-plugin-lingui-macro": "5.
|
|
62
|
-
"@lingui/conf": "5.
|
|
63
|
-
"@lingui/core": "5.
|
|
64
|
-
"@lingui/format-po": "5.
|
|
65
|
-
"@lingui/message-utils": "5.
|
|
60
|
+
"@lingui/babel-plugin-extract-messages": "5.2.0",
|
|
61
|
+
"@lingui/babel-plugin-lingui-macro": "5.2.0",
|
|
62
|
+
"@lingui/conf": "5.2.0",
|
|
63
|
+
"@lingui/core": "5.2.0",
|
|
64
|
+
"@lingui/format-po": "5.2.0",
|
|
65
|
+
"@lingui/message-utils": "5.2.0",
|
|
66
66
|
"babel-plugin-macros": "^3.0.1",
|
|
67
67
|
"chalk": "^4.1.0",
|
|
68
68
|
"chokidar": "3.5.1",
|
|
@@ -80,7 +80,6 @@
|
|
|
80
80
|
"pkg-up": "^3.1.0",
|
|
81
81
|
"pofile": "^1.1.4",
|
|
82
82
|
"pseudolocale": "^2.0.0",
|
|
83
|
-
"ramda": "^0.27.1",
|
|
84
83
|
"source-map": "^0.8.0-beta.0"
|
|
85
84
|
},
|
|
86
85
|
"devDependencies": {
|
|
@@ -91,5 +90,5 @@
|
|
|
91
90
|
"mock-fs": "^5.2.0",
|
|
92
91
|
"mockdate": "^3.0.5"
|
|
93
92
|
},
|
|
94
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "9c50b4877ca8b134d0d96c09a8055221ca70b095"
|
|
95
94
|
}
|