@lingui/cli 3.15.0 → 3.16.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/CHANGELOG.md +482 -0
- package/build/LICENSE +21 -0
- package/build/api/catalog.js +582 -0
- package/build/api/compile.js +89 -0
- package/{api → build/api}/detect.js +23 -9
- package/build/api/extract.js +78 -0
- package/build/api/extractors/babel.js +51 -0
- package/build/api/extractors/index.js +51 -0
- package/build/api/extractors/typescript.js +71 -0
- package/build/api/formats/csv.js +65 -0
- package/{api → build/api}/formats/index.js +8 -5
- package/build/api/formats/lingui.js +67 -0
- package/build/api/formats/minimal.js +63 -0
- package/build/api/formats/po-gettext.js +296 -0
- package/build/api/formats/po.js +122 -0
- package/{api → build/api}/help.js +6 -18
- package/{api → build/api}/index.js +7 -7
- package/build/api/locales.js +45 -0
- package/{api → build/api}/pseudoLocalize.js +13 -13
- package/build/api/stats.js +46 -0
- package/{api → build/api}/utils.js +21 -40
- package/build/lingui-add-locale.js +11 -0
- package/build/lingui-compile.js +192 -0
- package/build/lingui-extract-template.js +64 -0
- package/build/lingui-extract.js +181 -0
- package/{lingui.js → build/lingui.js} +2 -2
- package/{services → build/services}/translationIO.js +78 -94
- package/build/tests.js +78 -0
- package/package.json +18 -12
- package/api/catalog.js +0 -778
- package/api/compile.js +0 -172
- package/api/extract.js +0 -192
- package/api/extractors/babel.js +0 -61
- package/api/extractors/index.js +0 -130
- package/api/extractors/typescript.js +0 -77
- package/api/formats/csv.js +0 -71
- package/api/formats/lingui.js +0 -64
- package/api/formats/minimal.js +0 -63
- package/api/formats/po-gettext.js +0 -331
- package/api/formats/po.js +0 -130
- package/api/locales.js +0 -43
- package/api/stats.js +0 -51
- package/lingui-add-locale.js +0 -11
- package/lingui-compile.js +0 -198
- package/lingui-extract-template.js +0 -123
- package/lingui-extract.js +0 -286
package/api/locales.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.isValid = isValid;
|
|
11
|
-
exports.parse = parse;
|
|
12
|
-
|
|
13
|
-
var plurals = _interopRequireWildcard(require("make-plural/plurals"));
|
|
14
|
-
|
|
15
|
-
var _bcp = _interopRequireDefault(require("bcp-47"));
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Check that locale is valid according to BCP47 and we have plurals for it
|
|
19
|
-
* @param locale: string - Locale in BCP47 format
|
|
20
|
-
* @return {boolean}
|
|
21
|
-
*/
|
|
22
|
-
function isValid(locale) {
|
|
23
|
-
var localeData = parse(locale);
|
|
24
|
-
return localeData !== null && localeData !== undefined && localeData.language in plurals;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Parse locale in BCP47 format and
|
|
28
|
-
* @param locale - Locale in BCP47 format
|
|
29
|
-
* @return {LocaleInfo}
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
function parse(locale) {
|
|
34
|
-
if (typeof locale !== "string") return null;
|
|
35
|
-
|
|
36
|
-
var schema = _bcp.default.parse(locale.replace("_", "-"));
|
|
37
|
-
|
|
38
|
-
if (!schema.language) return null;
|
|
39
|
-
return {
|
|
40
|
-
locale: _bcp.default.stringify(schema),
|
|
41
|
-
language: schema.language
|
|
42
|
-
};
|
|
43
|
-
}
|
package/api/stats.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getStats = getStats;
|
|
9
|
-
exports.printStats = printStats;
|
|
10
|
-
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
|
|
13
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
14
|
-
|
|
15
|
-
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
16
|
-
|
|
17
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
|
-
|
|
19
|
-
function getStats(catalog) {
|
|
20
|
-
return [Object.keys(catalog).length, Object.keys(catalog).filter(function (key) {
|
|
21
|
-
return !catalog[key].translation;
|
|
22
|
-
}).length];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function printStats(config, catalogs) {
|
|
26
|
-
var table = new _cliTable.default({
|
|
27
|
-
head: ["Language", "Total count", "Missing"],
|
|
28
|
-
colAligns: ["left", "middle", "middle"],
|
|
29
|
-
style: {
|
|
30
|
-
head: ["green"],
|
|
31
|
-
border: [],
|
|
32
|
-
compact: true
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.keys(catalogs).forEach(function (locale) {
|
|
36
|
-
var catalog = catalogs[locale]; // catalog is null if no catalog exists on disk and the locale
|
|
37
|
-
// was not extracted due to a `--locale` filter
|
|
38
|
-
|
|
39
|
-
var _ref = catalog ? getStats(catalog) : ["-", "-"],
|
|
40
|
-
_ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
41
|
-
all = _ref2[0],
|
|
42
|
-
translated = _ref2[1];
|
|
43
|
-
|
|
44
|
-
if (config.sourceLocale === locale) {
|
|
45
|
-
table.push((0, _defineProperty2.default)({}, "".concat(_chalk.default.bold(locale), " (source)"), [all, "-"]));
|
|
46
|
-
} else {
|
|
47
|
-
table.push((0, _defineProperty2.default)({}, locale, [all, translated]));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return table;
|
|
51
|
-
}
|
package/lingui-add-locale.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
-
|
|
7
|
-
if (require.main === module) {
|
|
8
|
-
var msg = "lingui add-locale command is deprecated. " + "Please set ".concat(_chalk.default.yellow("'locales'"), " in configuration. ") + _chalk.default.underline("https://lingui.js.org/ref/conf.html#locales");
|
|
9
|
-
|
|
10
|
-
console.error(msg);
|
|
11
|
-
}
|
package/lingui-compile.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
|
-
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
|
|
11
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
12
|
-
|
|
13
|
-
var _chokidar = _interopRequireDefault(require("chokidar"));
|
|
14
|
-
|
|
15
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
16
|
-
|
|
17
|
-
var R = _interopRequireWildcard(require("ramda"));
|
|
18
|
-
|
|
19
|
-
var _commander = _interopRequireDefault(require("commander"));
|
|
20
|
-
|
|
21
|
-
var plurals = _interopRequireWildcard(require("make-plural"));
|
|
22
|
-
|
|
23
|
-
var _conf = require("@lingui/conf");
|
|
24
|
-
|
|
25
|
-
var _catalog = require("./api/catalog");
|
|
26
|
-
|
|
27
|
-
var _compile = require("./api/compile");
|
|
28
|
-
|
|
29
|
-
var _help = require("./api/help");
|
|
30
|
-
|
|
31
|
-
var _api = require("./api");
|
|
32
|
-
|
|
33
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
34
|
-
|
|
35
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
36
|
-
|
|
37
|
-
var noMessages = R.pipe(R.map(R.isEmpty), R.values, R.all(R.equals(true)));
|
|
38
|
-
|
|
39
|
-
function command(config, options) {
|
|
40
|
-
var catalogs = (0, _catalog.getCatalogs)(config);
|
|
41
|
-
|
|
42
|
-
if (noMessages(catalogs)) {
|
|
43
|
-
console.error("Nothing to compile, message catalogs are empty!\n");
|
|
44
|
-
console.error("(use \"".concat(_chalk.default.yellow((0, _help.helpRun)("extract")), "\" to extract messages from source files)"));
|
|
45
|
-
return false;
|
|
46
|
-
} // Check config.compile.merge if catalogs for current locale are to be merged into a single compiled file
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var doMerge = !!config.catalogsMergePath;
|
|
50
|
-
var mergedCatalogs = {};
|
|
51
|
-
console.error("Compiling message catalogs…");
|
|
52
|
-
config.locales.forEach(function (locale) {
|
|
53
|
-
var _locale$split = locale.split(/[_-]/),
|
|
54
|
-
_locale$split2 = (0, _slicedToArray2.default)(_locale$split, 1),
|
|
55
|
-
language = _locale$split2[0];
|
|
56
|
-
|
|
57
|
-
if (locale !== config.pseudoLocale && !plurals[language]) {
|
|
58
|
-
console.log(_chalk.default.red("Error: Invalid locale ".concat(_chalk.default.bold(locale), " (missing plural rules)!")));
|
|
59
|
-
console.error();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
catalogs.forEach(function (catalog) {
|
|
63
|
-
var messages = catalog.getTranslations(locale, {
|
|
64
|
-
fallbackLocales: config.fallbackLocales,
|
|
65
|
-
sourceLocale: config.sourceLocale
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (!options.allowEmpty) {
|
|
69
|
-
var missingMsgIds = R.pipe(R.pickBy(R.isNil), R.keys)(messages);
|
|
70
|
-
|
|
71
|
-
if (missingMsgIds.length > 0) {
|
|
72
|
-
console.error(_chalk.default.red("Error: Failed to compile catalog for locale ".concat(_chalk.default.bold(locale), "!")));
|
|
73
|
-
|
|
74
|
-
if (options.verbose) {
|
|
75
|
-
console.error(_chalk.default.red("Missing translations:"));
|
|
76
|
-
missingMsgIds.forEach(function (msgId) {
|
|
77
|
-
return console.log(msgId);
|
|
78
|
-
});
|
|
79
|
-
} else {
|
|
80
|
-
console.error(_chalk.default.red("Missing ".concat(missingMsgIds.length, " translation(s)")));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
console.error();
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (doMerge) {
|
|
89
|
-
mergedCatalogs = _objectSpread(_objectSpread({}, mergedCatalogs), messages);
|
|
90
|
-
} else {
|
|
91
|
-
var namespace = options.typescript ? "ts" : options.namespace || config.compileNamespace;
|
|
92
|
-
var compiledCatalog = (0, _compile.createCompiledCatalog)(locale, messages, {
|
|
93
|
-
strict: false,
|
|
94
|
-
namespace: namespace,
|
|
95
|
-
pseudoLocale: config.pseudoLocale,
|
|
96
|
-
compilerBabelOptions: config.compilerBabelOptions
|
|
97
|
-
});
|
|
98
|
-
var compiledPath = catalog.writeCompiled(locale, compiledCatalog, namespace);
|
|
99
|
-
|
|
100
|
-
if (options.typescript) {
|
|
101
|
-
var typescriptPath = compiledPath.replace(/\.ts?$/, "") + ".d.ts";
|
|
102
|
-
|
|
103
|
-
_fs.default.writeFileSync(typescriptPath, "import { Messages } from '@lingui/core';\n declare const messages: Messages;\n export { messages };\n ");
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
options.verbose && console.error(_chalk.default.green("".concat(locale, " \u21D2 ").concat(compiledPath)));
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (require.main === module) {
|
|
114
|
-
_commander.default.description("Add compile message catalogs and add language data (plurals) to compiled bundle.").option("--config <path>", "Path to the config file").option("--strict", "Disable defaults for missing translations").option("--verbose", "Verbose output").option("--format <format>", "Format of message catalog").option("--typescript", "Create Typescript definition for compiled bundle").option("--namespace <namespace>", "Specify namespace for compiled bundle. Ex: cjs(default) -> module.exports, es -> export, window.test -> window.test").option("--watch", "Enables Watch Mode").option("--debounce <delay>", "Debounces compilation for given amount of milliseconds").on("--help", function () {
|
|
115
|
-
console.log("\n Examples:\n");
|
|
116
|
-
console.log(" # Compile translations and use defaults or message IDs for missing translations");
|
|
117
|
-
console.log(" $ ".concat((0, _help.helpRun)("compile")));
|
|
118
|
-
console.log("");
|
|
119
|
-
console.log(" # Compile translations but fail when there are missing");
|
|
120
|
-
console.log(" # translations (don't replace missing translations with");
|
|
121
|
-
console.log(" # default messages or message IDs)");
|
|
122
|
-
console.log(" $ ".concat((0, _help.helpRun)("compile --strict")));
|
|
123
|
-
}).parse(process.argv);
|
|
124
|
-
|
|
125
|
-
var config = (0, _conf.getConfig)({
|
|
126
|
-
configPath: _commander.default.config
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
if (_commander.default.format) {
|
|
130
|
-
var msg = "--format option is deprecated and will be removed in @lingui/cli@3.0.0." + " Please set format in configuration https://lingui.js.org/ref/conf.html#format";
|
|
131
|
-
console.warn(msg);
|
|
132
|
-
config.format = _commander.default.format;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var compile = function compile() {
|
|
136
|
-
return command(config, {
|
|
137
|
-
verbose: _commander.default.watch || _commander.default.verbose || false,
|
|
138
|
-
allowEmpty: !_commander.default.strict,
|
|
139
|
-
typescript: _commander.default.typescript || config.compileNamespace === "ts" || false,
|
|
140
|
-
namespace: _commander.default.namespace // we want this to be undefined if user does not specify so default can be used
|
|
141
|
-
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
var debounceTimer;
|
|
146
|
-
|
|
147
|
-
var dispatchCompile = function dispatchCompile() {
|
|
148
|
-
// Skip debouncing if not enabled
|
|
149
|
-
if (!_commander.default.debounce) return compile(); // CLear the previous timer if there is any, and schedule the next
|
|
150
|
-
|
|
151
|
-
debounceTimer && clearTimeout(debounceTimer);
|
|
152
|
-
debounceTimer = setTimeout(function () {
|
|
153
|
-
return compile();
|
|
154
|
-
}, _commander.default.debounce);
|
|
155
|
-
}; // Check if Watch Mode is enabled
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
if (_commander.default.watch) {
|
|
159
|
-
var NAME = "{name}";
|
|
160
|
-
var LOCALE = "{locale}";
|
|
161
|
-
console.info(_chalk.default.bold("Initializing Watch Mode..."));
|
|
162
|
-
|
|
163
|
-
var _catalogs = (0, _catalog.getCatalogs)(config);
|
|
164
|
-
|
|
165
|
-
var paths = [];
|
|
166
|
-
var catalogExtension = (0, _api.getFormat)(config.format).catalogExtension;
|
|
167
|
-
config.locales.forEach(function (locale) {
|
|
168
|
-
_catalogs.forEach(function (catalog) {
|
|
169
|
-
paths.push("".concat(catalog.path.replace(LOCALE, locale).replace(NAME, "*")).concat(catalogExtension));
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
var watcher = _chokidar.default.watch(paths, {
|
|
174
|
-
persistent: true
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
var onReady = function onReady() {
|
|
178
|
-
console.info(_chalk.default.green.bold("Watcher is ready!"));
|
|
179
|
-
watcher.on("add", function () {
|
|
180
|
-
return dispatchCompile();
|
|
181
|
-
}).on("change", function () {
|
|
182
|
-
return dispatchCompile();
|
|
183
|
-
});
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
watcher.on("ready", function () {
|
|
187
|
-
return onReady();
|
|
188
|
-
});
|
|
189
|
-
} else {
|
|
190
|
-
var results = compile();
|
|
191
|
-
|
|
192
|
-
if (!results) {
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
console.log("Done!");
|
|
197
|
-
}
|
|
198
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = command;
|
|
9
|
-
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
|
|
12
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
19
|
-
|
|
20
|
-
var _commander = _interopRequireDefault(require("commander"));
|
|
21
|
-
|
|
22
|
-
var _conf = require("@lingui/conf");
|
|
23
|
-
|
|
24
|
-
var _catalog = require("./api/catalog");
|
|
25
|
-
|
|
26
|
-
var _detect = require("./api/detect");
|
|
27
|
-
|
|
28
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
29
|
-
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31
|
-
|
|
32
|
-
function command(_x, _x2) {
|
|
33
|
-
return _command.apply(this, arguments);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _command() {
|
|
37
|
-
_command = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(config, options) {
|
|
38
|
-
var catalogs, catalogStats;
|
|
39
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
40
|
-
while (1) {
|
|
41
|
-
switch (_context2.prev = _context2.next) {
|
|
42
|
-
case 0:
|
|
43
|
-
// `react-app` babel plugin used by CRA requires either BABEL_ENV or NODE_ENV to be
|
|
44
|
-
// set. We're setting it here, because lingui macros are going to use them as well.
|
|
45
|
-
if (!process.env.BABEL_ENV && !process.env.NODE_ENV) {
|
|
46
|
-
process.env.BABEL_ENV = "development";
|
|
47
|
-
} // We need macros to keep imports, so extract-messages plugin know what componets
|
|
48
|
-
// to collect. Users usually use both BABEN_ENV and NODE_ENV, so it's probably
|
|
49
|
-
// safer to introduce a new env variable. LINGUI_EXTRACT=1 during `lingui extract`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
process.env.LINGUI_EXTRACT = "1";
|
|
53
|
-
options.verbose && console.error("Extracting messages from source files…");
|
|
54
|
-
catalogs = (0, _catalog.getCatalogs)(config);
|
|
55
|
-
catalogStats = {};
|
|
56
|
-
_context2.next = 7;
|
|
57
|
-
return Promise.all(catalogs.map( /*#__PURE__*/function () {
|
|
58
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(catalog) {
|
|
59
|
-
var catalogTemplate;
|
|
60
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
61
|
-
while (1) {
|
|
62
|
-
switch (_context.prev = _context.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
_context.next = 2;
|
|
65
|
-
return catalog.makeTemplate(_objectSpread(_objectSpread({}, options), {}, {
|
|
66
|
-
orderBy: config.orderBy,
|
|
67
|
-
projectType: (0, _detect.detect)()
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
case 2:
|
|
71
|
-
catalogTemplate = catalog.readTemplate();
|
|
72
|
-
|
|
73
|
-
if (catalogTemplate !== null && catalogTemplate !== undefined) {
|
|
74
|
-
catalogStats[catalog.templateFile] = Object.keys(catalogTemplate).length;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
case 4:
|
|
78
|
-
case "end":
|
|
79
|
-
return _context.stop();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}, _callee);
|
|
83
|
-
}));
|
|
84
|
-
|
|
85
|
-
return function (_x3) {
|
|
86
|
-
return _ref.apply(this, arguments);
|
|
87
|
-
};
|
|
88
|
-
}()));
|
|
89
|
-
|
|
90
|
-
case 7:
|
|
91
|
-
Object.entries(catalogStats).forEach(function (_ref2) {
|
|
92
|
-
var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
|
|
93
|
-
key = _ref3[0],
|
|
94
|
-
value = _ref3[1];
|
|
95
|
-
|
|
96
|
-
console.log("Catalog statistics for ".concat(_chalk.default.bold(key), ": ").concat(_chalk.default.green(value), " messages"));
|
|
97
|
-
console.log();
|
|
98
|
-
});
|
|
99
|
-
return _context2.abrupt("return", true);
|
|
100
|
-
|
|
101
|
-
case 9:
|
|
102
|
-
case "end":
|
|
103
|
-
return _context2.stop();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}, _callee2);
|
|
107
|
-
}));
|
|
108
|
-
return _command.apply(this, arguments);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (require.main === module) {
|
|
112
|
-
_commander.default.option("--config <path>", "Path to the config file").option("--verbose", "Verbose output").parse(process.argv);
|
|
113
|
-
|
|
114
|
-
var config = (0, _conf.getConfig)({
|
|
115
|
-
configPath: _commander.default.config || process.env.LINGUI_CONFIG
|
|
116
|
-
});
|
|
117
|
-
var result = command(config, {
|
|
118
|
-
verbose: _commander.default.verbose || false,
|
|
119
|
-
configPath: _commander.default.config || process.env.LINGUI_CONFIG
|
|
120
|
-
}).then(function () {
|
|
121
|
-
if (!result) process.exit(1);
|
|
122
|
-
});
|
|
123
|
-
}
|